3 # vservers: starts and stops vservers
6 # description: Wrapper to start and stop vservers
7 # This script does not care for vservers not started by it
9 # Copyright 1999-2004 Gentoo Foundation
10 # Modified for PLD by Jan Rêkorajski <baggins@pld-linux.org>
11 # Distributed under the terms of the GNU General Public License v2
14 # Source function library
15 . /etc/rc.d/init.d/functions
17 [ -n "$UTIL_VSERVER_VARS" ] || UTIL_VSERVER_VARS=/usr/lib/util-vserver/util-vserver-vars
18 if [ ! -e "$UTIL_VSERVER_VARS" ] ; then
19 echo "Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
22 . "$UTIL_VSERVER_VARS"
24 [ -f /etc/sysconfig/vservers ] && . /etc/sysconfig/vservers
26 [ -n "$NUMPARALLEL" ] || NUMPARALLEL=1
27 [ -n "$LOCKDIR" ] || LOCKDIR="/var/lock/vservers"
43 if [ ! -f /var/lock/subsys/vprocunhide ]; then
44 echo "Run \"/etc/rc.d/init.d/vprocunhide start\" first"
48 if is_yes "$STARTALL"; then
49 if [ ! -f /var/lock/subsys/vservers-all ]; then
50 show "Starting all types of vservers"
52 $_START_VSERVERS -j $NUMPARALLEL --all --start
55 [ $rc -eq 0 ] && touch /var/lock/subsys/vservers-all
57 echo "All types of vservers are already startred"
60 for MARK in $MARKS; do
61 if [ -f /var/lock/subsys/vservers-$MARK ]; then
62 echo "Vservers of type '$MARK' are already startred"
65 show "Starting vservers of type '$MARK'"
67 $_START_VSERVERS -m $MARK -j $NUMPARALLEL --all --start
70 [ $rc -eq 0 ] && touch /var/lock/subsys/vservers-$MARK
74 for VSERVER in $START_VSERVERS; do
75 if [ -f /var/lock/subsys/vserver-$VSERVER ]; then
76 echo "Vserver '$VSERVER' is already startred"
79 show "Starting single vserver '$VSERVER'"
81 $_VSERVER $VSERVER start
84 [ $rc -eq 0 ] && touch /var/lock/subsys/vserver-$VSERVER
86 touch /var/lock/subsys/vservers
89 for VSERVER in $START_VSERVERS; do
90 if [ ! -f /var/lock/subsys/vserver-$VSERVER ]; then
91 echo "Vserver '$VSERVER' is not running"
94 show "Stopping single vserver '$VSERVER'"
96 $_VSERVER $VSERVER stop
99 rm -f /var/lock/subsys/vserver-$VSERVER
102 if is_yes "$STARTALL"; then
103 if [ -f /var/lock/subsys/vservers-all ]; then
104 show "Stopping all types of vservers"
106 $_START_VSERVERS -j $NUMPARALLEL --all --stop
109 rm -f /var/lock/subsys/vservers-all
111 echo "All types of vservers are not running"
114 for MARK in $MARKS; do
115 if [ ! -f /var/lock/subsys/vservers-$MARK ]; then
116 echo "Vservers of type '$MARK' are not running"
119 show "Stopping vservers of type '$MARK'"
121 $_START_VSERVERS -m $MARK -j $NUMPARALLEL --all --stop
124 rm -f /var/lock/subsys/vservers-$MARK
127 rm -f /var/lock/subsys/vservers
130 echo "The following types of vservers are running:"
132 for i in /var/lock/subsys/vservers-*; do
133 [ -f "$i" ] || continue
134 echo $i | awk '{gsub("/var/lock/subsys/vservers-",""); printf(" %s\n",$0); }'
138 if [[ "${running}" != "true" ]]; then
143 echo "/proc/virtual/ says these are running:"
145 for i in /proc/virtual/*; do
146 [ -d $i ] || continue
147 NAME=$( basename $( vuname -g --xid $( basename ${i} ) CONTEX ) )
152 echo "vserver-stat says these are running:"
153 /usr/sbin/vserver-stat
156 echo "Usage: $0 {start|stop|status}"
163 # This must be last line !