* Replace hpasm initscript with a bare version.
[matthijs/servers/drsnuggles.git] / etc / init.d / hpasm
1 #! /bin/sh
2 ### BEGIN INIT INFO
3 # Provides:            hpasm
4 # Required-Start:      snmp
5 # Required-Stop:       hprsm cmanic cmastor
6 # Default-Start:       2 3 4 5
7 # Default-Stop:        0 1 6
8 # Description:         starts hpasmd (HP Advanced System Management Drivers and Agents)
9 ### END INIT INFO
10
11 # Author: Matthijs Kooijman <matthijs@stdin.nl>
12 # This file is mostly built from the skeleton, but with PIDFILE and VERBOSE
13 # stuff removed.. It starts hpasmd, without any extra crap or configs.
14
15 # Just hpasmd is enough to be able to use hpasmcli and hplog, to send ASR pings
16 # and to shutdown the system in case of thermal failure.
17
18 PATH=/sbin:/usr/sbin:/bin:/usr/bin
19 DESC="HP Advanced System Management Daemon"
20 NAME=hpasmd
21 DAEMON=/opt/compaq/hpasmd/bin/hpasmd
22 DAEMON_ARGS=""
23 SCRIPTNAME=/etc/init.d/$NAME
24
25 # Exit if the package is not installed
26 [ -x "$DAEMON" ] || exit 0
27
28 # Read configuration variable file if it is present
29 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
30
31 # Load the VERBOSE setting and other rcS variables
32 . /lib/init/vars.sh
33
34 # Define LSB log_* functions.
35 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
36 . /lib/lsb/init-functions
37
38 #
39 # Function that starts the daemon/service
40 #
41 do_start()
42 {
43         # Return
44         #   0 if daemon has been started
45         #   1 if daemon was already running
46         #   2 if daemon could not be started
47         start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \
48                 || return 1
49         start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_ARGS \
50                 || return 2
51 }
52
53 #
54 # Function that stops the daemon/service
55 #
56 do_stop()
57 {
58         # Return
59         #   0 if daemon has been stopped
60         #   1 if daemon was already stopped
61         #   2 if daemon could not be stopped
62         #   other if a failure occurred
63         start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --name $NAME
64         RETVAL="$?"
65         return "$RETVAL"
66 }
67
68 case "$1" in
69   start)
70         log_daemon_msg "Starting $DESC" "$NAME"
71         do_start
72         case "$?" in
73                 0|1) log_end_msg 0 ;;
74                 2) log_end_msg 1 ;;
75         esac
76         ;;
77   stop)
78         log_daemon_msg "Stopping $DESC" "$NAME"
79         do_stop
80         case "$?" in
81                 0|1) log_end_msg 0 ;;
82                 2) log_end_msg 1 ;;
83         esac
84         ;;
85   restart|force-reload)
86         #
87         # If the "reload" option is implemented then remove the
88         # 'force-reload' alias
89         #
90         log_daemon_msg "Restarting $DESC" "$NAME"
91         do_stop
92         case "$?" in
93           0|1)
94                 do_start
95                 case "$?" in
96                         0) log_end_msg 0 ;;
97                         1) log_end_msg 1 ;; # Old process is still running
98                         *) log_end_msg 1 ;; # Failed to start
99                 esac
100                 ;;
101           *)
102                 # Failed to stop
103                 log_end_msg 1
104                 ;;
105         esac
106         ;;
107   *)
108         #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
109         echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
110         exit 3
111         ;;
112 esac
113
114 :