init scripts: Don't error out when stopping in restart action
[hcoop/domtool2.git] / scripts / domtool-slave
1 #!/usr/bin/pagsh.openafs
2
3 # This script should go in /etc/init.d/ on Debian Linux systems running Domtool slaves.
4
5 SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)
6 PIDFILE="/var/run/k5start-domtool-slave.pid"
7
8 set -e
9
10 case $1 in
11 start)
12 echo -n "Starting Domtool slave: domtool-slave"
13 if sudo -u domtool domtool-admin-sudo slave-ping; then
14 echo "...already running."
15 else
16 start-stop-daemon --start --pidfile $PIDFILE \
17 -c domtool:domtool \
18 --exec /usr/bin/k5start -- -U -b \
19 -f /etc/keytabs/domtool \
20 -K 300 -t -p $PIDFILE \
21 domtool-slave-logged
22 echo "."
23 fi
24 ;;
25
26 stop)
27 echo -n "Stopping Domtool slave: domtool-slave"
28 if sudo -u domtool domtool-admin-sudo slave-shutdown; then
29 echo "."
30 else
31 start-stop-daemon --stop --pidfile $PIDFILE
32 echo "."
33 fi
34 rm -f $PIDFILE
35 ;;
36
37 restart|reload|force-reload)
38 set +e; $SELF stop; set -e
39 $SELF start
40 ;;
41
42 status)
43 if sudo -u domtool domtool-admin-sudo slave-ping; then
44 echo "Domtool slave is running."
45 else
46 echo "Domtool slave is stopped."
47 exit 3
48 fi
49 ;;
50
51 *)
52 echo "Usage: $SELF start|stop|restart|reload|force-reload|status"
53 exit 1
54 ;;
55 esac