-esac
-# Uncomment the onboot line if you want to enable this
-# virtual server at boot time
-#ONBOOT=yes
-# You can set a different NIS domain for the vserver
-# If empty, the current on is kept
-# Set it to "none" to have no NIS domain set
-S_DOMAINNAME=
-# You can set the priority level (nice) of all process in the vserver
-# Even root won't be able to raise it
-S_NICE=
-# You can set various flags for the new security context
-# lock: Prevent the vserver from setting new security context
-# sched: Merge scheduler priority of all processes in the vserver
-# so that it acts a like a single one.
-# nproc: Limit the number of processes in the vserver according to ulimit
-# (instead of a per user limit, this becomes a per vserver limit)
-# private: No other process can join this security context. Even root
-# Do not forget the quotes around the flags
-S_FLAGS="lock nproc"
-# You can set various ulimit flags and they will be inherited by the
-# vserver. You enter here various command line argument of ulimit
-# ULIMIT="-HS -u 200"
-# The example above, combined with the nproc S_FLAGS will limit the
-# vserver to a maximum of 200 processes
-#ULIMIT="-HS -u 1000"
-ULIMIT=""
-# You can set various capabilities. By default, the vserver are run
-# with a limited set, so you can let root run in a vserver and not
-# worry about it. He can't take over the machine. In some cases
-# you can to give a little more capabilities (such as CAP_NET_RAW)
-# S_CAPS="CAP_NET_RAW"
-S_CAPS=""
-# Select an unused context (this is optional)
-# The default is to allocate a free context on the fly
-# In general you don't need to force a context
-#S_CONTEXT=
- EOF
- echo $CONF has been created. Look at it\!
- fi
- # Turn off some service useless on a vserver
- # vserver_turnoff apmd network autofs dhcpd gpm ipchains iptables \
- # irda isdn keytable kudzu linuxconf-setup netfs nfs nfslock \
- # pcmcia portmap pppoe random rawdevices rhnsd rstatd ruserd \
- # rwalld rwhod sendmail smb snmpd v_httpd h_xinetd v_sshd vservers \
- # xfs ypbind xinetd
- (
- cd etc/init.d 2>/dev/null || cd etc/rc.d/init.d
- for serv in *
- do
- case $serv in
- *.bak|*~|functions|killall|halt|single)
- ;;
- *)
- #$USR_LIB_VSERVER/capchroot $VROOTDIR/$1 /sbin/chkconfig --level 2345 $serv off
- $0 --silent $1 chkconfig --level 2345 $serv off
- ;;
- esac
- done
- )
- rm -f etc/rc.d/rc6.d/S*reboot
- fi
-elif [ ! -f /etc/vservers/$1.conf ] ; then
- echo No configuration for this vserver: /etc/vservers/$1.conf
- exit 1
-elif [ ! -d $VROOTDIR/$1/. ] ; then
- echo No directory for this vserver: $VROOTDIR/$1
- exit 1
-elif [ "$2" = "start" ] ; then
- echo Starting the virtual server $1
- testperm $1
- if ! $VSERVER_CMD $1 running
- then
- test -x /etc/vservers/$1.sh && /etc/vservers/$1.sh pre-start $1
- S_NICE=
- S_FLAGS=
- . /etc/vservers/$1.conf
- export PROFILE
- cd $VROOTDIR/$1 || exit 1
-
- if [ "$PROFILE" != "" ] ; then
- echo export PROFILE=$PROFILE >etc/PROFILE
- fi
-
- rm -f `find var/run -type f`
- touch var/run/utmp
- chgrp ${UTMP_GROUP:-utmp} var/run/utmp
- chmod 0664 var/run/utmp
- rm -f var/lock/subsys/*
- mountproc $VROOTDIR/$1
- CTXOPT=
- HOSTOPT=
- DOMAINOPT=
- NICECMD=
- FLAGS=
- CAPS=
- get_initdefault $1
- STARTCMD="/etc/rc.d/rc $INITDEFAULT"
- if [ -x $VROOTDIR/$1/etc/init.d/rc ] ; then
- STARTCMD="/etc/init.d/rc $INITDEFAULT"
- elif [ -x $VROOTDIR/$1/usr/bin/emerge ] ; then
- STARTCMD="/sbin/rc default"
- elif [ -x $VROOTDIR/$1/etc/rc.d/rc.M ] ; then
- STARTCMD="/etc/rc.d/rc.M"
- fi
-
- DISCONNECT=
- FAKEINIT=
- for f in $S_FLAGS dummy
- do
- case $f in
- dummy)
- ;;
-
- minit)
- FAKEINIT=true
- FLAGS="$FLAGS --flag fakeinit"
- STARTCMD=/sbin/minit-start
- DISCONNECT=--disconnect
- ;;
-
- fakeinit)
- FAKEINIT=true
- FLAGS="$FLAGS --flag $f"
- STARTCMD=/sbin/init
- DISCONNECT=--disconnect
- ;;
- *)
- FLAGS="$FLAGS --flag $f"
- ;;
- esac
- done
- if [ -n "$S_START" ] ; then
- STARTCMD=$S_START
- fi
- if [ "$FAKEINIT" = "" ] ; then
- $USR_LIB_VSERVER/fakerunlevel $INITDEFAULT var/run/utmp
- fi
-
- calculateCaps $S_CAPS
-
- if [ "$S_CONTEXT" != "" ] ; then
- CTXOPT="--ctx $S_CONTEXT"
- fi
- if [ "$S_HOSTNAME" != "" ] ; then
- HOSTOPT="--hostname $S_HOSTNAME"
- export HOSTNAME=$S_HOSTNAME
- fi
- if [ "$S_DOMAINNAME" != "" ] ; then
- DOMAINOPT="--domainname $S_DOMAINNAME"
- fi
- if [ "$S_NICE" != "" ] ; then
- NICECMD="nice -$S_NICE"
- fi
- mkdir -p /var/run/vservers
- chmod 700 /var/run/vservers
- setdefulimit
- if [ "$ULIMIT" != "" ] ; then
- ulimit $ULIMIT
- fi
- #echo FLAGS=$FLAGS
- #echo CAPS=$CAPS
- # We switch to $VROOTDIR/$1 now, because after the
- # security context switch $VROOTDIR directory becomes a dead zone.
- cd $VROOTDIR/$1
- export PATH=$DEFAULTPATH
- # XXX execute /etc/rc.vinit first for backward compatibility
- for CMD in "$VINIT_CMD $2" "$STARTCMD" ; do
- $WAITFOR_CMD $NICECMD \
- $CHCONTEXT_CMD $SILENT $DISCONNECT $CAPS $FLAGS $CTXOPT $HOSTOPT $DOMAINOPT --secure \
- $SAVE_S_CONTEXT_CMD /var/run/vservers/$1.ctx \
- $CAPCHROOT_CMD $CHROOTOPT . $CMD
- done
- sleep 2
- test -x /etc/vservers/$1.sh && /etc/vservers/$1.sh post-start $1
- fi
-elif [ "$2" = "running" ] ; then
- if [ ! -f /var/run/vservers/$1.ctx ] ; then
- echo Server $1 is not running
- exit 1
- else
- . /var/run/vservers/$1.ctx
- NB=$($USR_SBIN/vps ax | awk '{print $2}' | grep \^$S_CONTEXT\$ | wc -l)
- #NB=`$CHCONTEXT_CMD --silent --ctx $S_CONTEXT ps ax | wc -l`
- #NB=`eval expr $NB + 0`
- if [ "$NB" -gt 0 ] ; then
- echo Server $1 is running
- exit 0
- else
- echo Server $1 is not running
- exit 1
- fi
- fi
-elif [ "$2" = "status" ] ; then
- if $0 $1 running
- then
- . /var/run/vservers/$1.ctx
- NB=$($USR_SBIN/vps ax | awk '{print $2}' | grep \^$S_CONTEXT\$ | wc -l)
- echo $NB processes running
- echo Vserver uptime: `$USR_LIB_VSERVER/filetime /var/run/vservers/$1.ctx`
- fi
-elif [ "$2" = "stop" ] ; then
- echo Stopping the virtual server $1
- CAPS=
- IS_MINIT=
- readlastconf $1
- if $VSERVER_CMD $1 running
- then
- test -x /etc/vservers/$1.sh && /etc/vservers/$1.sh pre-stop $1
- cd $VROOTDIR/$1
- mountproc $VROOTDIR/$1
- # The fakeinit flag tell us how to turn off the server
- get_initdefault $1
- export PREVLEVEL=$INITDEFAULT
- STOPCMD="/etc/rc.d/rc 6"
- if [ -x $VROOTDIR/$1/etc/init.d/rc ] ; then
- STOPCMD="/etc/init.d/rc 6"
- elif [ -x $VROOTDIR/$1/usr/bin/emerge ] ; then
- STOPCMD="/sbin/rc shutdown"
- elif [ -x $VROOTDIR/$1/etc/rc.d/rc.6 ] ; then
- STOPCMD="/etc/rc.d/rc.6"
- fi
-
- for f in $S_FLAGS dummy
- do
- case $f in
- minit)
- IS_MINIT=1
- FLAGS="$FLAGS --flag fakeinit"
- STOPCMD="/sbin/minit-stop"
- ;;
-
- fakeinit)
- FLAGS="$FLAGS --flag $f"
- STOPCMD="/sbin/init 6"
- ;;
- *)
- ;;
- esac
- done
-
- if [ -n "$S_STOP" ] ; then
- STOPCMD=$S_STOP
- fi