/rc6.d/K02hobbit

http://github.com/brinkman83/bashrc · Shell · 110 lines · 77 code · 16 blank · 17 comment · 8 complexity · 78bf1e7d611cec4b89c060359ee159b4 MD5 · raw file

  1. #!/bin/sh
  2. # Startup script for the Hobbit monitor
  3. #
  4. # This starts the "hobbitlaunch" tool, which in turn starts
  5. # all of the other Hobbit server programs.
  6. ### BEGIN INIT INFO
  7. # Provides: hobbit
  8. # Required-Start: $remote_fs $network
  9. # Should-Start: $all
  10. # Required-Stop: $remote_fs
  11. # Default-Start: 2 3 4 5
  12. # Default-Stop: 0 1 6
  13. # Short-Description: Hobbit system monitor server
  14. # Description: Hobbit system monitor, server part.
  15. # (Also monitors the local host.)
  16. ### END INIT INFO
  17. PIDFILE=/var/run/hobbit/hobbitlaunch.pid
  18. DAEMON=/usr/lib/hobbit/server/bin/hobbitlaunch
  19. NAME="hobbitd"
  20. DESC="Hobbit Server"
  21. test -x $DAEMON || exit 0
  22. . /lib/lsb/init-functions
  23. . /usr/share/hobbit/init-common.sh
  24. # Include hobbitclient defaults if available
  25. if [ -f /etc/default/hobbit-client ] ; then
  26. . /etc/default/hobbit-client
  27. fi
  28. case "$1" in
  29. "start")
  30. create_includefiles
  31. log_daemon_msg "Starting $DESC" "$NAME"
  32. start-stop-daemon --exec $DAEMON --chuid hobbit --umask 022 --start \
  33. -- \
  34. --config=/etc/hobbit/hobbitlaunch.cfg \
  35. --env=/etc/hobbit/hobbitserver.cfg \
  36. --log=/var/log/hobbit/hobbitlaunch.log \
  37. --pidfile=$PIDFILE
  38. log_end_msg $?
  39. ;;
  40. "stop")
  41. log_daemon_msg "Stopping $DESC" "$NAME"
  42. start-stop-daemon --exec $DAEMON --pidfile $PIDFILE --stop --retry 5
  43. log_end_msg $?
  44. ;;
  45. "status")
  46. if test -s $PIDFILE
  47. then
  48. kill -0 `cat $PIDFILE`
  49. if test $? -eq 0
  50. then
  51. echo "Hobbit (hobbitlaunch) running with PID `cat $PIDFILE`"
  52. exit 0
  53. else
  54. echo "Hobbit not running, removing stale PID file"
  55. rm -f $PIDFILE
  56. exit 1
  57. fi
  58. else
  59. echo "Hobbit (hobbitlaunch) does not appear to be running"
  60. exit 3
  61. fi
  62. ;;
  63. "restart")
  64. if test -s $PIDFILE
  65. then
  66. $0 stop
  67. sleep 1
  68. $0 start
  69. else
  70. log_action_msg "hobbitlaunch does not appear to be running, starting it"
  71. $0 start
  72. fi
  73. ;;
  74. "reload"|"force-reload")
  75. if test -s $PIDFILE
  76. then
  77. create_includefiles
  78. log_action_msg "Reloading hobbitd config"
  79. kill -HUP `cat /var/run/hobbit/hobbitd.pid`
  80. else
  81. log_action_msg "hobbitd not running (no PID file)"
  82. fi
  83. ;;
  84. "rotate")
  85. for PIDFILE in /var/run/hobbit/*.pid
  86. do
  87. test -e $PIDFILE && kill -HUP `cat $PIDFILE`
  88. done
  89. ;;
  90. *)
  91. echo "Usage: $0 start|stop|restart|force-reload|reload|status|rotate"
  92. break;
  93. esac
  94. exit 0