airtime-media-monitor 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/bash
  2. ### BEGIN INIT INFO
  3. # Provides: airtime-media-monitor
  4. # Required-Start: $local_fs $remote_fs $network $syslog $all
  5. # Required-Stop: $local_fs $remote_fs $network $syslog
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: Manage airtime-media-monitor daemon
  9. ### END INIT INFO
  10. USERID=www-data
  11. GROUPID=www-data
  12. NAME=airtime-media-monitor
  13. DAEMON=/usr/bin/$NAME
  14. PIDFILE=/var/run/$NAME.pid
  15. # Exit if the package is not installed
  16. [ -x "$DAEMON" ] || exit 0
  17. # Read configuration variable file if it is present
  18. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  19. # Load the VERBOSE setting and other rcS variables
  20. . /lib/init/vars.sh
  21. # Define LSB log_* functions.
  22. # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
  23. # and status_of_proc is working.
  24. . /lib/lsb/init-functions
  25. start () {
  26. start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID \
  27. --make-pidfile --pidfile $PIDFILE --startas $DAEMON
  28. }
  29. stop () {
  30. # Send TERM after 5 seconds, wait at most 30 seconds.
  31. start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE
  32. rm -f $PIDFILE
  33. }
  34. case "${1:-''}" in
  35. 'start')
  36. # start commands here
  37. echo -n "Starting $NAME: "
  38. start
  39. echo "Done."
  40. ;;
  41. 'stop')
  42. # stop commands here
  43. echo -n "Stopping $NAME: "
  44. stop
  45. echo "Done."
  46. ;;
  47. 'restart')
  48. # restart commands here
  49. echo -n "Restarting $NAME: "
  50. stop
  51. start
  52. echo "Done."
  53. ;;
  54. 'force-reload')
  55. # reload commands here
  56. echo -n "Reloading $NAME: "
  57. stop
  58. start
  59. echo "Done."
  60. ;;
  61. 'status')
  62. status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
  63. ;;
  64. *) # no parameter specified
  65. echo "Usage: $SELF start|stop|restart|status"
  66. exit 1
  67. ;;
  68. esac