]> git.pld-linux.org Git - packages/util-vserver.git/blob - vservers-legacy.init
- remove the "third chunk" mentioned in http://irc.13thfloor.at/LOG/2007-11/LOG_2007...
[packages/util-vserver.git] / vservers-legacy.init
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 . /etc/init.d/functions
7
8 . /etc/sysconfig/vservers-legacy
9
10 [ -n "$UTIL_VSERVER_VARS" ] || UTIL_VSERVER_VARS=/usr/lib/util-vserver/util-vserver-vars
11 if [ ! -e "$UTIL_VSERVER_VARS" ] ; then
12         echo "Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
13         exit 1
14 fi
15 . "$UTIL_VSERVER_VARS"
16
17 # Print the vserver name in priority/alpha order
18 sortserver(){
19         (
20         cd $__CONFDIR
21         for serv in *.conf
22         do
23                 test -f "$serv" || continue
24
25                 PRIORITY=100
26                 . $serv
27                 test "$ONBOOT" || continue
28                 printf "%03d %s\n" $PRIORITY `basename $serv .conf`
29         done
30         ) | sort $* | (while read a b; do echo $b; done)
31 }
32
33 startservers(){
34         cd $__CONFDIR
35         for name in `sortserver`
36         do
37                 ONBOOT=
38                 . $name.conf
39                 if [ "$ONBOOT" = "yes" ] ; then
40                         $_VSERVER_LEGACY $name start
41                 fi
42         done
43 }
44
45 # See how we were called.
46 case "$1" in
47   start)
48         if [ ! -f /var/lock/subsys/vservers-legacy ] ; then
49             show "Starting the virtual servers"
50             busy
51             if [ "$BACKGROUND" = "yes" ] ; then
52                 startservers >/dev/tty8 </dev/tty8 2>/dev/tty8 &
53             else
54                 startservers
55             fi
56             touch /var/lock/subsys/vservers-legacy
57             ok
58         else
59             msg_already_running "virtual servers"
60         fi
61         ;;
62   stop)
63         if [ -f /var/lock/subsys/vservers-legacy ] ; then
64             show "Stopping the virtual servers"
65             busy
66             cd $__CONFDIR
67             for name in `sortserver -r` ; do
68                 $_VSERVER_LEGACY $name stop
69             done
70             rm -f /var/lock/subsys/vservers-legacy
71             ok
72         else
73             msg_not_running "virtual servers"
74         fi
75         ;;
76   restart)
77         $0 stop
78         $0 start
79         ;;
80   status)
81         if [ -f /var/lock/subsys/vservers-legacy ] ; then
82             cd $__CONFDIR
83             for serv in *.conf ; do
84                 ONBOOT=no
85                 name=`basename $serv .conf`
86                 . $serv
87                 echo -n ONBOOT=$ONBOOT " "
88                 $_VSERVER_LEGACY $name running
89             done
90         else
91             msg_not_running "virtual servers"
92         fi
93         ;;
94   *)
95         echo "Usage: vservers {start|stop|restart|status}"
96         exit 1
97 esac
98
99 exit $RETVAL
100
101 # This must be last line !
102 # vi:syntax=sh:tw=78:ts=8:sw=4
This page took 0.085394 seconds and 3 git commands to generate.