]> git.proxmox.com Git - corosync-pve.git/blob - debian/corosync-notifyd.init
buildsys: drop unused ARCH variable
[corosync-pve.git] / debian / corosync-notifyd.init
1 #! /bin/sh
2 #
3 ### BEGIN INIT INFO
4 # Provides: corosync-notifyd
5 # Required-Start: $network $remote_fs $syslog corosync
6 # Required-Stop: $network $remote_fs $syslog corosync
7 # Should-Start: dbus
8 # Should-Stop: dbus
9 # Default-Start: 2 3 4 5
10 # Default-Stop: 0 1 6
11 # Short-Description: corosync notifying daemon
12 # Description: Manages the notification daemon of the Corosync Cluster Engine.
13 ### END INIT INFO
14
15 # Author: Fabio M. Di Nitto <fabbione@ubuntu.com>
16
17 # PATH should only include /usr/* if it runs after the mountnfs.sh script
18 PATH=/usr/sbin:/usr/bin:/sbin:/bin
19 DESC="corosync notifying daemon"
20 NAME=corosync-notifyd
21 DAEMON=/usr/sbin/$NAME
22 PIDFILE=/var/run/$NAME.pid
23 SCRIPTNAME=/etc/init.d/$NAME
24 PIDFILE=/var/run/corosync.pid
25 RARUNDIR=/var/run/resource-agents
26
27 # Exit if the package is not installed
28 [ -x "$DAEMON" ] || exit 0
29
30 # Read configuration variable file if it is present
31 [ -r /etc/default/corosync-notifyd ] && . /etc/default/corosync-notifyd
32
33 # Define LSB log_* functions.
34 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
35 . /lib/lsb/init-functions
36
37 #
38 # Function that starts the daemon/service
39 #
40 do_start()
41 {
42 # Return
43 # 0 if daemon has been started
44 # 1 if daemon was already running
45 # 2 if daemon could not be started
46 start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \
47 || return 1
48 start-stop-daemon --start --quiet --exec $DAEMON -- $OPTIONS \
49 || return 2
50 # Add code here, if necessary, that waits for the process to be ready
51 # to handle requests from services started subsequently which depend
52 # on this one. As a last resort, sleep for some time.
53 pidof $DAEMON > $PIDFILE
54 }
55
56 #
57 # Function that stops the daemon/service
58 #
59 do_stop()
60 {
61 # Return
62 # 0 if daemon has been stopped
63 # 1 if daemon was already stopped
64 # 2 if daemon could not be stopped
65 # other if a failure occurred
66 start-stop-daemon --stop --quiet --retry forever/QUIT/1 --pidfile $PIDFILE
67 RETVAL="$?"
68 [ "$RETVAL" = 2 ] && return 2
69 # Many daemons don't delete their pidfiles when they exit.
70 rm -f $PIDFILE
71 return "$RETVAL"
72 }
73
74 case "$1" in
75 start)
76 log_daemon_msg "Starting $DESC" "$NAME"
77 do_start
78 case "$?" in
79 0|1) log_end_msg 0 ;;
80 2) log_end_msg 1 ;;
81 esac
82 ;;
83 stop)
84 log_daemon_msg "Stopping $DESC" "$NAME"
85 do_stop
86 case "$?" in
87 0|1) log_end_msg 0 ;;
88 2) log_end_msg 1 ;;
89 esac
90 ;;
91 restart|force-reload)
92 log_daemon_msg "Restarting $DESC" "$NAME"
93 do_stop
94 case "$?" in
95 0|1)
96 do_start
97 case "$?" in
98 0) log_end_msg 0 ;;
99 1) log_end_msg 1 ;; # Old process is still running
100 *) log_end_msg 1 ;; # Failed to start
101 esac
102 ;;
103 *)
104 # Failed to stop
105 log_end_msg 1
106 ;;
107 esac
108 ;;
109 status|monitor)
110 status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
111 ;;
112 *)
113 #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
114 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
115 exit 3
116 ;;
117 esac
118
119 :