ipmievd.init.debian 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: ipmievd
  4. # Required-Start: $local_fs $remote_fs $syslog
  5. # Required-Stop: $local_fs $remote_fs $syslog
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: S 0 1 6
  8. # Short-Description: IPMI event daemon
  9. # Description: ipmievd is a daemon which will listen for events
  10. # from the BMC that are being sent to the SEL and
  11. # also log those messages to syslog.
  12. ### END INIT INFO
  13. #
  14. # Author: Elmar Hoffmann <elho@elho.net>
  15. # Licence: This script is public domain using the same
  16. # licence as ipmitool itself.
  17. # Modified by: Petter Reinholdtsen
  18. set -e
  19. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  20. DESC="IPMI event daemon"
  21. NAME=ipmievd
  22. DAEMON=/usr/sbin/$NAME
  23. PIDFILE=/var/run/$NAME.pid
  24. SCRIPTNAME=/etc/init.d/$NAME
  25. # Gracefully exit if the package has been removed.
  26. test -x $DAEMON || exit 0
  27. . /lib/lsb/init-functions
  28. . /etc/default/rcS
  29. # Options used by ipmievd.
  30. #
  31. # "open" uses the asynchronous event notification from the OpenIPMI
  32. # kernel driver, "sel" uses active polling of the contents of the SEL
  33. # for new events.
  34. #
  35. # Need to force 'daemon' mode, to make sure messages are sent to
  36. # syslog and the program forks into the background.
  37. #
  38. # Se ipmievd(8) for more info.
  39. IPMIEVD_OPTIONS="open daemon"
  40. # Read config file if it is present.
  41. [ -f /etc/default/$NAME ] && . /etc/default/$NAME
  42. #
  43. # Function that starts the daemon/service.
  44. #
  45. d_start() {
  46. start-stop-daemon --start --quiet --exec $DAEMON -- $IPMIEVD_OPTIONS
  47. }
  48. #
  49. # Function that stops the daemon/service.
  50. #
  51. d_stop() {
  52. start-stop-daemon --stop --quiet --name $NAME --exec $DAEMON
  53. }
  54. CODE=0
  55. case "$1" in
  56. start)
  57. [ "$VERBOSE" != no ] && log_begin_msg "Starting $DESC" "$NAME"
  58. d_start || CODE=$?
  59. [ "$VERBOSE" != no ] && log_end_msg $CODE
  60. exit $CODE
  61. ;;
  62. stop)
  63. log_begin_msg "Stopping $DESC" "$NAME"
  64. d_stop || CODE=$?
  65. log_end_msg $CODE
  66. exit $CODE
  67. ;;
  68. restart|force-reload)
  69. log_begin_msg "Restarting $DESC" "$NAME"
  70. d_stop || true
  71. sleep 1
  72. d_start || CODE=$?
  73. log_end_msg $CODE
  74. exit $CODE
  75. ;;
  76. *)
  77. echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
  78. exit 1
  79. ;;
  80. esac
  81. exit 0