This commit was manufactured by cvs2svn to create branch
[util-vserver.git] / sysv / vservers-legacy
1 #!/bin/sh
2 # chkconfig: 345 98 02
3 # description: The vservers service is used to start and stop all
4 #              the virtual servers.
5
6 : ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
7 test -e "$UTIL_VSERVER_VARS" || {
8     echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
9     exit 1
10 }
11 . "$UTIL_VSERVER_VARS"
12
13 # Print the vserver name in priority/alpha order
14 sortserver(){
15         (
16         cd $__CONFDIR
17         for serv in *.conf
18         do
19                 test -f "$serv" || continue
20
21                 PRIORITY=100
22                 . $serv
23                 test "$ONBOOT" || continue
24                 printf "%03d %s\n" $PRIORITY `basename $serv .conf`
25         done
26         ) | sort $* | (while read a b; do echo $b; done)
27 }
28
29 startservers(){
30         echo "Starting the virtual servers"
31         cd $__CONFDIR
32         for name in `sortserver`
33         do
34                 ONBOOT=
35                 . $name.conf
36                 if [ "$ONBOOT" = "yes" ] ; then
37                         $_VSERVER_LEGACY $name start
38                 else
39                         echo virtual server $name not configured for on boot start
40                 fi
41         done
42 }
43
44 BACKGROUND=off
45 if [ -f /etc/vservers.conf ] ; then
46         . /etc/vservers.conf
47 fi
48
49
50 # See how we were called.
51 case "$1" in
52   start)
53         if [ "$BACKGROUND" = "yes" ] ; then
54                 startservers >/dev/tty8 </dev/tty8 2>/dev/tty8 &
55         else
56                 startservers
57         fi
58         touch /var/lock/subsys/vservers-legacy
59         ;;
60   stop)
61         echo "Stopping the virtual servers"
62         cd $__CONFDIR
63         for name in `sortserver -r`
64         do
65                 $_VSERVER_LEGACY $name stop
66         done
67         rm -f /var/lock/subsys/vservers-legacy
68         ;;
69   restart)
70         $0 stop
71         $0 start
72         ;;
73   reload)
74         echo Not implemented
75         ;;
76   status)
77         cd $__CONFDIR
78         for serv in *.conf
79         do
80                 ONBOOT=no
81                 name=`basename $serv .conf`
82                 . $serv
83                 echo -n ONBOOT=$ONBOOT " "
84                 $_VSERVER_LEGACY $name running
85         done
86         ;;
87   *)
88         echo "Usage: vservers {start|stop|restart|reload|status}"
89         exit 1
90 esac
91
92 exit 0