]> git.pld-linux.org Git - packages/util-vserver.git/blame_incremental - vservers-legacy.init
- fix docs BRs
[packages/util-vserver.git] / vservers-legacy.init
... / ...
CommitLineData
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# $Id$
7
8. /etc/init.d/functions
9
10. /etc/sysconfig/vservers-legacy
11
12[ -n "$UTIL_VSERVER_VARS" ] || UTIL_VSERVER_VARS=/usr/lib/util-vserver/util-vserver-vars
13if [ ! -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
16fi
17. "$UTIL_VSERVER_VARS"
18
19# Print the vserver name in priority/alpha order
20sortserver(){
21 (
22 cd $__CONFDIR
23 for serv in *.conf; do
24 test -f "$serv" || continue
25
26 PRIORITY=100
27 . $serv
28 test "$ONBOOT" || continue
29 printf "%03d %s\n" $PRIORITY $(basename $serv .conf)
30 done
31 ) | sort $* | (while read a b; do echo $b; done)
32}
33
34startservers(){
35 cd $__CONFDIR
36 for name in $(sortserver); do
37 ONBOOT=
38 . $name.conf
39 if [ "$ONBOOT" = "yes" ] ; then
40 $_VSERVER_LEGACY $name start
41 fi
42 done
43}
44
45start() {
46 if [ ! -f /var/lock/subsys/vservers-legacy ] ; then
47 show "Starting the virtual servers"
48 busy
49 if [ "$BACKGROUND" = "yes" ] ; then
50 startservers >/dev/tty8 </dev/tty8 2>/dev/tty8 &
51 else
52 startservers
53 fi
54 touch /var/lock/subsys/vservers-legacy
55 ok
56 else
57 msg_already_running "virtual servers"
58 fi
59}
60
61stop() {
62 if [ -f /var/lock/subsys/vservers-legacy ] ; then
63 show "Stopping the virtual servers"
64 busy
65 cd $__CONFDIR
66 for name in $(sortserver -r); do
67 $_VSERVER_LEGACY $name stop
68 done
69 rm -f /var/lock/subsys/vservers-legacy
70 ok
71 else
72 msg_not_running "virtual servers"
73 fi
74}
75
76RETVAL=0
77# See how we were called.
78case "$1" in
79 start)
80 start
81 ;;
82 stop)
83 stop
84 ;;
85 restart)
86 stop
87 start
88 ;;
89 status)
90 if [ -f /var/lock/subsys/vservers-legacy ]; then
91 cd $__CONFDIR
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
98 done
99 else
100 msg_not_running "virtual servers"
101 fi
102 ;;
103 *)
104 msg_usage "$0 {start|stop|restart|status}"
105 exit 3
106esac
107
108exit $RETVAL
This page took 0.026208 seconds and 4 git commands to generate.