/debian/perlbal.init

http://github.com/perlbal/Perlbal · Shell · 97 lines · 54 code · 14 blank · 29 comment · 4 complexity · 77967738fff133b36c75f65a56632375 MD5 · raw file

  1. #! /bin/sh
  2. #
  3. # perlbal Start and Stop the perlbal daemon
  4. #
  5. ### BEGIN INIT INFO
  6. # Provides: perlbal
  7. # Required-Start: $local_fs $remote_fs $network $syslog
  8. # Required-Stop: $local_fs $remote_fs $network $syslog
  9. # Default-Start: 2 3 4 5
  10. # Default-Stop: 0 1 6
  11. # Short-Description: Start/Stop the perlbal daemon
  12. # Description: Start/Stop the perlbal daemon.
  13. ### END INIT INFO
  14. # PATH should only include /usr/* if it runs after the mountnfs.sh script
  15. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  16. DAEMON=/usr/sbin/perlbal
  17. NAME=perlbal
  18. DESC=Perlbal
  19. PIDFILE=/var/run/$NAME.pid
  20. USER=root
  21. SCRIPTNAME=/etc/init.d/$NAME
  22. # Exit if the package is not installed
  23. [ -x "$DAEMON" ] || exit 0
  24. set -e
  25. # Read configuration variable file if it is present
  26. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  27. # Load the VERBOSE setting and other rcS variables
  28. . /lib/init/vars.sh
  29. #
  30. # Function that starts the daemon/service
  31. #
  32. do_start()
  33. {
  34. if [ -e $PIDFILE ]
  35. then
  36. if [ -d /proc/`cat $PIDFILE`/ ]
  37. then
  38. echo "$NAME already running."
  39. exit 0;
  40. else
  41. rm -f $PIDFILE
  42. fi
  43. fi
  44. start-stop-daemon --start --quiet --exec $DAEMON --pidfile $PIDFILE -b -m --name $NAME --user $USER
  45. }
  46. #
  47. # Function that stops the daemon/service
  48. #
  49. do_stop()
  50. {
  51. start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --name $NAME --user $USER
  52. rm -f $PIDFILE
  53. }
  54. case "$1" in
  55. start)
  56. echo -n "Starting $DESC: "
  57. do_start
  58. echo "$NAME."
  59. ;;
  60. stop)
  61. echo -n "Stopping $DESC: "
  62. do_stop
  63. echo "$NAME."
  64. ;;
  65. restart|force-reload)
  66. #
  67. # If the "reload" option is implemented, move the "force-reload"
  68. # option to the "reload" entry above. If not, "force-reload" is
  69. # just the same as "restart".
  70. #
  71. echo -n "Restarting $DESC: "
  72. do_stop
  73. sleep 1
  74. do_start
  75. echo "$NAME."
  76. ;;
  77. *)
  78. #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
  79. echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
  80. exit 3
  81. ;;
  82. esac
  83. exit 0