]> git.pld-linux.org Git - packages/util-vserver.git/blob - vservers-legacy.init
- rel 2; build with glibc, so it will also work on systems with newer kernels that...
[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/share/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; do
22         test -f "$serv" || continue
23
24                 PRIORITY=100
25                 . $serv
26                 test "$ONBOOT" || continue
27                 printf "%03d %s\n" $PRIORITY $(basename $serv .conf)
28         done
29         ) | sort $* | (while read a b; do echo $b; done)
30 }
31
32 startservers(){
33         cd $__CONFDIR
34         for name in $(sortserver); do
35                 ONBOOT=
36                 . $name.conf
37                 if [ "$ONBOOT" = "yes" ] ; then
38                         $_VSERVER_LEGACY $name start
39                 fi
40         done
41 }
42
43 start() {
44         if [ ! -f /var/lock/subsys/vservers-legacy ] ; then
45             show "Starting the virtual servers"
46             busy
47             if [ "$BACKGROUND" = "yes" ] ; then
48                         startservers >/dev/tty8 </dev/tty8 2>/dev/tty8 &
49             else
50                         startservers
51             fi
52             touch /var/lock/subsys/vservers-legacy
53             ok
54         else
55             msg_already_running "virtual servers"
56         fi
57 }
58
59 stop() {
60         if [ -f /var/lock/subsys/vservers-legacy ] ; then
61             show "Stopping the virtual servers"
62             busy
63             cd $__CONFDIR
64             for name in $(sortserver -r); do
65                         $_VSERVER_LEGACY $name stop
66             done
67             rm -f /var/lock/subsys/vservers-legacy
68             ok
69         else
70             msg_not_running "virtual servers"
71         fi
72 }
73
74 RETVAL=0
75 # See how we were called.
76 case "$1" in
77   start)
78         start
79         ;;
80   stop)
81         stop
82         ;;
83   restart)
84         stop
85         start
86         ;;
87   status)
88         if [ -f /var/lock/subsys/vservers-legacy ]; then
89             cd $__CONFDIR
90             for serv in *.conf; do
91                         ONBOOT=no
92                         name=$(basename $serv .conf)
93                         . $serv
94                         echo -n ONBOOT=$ONBOOT " "
95                         $_VSERVER_LEGACY $name running
96             done
97         else
98             msg_not_running "virtual servers"
99         fi
100         ;;
101   *)
102         msg_usage "$0 {start|stop|restart|status}"
103         exit 3
104 esac
105
106 exit $RETVAL
This page took 0.069322 seconds and 3 git commands to generate.