X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=vservers-legacy.init;h=6724107671e0363af5c350f181a077c29d0ce388;hb=bd81bec6754be378faaed080aa54c3dce51f507d;hp=1c22d56734e12535107c84dfb13dc2430a887d76;hpb=0ef6e1b225c3b962528d49d49a34a6cad62ce4bd;p=packages%2Futil-vserver.git diff --git a/vservers-legacy.init b/vservers-legacy.init index 1c22d56..6724107 100644 --- a/vservers-legacy.init +++ b/vservers-legacy.init @@ -2,12 +2,14 @@ # chkconfig: 345 98 02 # description: The vservers service is used to start and stop all # the virtual servers. +# +# $Id$ . /etc/init.d/functions . /etc/sysconfig/vservers-legacy -[ -n "$UTIL_VSERVER_VARS" ] || $UTIL_VSERVER_VARS=/usr/lib/util-vserver/util-vserver-vars +[ -n "$UTIL_VSERVER_VARS" ] || UTIL_VSERVER_VARS=/usr/lib/util-vserver/util-vserver-vars if [ ! -e "$UTIL_VSERVER_VARS" ] ; then echo "Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2 exit 1 @@ -18,22 +20,20 @@ fi 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 @@ -42,61 +42,67 @@ startservers(){ 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 & + startservers >/dev/tty8 /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