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