ornek_servis 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/sh
  2. # Derived from https://gist.github.com/sodik82/4f4aafdb52e84102b75d
  3. set -e
  4. . /lib/lsb/init-functions
  5. # Must be a valid filename
  6. NAME=foo
  7. PIDFILE=/run/$NAME.pid
  8. # Full path to executable
  9. DAEMON=/usr/local/bin/bar
  10. # Options
  11. DAEMON_OPTS="--baz=quux"
  12. # User to run the command as
  13. USER=www
  14. export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
  15. case "$1" in
  16. start)
  17. echo -n "Starting daemon: "$NAME
  18. start-stop-daemon --start --quiet -b -m --pidfile $PIDFILE --chdir $WORK_DIR --chuid $USER --exec $DAEMON -- $DAEMON_OPTS
  19. echo "."
  20. ;;
  21. stop)
  22. echo -n "Stopping daemon: "$NAME
  23. start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
  24. echo "."
  25. ;;
  26. restart)
  27. echo -n "Restarting daemon: "$NAME
  28. start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $PIDFILE
  29. start-stop-daemon --start --quiet -b -m --pidfile $PIDFILE --chdir $WORK_DIR --chuid $USER --exec $DAEMON -- $DAEMON_OPTS
  30. echo "."
  31. ;;
  32. status)
  33. status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
  34. ;;
  35. *)
  36. echo "Usage: "$1" {start|stop|restart}"
  37. exit 1
  38. esac