konfd 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: kondf
  4. # Required-Start: $remote_fs
  5. # Required-Stop: $remote_fs
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: Konfd initscript
  9. # Description: Klish configuration daemon
  10. ### END INIT INFO
  11. # Author: Nixus Networks <oss@nixus.es>
  12. #
  13. # Please remove the "Author" lines above and replace them
  14. # with your own name if you copy and modify this script.
  15. # Do NOT "set -e"
  16. # PATH should only include /usr/* if it runs after the mountnfs.sh script
  17. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  18. DESC="Klish configuration daemon"
  19. NAME=gluff
  20. DAEMON=/usr/sbin/$NAME
  21. PIDFILE=/var/run/$NAME.pid
  22. SCRIPTNAME=/etc/init.d/$NAME
  23. # Exit if the package is not installed
  24. [ -x "$DAEMON" ] || exit 0
  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. # Define LSB log_* functions.
  30. # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
  31. # and status_of_proc is working.
  32. . /lib/lsb/init-functions
  33. DAEMON_ARGS="-l $QUEUE_DB -h $MYSQL_HOST -u $MYSQL_USER -p $MYSQL_PASSWD -d $MYSQL_DB $OPTIONS"
  34. #
  35. # Function that starts the daemon/service
  36. #
  37. do_start()
  38. {
  39. log_daemon_msg "Starting $DESC" "$NAME"
  40. start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_ARGS
  41. ps -fe | grep $DAEMON | head -n1 | cut -d" " -f 6 > ${PIDFILE}
  42. log_end_msg $?
  43. }
  44. #
  45. # Function that stops the daemon/service
  46. #
  47. do_stop()
  48. {
  49. log_daemon_msg "Stopping $DESC" "$NAME"
  50. start-stop-daemon --stop --quiet --pidfile "$PIDFILE"
  51. log_end_msg $?
  52. rm -f "$PIDFILE"
  53. }
  54. #
  55. # Function that sends a SIGHUP to the daemon/service
  56. #
  57. do_reload() {
  58. #
  59. # If the daemon can reload its configuration without
  60. # restarting (for example, when it is sent a SIGHUP),
  61. # then implement that here.
  62. #
  63. start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
  64. return 0
  65. }
  66. case "$1" in
  67. start)
  68. [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  69. do_start
  70. case "$?" in
  71. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  72. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  73. esac
  74. ;;
  75. stop)
  76. [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  77. do_stop
  78. case "$?" in
  79. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  80. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  81. esac
  82. ;;
  83. status)
  84. status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
  85. ;;
  86. #reload|force-reload)
  87. #
  88. # If do_reload() is not implemented then leave this commented out
  89. # and leave 'force-reload' as an alias for 'restart'.
  90. #
  91. #log_daemon_msg "Reloading $DESC" "$NAME"
  92. #do_reload
  93. #log_end_msg $?
  94. #;;
  95. restart|force-reload)
  96. #
  97. # If the "reload" option is implemented then remove the
  98. # 'force-reload' alias
  99. #
  100. do_stop
  101. case "$?" in
  102. 0|1)
  103. do_start
  104. case "$?" in
  105. 0) log_end_msg 0 ;;
  106. 1) log_end_msg 1 ;; # Old process is still running
  107. *) log_end_msg 1 ;; # Failed to start
  108. esac
  109. ;;
  110. *)
  111. # Failed to stop
  112. log_end_msg 1
  113. ;;
  114. esac
  115. ;;
  116. *)
  117. #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
  118. echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
  119. exit 3
  120. ;;
  121. esac
  122. :