# chkconfig: 345 98 02
# description: The vservers service is used to start and stop all
# the virtual servers.
+#
+# $Id$
. /etc/init.d/functions
sortserver(){
(
cd $__CONFDIR
- for serv in *.conf
- do
- test -f "$serv" || continue
+ for serv in *.conf; do
+ test -f "$serv" || continue
PRIORITY=100
. $serv
test "$ONBOOT" || continue
- printf "%03d %s\n" $PRIORITY `basename $serv .conf`
+ printf "%03d %s\n" $PRIORITY $(basename $serv .conf)
done
) | sort $* | (while read a b; do echo $b; done)
}
startservers(){
cd $__CONFDIR
- for name in `sortserver`
- do
+ for name in $(sortserver); do
ONBOOT=
. $name.conf
if [ "$ONBOOT" = "yes" ] ; then
done
}
-# See how we were called.
-case "$1" in
- start)
+start() {
if [ ! -f /var/lock/subsys/vservers-legacy ] ; then
show "Starting the virtual servers"
busy
if [ "$BACKGROUND" = "yes" ] ; then
- startservers >/dev/tty8 </dev/tty8 2>/dev/tty8 &
+ startservers >/dev/tty8 </dev/tty8 2>/dev/tty8 &
else
- startservers
+ startservers
fi
touch /var/lock/subsys/vservers-legacy
ok
else
msg_already_running "virtual servers"
fi
- ;;
- stop)
+}
+
+stop() {
if [ -f /var/lock/subsys/vservers-legacy ] ; then
show "Stopping the virtual servers"
busy
cd $__CONFDIR
- for name in `sortserver -r` ; do
- $_VSERVER_LEGACY $name stop
+ for name in $(sortserver -r); do
+ $_VSERVER_LEGACY $name stop
done
rm -f /var/lock/subsys/vservers-legacy
ok
else
msg_not_running "virtual servers"
fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
;;
restart)
- $0 stop
- $0 start
+ stop
+ start
;;
status)
- if [ -f /var/lock/subsys/vservers-legacy ] ; then
+ if [ -f /var/lock/subsys/vservers-legacy ]; then
cd $__CONFDIR
- for serv in *.conf ; do
- ONBOOT=no
- name=`basename $serv .conf`
- . $serv
- echo -n ONBOOT=$ONBOOT " "
- $_VSERVER_LEGACY $name running
+ for serv in *.conf; do
+ ONBOOT=no
+ name=$(basename $serv .conf)
+ . $serv
+ echo -n ONBOOT=$ONBOOT " "
+ $_VSERVER_LEGACY $name running
done
else
msg_not_running "virtual servers"
fi
;;
*)
- echo "Usage: vservers {start|stop|restart|status}"
- exit 1
+ msg_usage "$0 {start|stop|restart|status}"
+ exit 3
esac
exit $RETVAL
-
-# This must be last line !
-# vi:syntax=sh:tw=78:ts=8:sw=4