5392bea7f33e4a9c529ce40282e96695154656bd
[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
4 # running Domtool slaves.
5
6 SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)
7 PIDFILE="/var/run/domtool/k5start-slave.pid"
8
9 set -e
10
11 case $1 in
12 start)
13 echo -n "Starting Domtool slave: domtool-slave"
14 if sudo -u domtool domtool-admin-sudo slave-ping; then
15 echo "...already running."
16 else
17 PIDDIR=$(dirname "$PIDFILE")
18 if test ! -d "$PIDDIR"; then
19 mkdir -m 0755 $PIDDIR
20 chown domtool:domtool $PIDDIR
21 fi
22
23 start-stop-daemon --start --pidfile $PIDFILE \
24 -c domtool:domtool \
25 --exec /usr/bin/k5start -- -U -b \
26 -f /etc/keytabs/domtool \
27 -K 300 -t -p $PIDFILE \
28 domtool-slave-logged
29 echo "."
30 fi
31 ;;
32
33 stop)
34 echo -n "Stopping Domtool slave: domtool-slave"
35 if sudo -u domtool domtool-admin-sudo slave-shutdown; then
36 echo "."
37 else
38 start-stop-daemon --stop --pidfile $PIDFILE
39 echo "."
40 fi
41 rm -f $PIDFILE
42 ;;
43
44 restart|reload|force-reload)
45 set +e; $SELF stop; set -e
46 $SELF start
47 ;;
48
49 status)
50 if sudo -u domtool domtool-admin-sudo slave-ping; then
51 echo "Domtool slave is running."
52 else
53 echo "Domtool slave is stopped."
54 exit 3
55 fi
56 ;;
57
58 *)
59 echo "Usage: $SELF start|stop|restart|reload|force-reload|status"
60 exit 1
61 ;;
62 esac