From: Enrico Scholz Date: Tue, 4 Nov 2003 01:07:07 +0000 (+0000) Subject: merged in changes from 0.23.96 (/vservers -> $DEFAULT_VSERVERDIR) X-Git-Tag: VERSION_0_10~1091 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8be566b1a2c10b883a2ec9a003cdf568e476f070;p=util-vserver.git merged in changes from 0.23.96 (/vservers -> $DEFAULT_VSERVERDIR) git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@367 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/scripts/distrib-info b/util-vserver/scripts/distrib-info index a493ab3..cccced8 100755 --- a/util-vserver/scripts/distrib-info +++ b/util-vserver/scripts/distrib-info @@ -47,7 +47,7 @@ elif [ -d "$1" ] ; then DISTDIR=$1 CHROOTCMD="$SBINDIR/chroot $DISTDIR" else - DISTDIR=/vservers/$1 + DISTDIR=$DEFAULT_VSERVERDIR/$1 CHROOTCMD="$SBINDIR/chroot $DISTDIR" fi KEY=$2 diff --git a/util-vserver/scripts/vserver-copy b/util-vserver/scripts/vserver-copy index 321cfda..c98cd48 100755 --- a/util-vserver/scripts/vserver-copy +++ b/util-vserver/scripts/vserver-copy @@ -99,7 +99,7 @@ flag a vserver can even be operationally moved to different hardware within seconds. The -i and -d flags can be used to minimally reconfigure the destination -vserver (rewrites /etc/vservers/newname.conf and /vservers/newname/etc/hosts) +vserver (rewrites /etc/vservers/newname.conf and $DEFAULT_VSERVERDIR/newname/etc/hosts) Options: -h, --help this help @@ -143,7 +143,7 @@ rsh=(false) colon=":" domain="" ip="" -vsroot="/vservers" +vsroot=$DEFAULT_VSERVERDIR if [ $# -eq 0 ]; then # Script invoked with no command-line args? usage diff --git a/util-vserver/scripts/vserver-legacy b/util-vserver/scripts/vserver-legacy index 5342cd9..d0435bf 100755 --- a/util-vserver/scripts/vserver-legacy +++ b/util-vserver/scripts/vserver-legacy @@ -55,14 +55,14 @@ umountproc() testperm() { return - PERM=`$USR_LIB_VSERVER/showperm /vservers/$1/..` + PERM=`$USR_LIB_VSERVER/showperm $DEFAULT_VSERVERDIR/$1/..` if [ "$PERM" != 000 ] ; then echo echo "**********************************************************" - echo /vservers/$1/.. has insecure permissions. + echo $DEFAULT_VSERVERDIR/$1/.. has insecure permissions. echo A vserver administrator may be able to visit the root server. echo To fix this, do - echo " " chmod 000 /vservers/$1/.. + echo " " chmod 000 $DEFAULT_VSERVERDIR/$1/.. echo do it anytime you want, even if vservers are running. echo "**********************************************************" echo @@ -180,7 +180,7 @@ setipopt(){ # Extract the initial runlevel from the vserver inittab get_initdefault() { - INITDEFAULT=`grep :initdefault /vservers/$1/etc/inittab | sed 's/:/ /g' | ( read a level b; echo $level)` + INITDEFAULT=`grep :initdefault $DEFAULT_VSERVERDIR/$1/etc/inittab | sed 's/:/ /g' | ( read a level b; echo $level)` } # Read the vserver configuration file, reusing the PROFILE value @@ -200,7 +200,7 @@ usage() { echo vserver [ options ] server-name command ... echo - echo server-name is a directory in /vservers + echo server-name is a directory in $DEFAULT_VSERVERDIR echo echo The commands are: echo " build : Create a virtual server by copying the packages" @@ -270,24 +270,24 @@ if [ $# -lt 2 ] ; then usage elif [ "$2" = "build" ] ; then # Either the directory does not exist or is empty - NBSUB=`ls /vservers/$1 2>/dev/null | grep -v lost+found | wc -l` + NBSUB=`ls $DEFAULT_VSERVERDIR/$1 2>/dev/null | grep -v lost+found | wc -l` NBSUB=`expr $NBSUB` if [ "$NBSUB" != 0 ] ; then - echo Virtual server /vservers/$1 already exist + echo Virtual server $DEFAULT_VSERVERDIR/$1 already exist else - if [ ! -d /vservers ] ; then - mkdir /vservers || exit 1 - chmod 000 /vservers - echo Directory /vservers was created with permissions 000 + if [ ! -d $DEFAULT_VSERVERDIR ] ; then + mkdir $DEFAULT_VSERVERDIR || exit 1 + chmod 000 $DEFAULT_VSERVERDIR + echo Directory $DEFAULT_VSERVERDIR was created with permissions 000 fi - mkdir -p /vservers/$1 || exit 1 - chmod 755 /vservers/$1 + mkdir -p $DEFAULT_VSERVERDIR/$1 || exit 1 + chmod 755 $DEFAULT_VSERVERDIR/$1 if test "$UTIL_VSERVER_AVOID_COPY"; then - mkdir -p /vservers/$1/{etc/rc.d/init.d,sbin,var/run,var/log} + mkdir -p $DEFAULT_VSERVERDIR/$1/{etc/rc.d/init.d,sbin,var/run,var/log} else - cp -ax /sbin /bin /etc /usr /var /lib /vservers/$1/. || exit 1 + cp -ax /sbin /bin /etc /usr /var /lib $DEFAULT_VSERVERDIR/$1/. || exit 1 fi - cd /vservers/$1 || exit 1 + cd $DEFAULT_VSERVERDIR/$1 || exit 1 rm -fr lib/modules/* rm -f var/spool/mail/* rm -f `find var/run -type f` @@ -325,7 +325,7 @@ elif [ "$2" = "build" ] ; then *.bak|*~|functions|killall|halt|single) ;; *) - #$USR_LIB_VSERVER/capchroot /vservers/$1 /sbin/chkconfig --level 2345 $serv off + #$USR_LIB_VSERVER/capchroot $DEFAULT_VSERVERDIR/$1 /sbin/chkconfig --level 2345 $serv off $0 --silent $1 chkconfig --level 2345 $serv off ;; esac @@ -341,7 +341,7 @@ elif [ "$2" = "build" ] ; then cp -a $USR_LIB_VSERVER/vreboot sbin/. ln -sf vreboot sbin/vhalt - echo Directory /vservers/$1 has been populated + echo Directory $DEFAULT_VSERVERDIR/$1 has been populated if [ ! -d /etc/vservers ] ; then mkdir /etc/vservers chmod 600 /etc/vservers @@ -426,8 +426,8 @@ S_CAPS="" elif [ ! -f /etc/vservers/$1.conf ] ; then echo No configuration for this vserver: /etc/vservers/$1.conf exit 1 -elif [ ! -d /vservers/$1/. ] ; then - echo No directory for this vserver: /vservers/$1 +elif [ ! -d $DEFAULT_VSERVERDIR/$1/. ] ; then + echo No directory for this vserver: $DEFAULT_VSERVERDIR/$1 exit 1 elif [ "$2" = "start" ] ; then echo Starting the virtual server $1 @@ -444,7 +444,7 @@ elif [ "$2" = "start" ] ; then . /etc/vservers/$1.conf export PROFILE ifconfig_iproot $1 - cd /vservers/$1 || exit 1 + cd $DEFAULT_VSERVERDIR/$1 || exit 1 if [ "$PROFILE" != "" ] ; then echo export PROFILE=$PROFILE >etc/PROFILE @@ -453,7 +453,7 @@ elif [ "$2" = "start" ] ; then rm -f `find var/run -type f` touch var/run/utmp rm -f var/lock/subsys/* - mountproc /vservers/$1 + mountproc $DEFAULT_VSERVERDIR/$1 CTXOPT= HOSTOPT= DOMAINOPT= @@ -462,7 +462,7 @@ elif [ "$2" = "start" ] ; then CAPS= get_initdefault $1 STARTCMD="/etc/rc.d/rc $INITDEFAULT" - if [ -x /vservers/$1/etc/init.d/rc ] ; then + if [ -x $DEFAULT_VSERVERDIR/$1/etc/init.d/rc ] ; then STARTCMD="/etc/init.d/rc $INITDEFAULT" fi @@ -521,7 +521,7 @@ elif [ "$2" = "start" ] ; then #echo CAPS=$CAPS # We switch to /vservers/$1 now, because after the # security context switch /vservers directory becomes a dead zone. - cd /vservers/$1 + cd $DEFAULT_VSERVERDIR/$1 IPOPT=`setipopt $IPROOT` export PATH=$DEFAULTPATH $NICECMD $_CHBIND $SILENT $IPOPT --bcast $IPROOTBCAST \ @@ -569,13 +569,13 @@ elif [ "$2" = "stop" ] ; then then test -x /etc/vservers/$1.sh && /etc/vservers/$1.sh pre-stop $1 ifconfig_iproot $1 - cd /vservers/$1 - mountproc /vservers/$1 + cd $DEFAULT_VSERVERDIR/$1 + mountproc $DEFAULT_VSERVERDIR/$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 /vservers/$1/etc/init.d/rc ] ; then + if [ -x $DEFAULT_VSERVERDIR/$1/etc/init.d/rc ] ; then STOPCMD="/etc/init.d/rc 6" fi for f in $S_FLAGS dummy @@ -598,7 +598,7 @@ elif [ "$2" = "stop" ] ; then calculateCaps $S_CAPS - cd /vservers/$1 + cd $DEFAULT_VSERVERDIR/$1 IPOPT=`setipopt $IPROOT` export PATH=$DEFAULTPATH $_CHBIND $SILENT $IPOPT --bcast $IPROOTBCAST \ @@ -621,7 +621,7 @@ elif [ "$2" = "stop" ] ; then fi # We umount anyway, because "enter" establish the mount # but when you exit, the server is considered not running - umountproc /vservers/$1 + umountproc $DEFAULT_VSERVERDIR/$1 cd / test -x /etc/vservers/$1.sh && /etc/vservers/$1.sh post-stop $1 ifconfig_iproot_off $1 @@ -647,9 +647,9 @@ elif [ "$2" = "suexec" ] ; then IPROOTDEV= readlastconf $1 . /etc/vservers/$1.conf - cd /vservers/$1 + cd $DEFAULT_VSERVERDIR/$1 ifconfig_iproot $1 - mountproc /vservers/$1 + mountproc $DEFAULT_VSERVERDIR/$1 PS1="[\u@vserver:$1 \W]" export PS1 VSERVER=$1 @@ -691,7 +691,7 @@ elif [ "$2" = "suexec" ] ; then if $0 $VSERVER running >/dev/null then . /var/run/vservers/$VSERVER.ctx - cd /vservers/$VSERVER + cd $DEFAULT_VSERVERDIR/$VSERVER IPOPT=`setipopt $IPROOT` export PATH=$DEFAULTPATH $_CHBIND $SILENT $IPOPT --bcast $IPROOTBCAST \ @@ -713,7 +713,7 @@ elif [ "$2" = "suexec" ] ; then DOMAINOPT="--domainname $S_DOMAINNAME" fi mkdir -p /var/run/vservers - cd /vservers/$VSERVER + cd $DEFAULT_VSERVERDIR/$VSERVER IPOPT=`setipopt $IPROOT` export PATH=$DEFAULTPATH $_CHBIND $SILENT $IPOPT --bcast $IPROOTBCAST \ @@ -743,11 +743,11 @@ elif [ "$2" = "chkconfig" ] ; then LEVELS=$1 shift fi - if [ $# != 2 -a ! -x /vservers/$VSERVER/sbin/chkconfig ] ; then + if [ $# != 2 -a ! -x $DEFAULT_VSERVERDIR/$VSERVER/sbin/chkconfig ] ; then echo Invalid argument, expected vserver name chkconfig [ --level nnn ] service on\|off - elif [ -x /vservers/$VSERVER/sbin/chkconfig ] ; then + elif [ -x $DEFAULT_VSERVERDIR/$VSERVER/sbin/chkconfig ] ; then exec $0 --silent $VSERVER exec /sbin/chkconfig "$@" - elif [ -x /vservers/$VSERVER/usr/sbin/update-rc.d ] ; then + elif [ -x $DEFAULT_VSERVERDIR/$VSERVER/usr/sbin/update-rc.d ] ; then if [ "$2" = "on" -o "$2" = "start" ] ; then $0 --silent $VSERVER exec /usr/sbin/update-rc.d -f $1 remove >/dev/null exec $0 --silent $VSERVER exec /usr/sbin/update-rc.d $1 start 80 2 3 4 5 . stop 20 0 1 6 . >/dev/null diff --git a/util-vserver/scripts/vservers.grabinfo.sh b/util-vserver/scripts/vservers.grabinfo.sh index 21de103..8eab64b 100644 --- a/util-vserver/scripts/vservers.grabinfo.sh +++ b/util-vserver/scripts/vservers.grabinfo.sh @@ -25,7 +25,7 @@ test -e "$UTIL_VSERVER_VARS" || { } . "$UTIL_VSERVER_VARS" -cd /vservers +cd $DEFAULT_VSERVERDIR for vserv in * do if [ -f /etc/vservers/$vserv.conf ] ; then diff --git a/util-vserver/src/rebootmgr.c b/util-vserver/src/rebootmgr.c index 9e43906..fe552b9 100644 --- a/util-vserver/src/rebootmgr.c +++ b/util-vserver/src/rebootmgr.c @@ -66,7 +66,7 @@ static int rebootmgr_opensocket (const char *vname) int ret = -1; char sockn[PATH_MAX]; int fd = socket (AF_UNIX,SOCK_STREAM,0); - sprintf (sockn,"/vservers/%s/dev/reboot",vname); + sprintf (sockn, DEFAULT_VSERVERVDIR "/%s/dev/reboot",vname); unlink (sockn); if (fd == -1){ fprintf (stderr,"Can't create a unix domain socket (%s)\n" diff --git a/util-vserver/sysv/Makefile-files b/util-vserver/sysv/Makefile-files index 5f0601d..c565036 100644 --- a/util-vserver/sysv/Makefile-files +++ b/util-vserver/sysv/Makefile-files @@ -47,7 +47,8 @@ sysv_CFG = sysv/vservers.conf sysv_SUBSTRULE = s!/usr/lib/util-vserver!$(pkglibdir)!g; \ - s!^USR_SBIN=/usr/sbin$$!USR_SBIN=$(sbindir)!g + s!^USR_SBIN=/usr/sbin$$!USR_SBIN=$(sbindir)!g; \ + s!^DEFAULT_VSERVERDIR=/vservers$$!DEFAULT_VSERVERDIR=$(vserverdir)!g sysv/%: sysv/%.subst @mkdir -p $$(dirname '$@') diff --git a/util-vserver/sysv/rebootmgr.subst b/util-vserver/sysv/rebootmgr.subst index a526dd8..84b00e2 100755 --- a/util-vserver/sysv/rebootmgr.subst +++ b/util-vserver/sysv/rebootmgr.subst @@ -6,7 +6,7 @@ # processname: rebootmgr # config: /etc/vservers - +DEFAULT_VSERVERDIR=/vservers USR_SBIN=/usr/sbin PIDFILE=/var/run/rebootmgr.pid # See how we were called. @@ -18,7 +18,7 @@ case "$1" in for serv in *.conf do serv=`basename $serv .conf` - if [ -d /vservers/$serv ] ; then + if [ -d $DEFAULT_VSERVERDIR/$serv ] ; then VSERVERS="$VSERVERS $serv" fi done