From: Sam Vilain (sam_at_vilain.net)
Date: Wed 28 Jul 2004 - 23:53:02 BST
The patch seems to have been eaten. Here it is, inline this time:
--- vserver.orig 2004-07-29 10:35:37.000000000 +1200
+++ vserver 2004-07-29 10:25:49.000000000 +1200
@@ -19,7 +19,8 @@
# This is a script to control a virtual server
-: ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars}
+#: ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars}
+: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
test -e "$UTIL_VSERVER_VARS" || {
echo "Can not find util-vserver installation; aborting..."
exit 1
@@ -37,6 +38,9 @@
VSERVERKILLALL_CMD=$USR_LIB_VSERVER/vserverkillall
DEFAULTPATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin
+STATIC_DIRS="usr lib sbin bin"
+UNIQUE_DIRS="etc var"
+
vserver_mknod(){
mknod $1 $2 $3 $4
chmod $5 $1
@@ -44,16 +48,31 @@
mountproc()
{
- mkdir -p $1/proc $1/dev/pts
- if [ ! -d $1/proc/1 ] ; then
- mount -t proc none $1/proc
- mount -t devpts -o gid=5,mode=0620 none $1/dev/pts
+ mkdir -p $VROOTDIR/$1/proc $VROOTDIR/$1/dev/pts
+ if [ ! -d $VROOTDIR/$1/proc/1 ] ; then
+ mount -n -t proc none $VROOTDIR/$1/proc
+ mount -n -t devpts -o gid=5,mode=0620 none
$VROOTDIR/$1/dev/pts
+ fi
+ if [ -d $VROOTDIR/shadow/$1/usr -a ! -d $VROOTDIR/$1/usr/bin ]
+ then
+ for dir in $STATIC_DIRS
+ do
+ [ -d $VROOTDIR/$1/$dir ] || mkdir $VROOTDIR/$1/$dir
+ mount -n --bind $VROOTDIR/shadow/$1/$dir
$VROOTDIR/$1/$dir
+ done
fi
}
umountproc()
{
- umount $1/proc 2>/dev/null
- umount $1/dev/pts 2>/dev/null
+ umount $VROOTDIR/$1/proc 2>/dev/null
+ umount $VROOTDIR/$1/dev/pts 2>/dev/null
+ if [ -d $VROOTDIR/shadow/$1/usr ]
+ then
+ for dir in $STATIC_DIRS
+ do
+ umount $VROOTDIR/$1/$dir 2>/dev/null
+ done
+ fi
}
# Check that the vservers parent directory has permission 000
@@ -275,9 +294,11 @@
if [ $# -lt 2 ] ; then
usage
elif [ "$2" = "build" ] ; then
+
# Either the directory does not exist or is empty
NBSUB=`ls $VROOTDIR/$1 2>/dev/null | grep -v lost+found | wc -l`
NBSUB=`expr $NBSUB`
+
if [ "$NBSUB" != 0 ] ; then
echo Virtual server $VROOTDIR/$1 already exist
else
@@ -293,7 +314,24 @@
if test "$UTIL_VSERVER_AVOID_COPY"; then
mkdir -p $VROOTDIR/$1/{etc/rc.d/init.d,sbin,var/run,var/log}
else
- cp -ax /sbin /bin /etc /usr /var /lib $VROOTDIR/$1/. || exit 1
+ MASTER=/
+ [ -d $VROOTDIR/master ] && MASTER=$VROOTDIR/master
+ echo "Copying files from $MASTER"
+ if [ -d $VROOTDIR/shadow/master ]
+ then
+ ( cd $VROOTDIR/master;
+ cp -ax $UNIQUE_DIRS $VROOTDIR/$1/. ) || exit 1
+ echo "Linking files from $VROOTDIR/shadow/master"
+ mkdir $VROOTDIR/shadow/$1
+ ( cd $VROOTDIR/shadow/master;
+ cp -a $STATIC_DIRS $VROOTDIR/shadow/$1/. &&
+ cd $VROOTDIR/shadow &&
+ $USR_LIB_VSERVER/unify-dirs -il master
$1 ) || exit 1
+ mountproc $1
+ TMP_MOUNT=1
+ else
+ cp -ax /sbin /bin /usr /etc /var /lib
$VROOTDIR/$1/. || exit 1
+ fi
fi
cd $VROOTDIR/$1 || exit 1
rm -fr lib/modules/*
@@ -430,6 +456,7 @@
done
)
rm -f etc/rc.d/rc6.d/S*reboot
+ [ -n "$TMP_MOUNT" ] && umountproc $1
fi
elif [ ! -f /etc/vservers/$1.conf ] ; then
echo No configuration for this vserver: /etc/vservers/$1.conf
@@ -463,7 +490,7 @@
chgrp ${UTMP_GROUP:-utmp} var/run/utmp
chmod 0664 var/run/utmp
rm -f var/lock/subsys/*
- mountproc $VROOTDIR/$1
+ mountproc $1
CTXOPT=
HOSTOPT=
DOMAINOPT=
@@ -587,7 +614,7 @@
test -x /etc/vservers/$1.sh && /etc/vservers/$1.sh pre-stop $1
ifconfig_iproot $1
cd $VROOTDIR/$1
- mountproc $VROOTDIR/$1
+ mountproc $1
# The fakeinit flag tell us how to turn off the server
get_initdefault $1
export PREVLEVEL=$INITDEFAULT
@@ -647,7 +674,7 @@
fi
# We umount anyway, because "enter" establish the mount
# but when you exit, the server is considered not running
- umountproc $VROOTDIR/$1
+ umountproc $1
cd /
test -x /etc/vservers/$1.sh && /etc/vservers/$1.sh post-stop $1
ifconfig_iproot_off $1
@@ -675,7 +702,7 @@
. /etc/vservers/$1.conf
cd $VROOTDIR/$1
ifconfig_iproot $1
- mountproc $VROOTDIR/$1
+ mountproc $1
PS1="[\u_at_vserver:$1 \W]"
export PS1
VSERVER=$1
Sam Vilain wrote:
> By request, attached is the patch to the `vserver' script that comes
> with util-vserver 0.30, to allow vservers to have independant
> filesystems but still gain the major advantages of unification, as
> described in this previous thread:
>
> http://www.paul.sladen.org/vserver/archives/200404/0073.html
>
> Sam.
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Vserver mailing list
>Vserver_at_list.linux-vserver.org
>http://list.linux-vserver.org/mailman/listinfo/vserver
>
>
_______________________________________________
Vserver mailing list
Vserver_at_list.linux-vserver.org
http://list.linux-vserver.org/mailman/listinfo/vserver