- moved here from sysv/
[util-vserver.git] / sysv / rebootmgr.subst
1 #!/bin/sh
2 # chkconfig: - 98 10
3 # description: The rebootmgr service is monitoring all virtual servers \
4 #              and restart them as need. Virtual servers are using \
5 #              the /sbin/vreboot command to talk with the reboot manager
6 # processname: rebootmgr
7 # config: /etc/vservers
8
9 VROOTDIR=/vservers
10 USR_SBIN=/usr/sbin
11 PIDFILE=/var/run/rebootmgr.pid
12 # See how we were called.
13 case "$1" in
14   start)
15         echo "Starting the reboot manager"
16         cd /etc/vservers
17         VSERVERS=
18         for serv in *.conf
19         do
20                 test -f "$serv" || continue
21                 
22                 serv=`basename $serv .conf`
23                 if [ -d $VROOTDIR/$serv ] ; then
24                         VSERVERS="$VSERVERS $serv"
25                 fi
26         done
27         $USR_SBIN/rebootmgr --pidfile $PIDFILE $VSERVERS &
28         touch /var/lock/subsys/rebootmgr
29         ;;
30   stop)
31         echo "Stopping the reboot manager"
32         kill `cat $PIDFILE`
33         rm -f /var/lock/subsys/rebootmgr
34         rm -f $PIDFILE
35         ;;
36   restart|force-reload)
37         $0 stop
38         $0 start
39         ;;
40   reload)
41         echo Not implemented
42         ;;
43   status)
44         if [ -f $PIDFILE ] ; then
45                 if kill -0 `cat $PIDFILE`
46                 then
47                         echo rebootmgr is running
48                 else
49                         echo rebootmgr is NOT running
50                 fi
51         fi
52         ;;
53   *)
54         echo "Usage: rebootmgr {start|stop|restart|reload|status}"
55         exit 1
56 esac
57
58 exit 0
59
60
61
62
63