]> git.pld-linux.org Git - packages/util-vserver.git/blob - rebootmgr.init
- rel 2; build with glibc, so it will also work on systems with newer kernels that...
[packages/util-vserver.git] / rebootmgr.init
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 . /etc/init.d/functions
10
11 [ -n "$UTIL_VSERVER_VARS" ] || UTIL_VSERVER_VARS=/usr/share/util-vserver/util-vserver-vars
12 if [ ! -e "$UTIL_VSERVER_VARS" ] ; then
13         echo "Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
14         exit 1
15 fi
16 . "$UTIL_VSERVER_VARS"
17
18 start() {
19         if [ ! -f /var/lock/subsys/rebootmgr ] ; then
20             show "Starting the legacy vserver reboot manager"
21             busy
22             cd $__CONFDIR
23             VSERVERS=
24             for serv in *.conf; do
25                         [ -f "$serv" ] || continue
26                         serv=`basename $serv .conf`
27                         if [ -d $__DEFAULT_VSERVERDIR/$serv ] ; then
28                                 VSERVERS="$VSERVERS $serv"
29                         fi
30             done
31             $_REBOOTMGR --pidfile /var/run/rebootmgr.pid $VSERVERS &
32             touch /var/lock/subsys/rebootmgr
33             ok
34         else
35             msg_already_running "legacy vserver reboot manager"
36         fi
37 }
38
39 stop() {
40         if [ -f /var/lock/subsys/rebootmgr ] ; then
41                 show "Stopping the legacy vserver reboot manager"
42                 busy
43                 kill $(cat /var/run/rebootmgr.pid)
44                 rm -f /var/lock/subsys/rebootmgr
45                 rm -f /var/run/rebootmgr.pid
46                 ok
47         else
48             msg_not_running "legacy vserver reboot manager"
49         fi
50 }
51
52 RETVAL=0
53 # See how we were called.
54 case "$1" in
55   start)
56         start
57         ;;
58   stop)
59         stop
60         ;;
61   restart)
62         stop
63         start
64         ;;
65   status)
66         if [ -f /var/run/rebootmgr.pid ] ; then
67             if kill -0 $(cat /var/run/rebootmgr.pid); then
68                         echo rebootmgr is running
69             else
70                         echo rebootmgr is NOT running
71             fi
72         fi
73         ;;
74   *)
75         msg_usage "$0 {start|stop|restart|status}"
76         exit 3
77 esac
78
79 exit $RETVAL
This page took 0.08574 seconds and 3 git commands to generate.