ready for tagging
[util-vserver.git] / sysv / rebootmgr
1 #!/bin/sh
2 # chkconfig: - 98 02
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 : ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
10 test -e "$UTIL_VSERVER_VARS" || {
11     echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
12     exit 1
13 }
14 . "$UTIL_VSERVER_VARS"
15
16 PIDFILE=/var/run/rebootmgr.pid
17 # See how we were called.
18 case "$1" in
19   start)
20         echo "Starting the reboot manager"
21         cd $__CONFDIR
22         VSERVERS=
23         for serv in *.conf
24         do
25                 test -f "$serv" || continue
26
27                 serv=`basename $serv .conf`
28                 if [ -d $__DEFAULT_VSERVERDIR/$serv ] ; then
29                         VSERVERS="$VSERVERS $serv"
30                 fi
31         done
32         $_REBOOTMGR --pidfile $PIDFILE $VSERVERS &
33         touch /var/lock/subsys/rebootmgr
34         ;;
35   stop)
36         echo "Stopping the reboot manager"
37         kill `cat $PIDFILE`
38         rm -f /var/lock/subsys/rebootmgr
39         rm -f $PIDFILE
40         ;;
41   restart)
42         $0 stop
43         $0 start
44         ;;
45   reload)
46         echo Not implemented
47         ;;
48   status)
49         if [ -f $PIDFILE ] ; then
50                 if kill -0 `cat $PIDFILE`
51                 then
52                         echo rebootmgr is running
53                 else
54                         echo rebootmgr is NOT running
55                 fi
56         fi
57         ;;
58   *)
59         echo "Usage: rebootmgr {start|stop|restart|reload|status}"
60         exit 1
61 esac
62
63 exit 0
64
65
66
67
68