Package: vserver-debiantools Version: 0.1.10 Severity: normal Tags: patch Hi,
this is more an inconsistency than a bug, but I file it here anyway.
Recently, the alpha branch of util-vserver was introduced to Debian
which has a different configuration scheme and other differences
compared to the stable branch. In addition, the "vserver" command now
has support for building Debian vservers using debootstrap.
The newvserver command in vserver-debiantools creates a new vserver of
old style (stable branch). These vservers can still be handled by
util-vserver in legacy mode, but IMHO it would be better if new
vservers were of the new alpha branch style. This would avoid several
legacy problems (security, documentation, ...).
I adjusted the newvserver script so that it creates a new vserver
using "vserver ... build" with the "debootstrap" method instead of
using "debootstrap" directly. Some parts of "newvserver" could be
removed because "vserver ... build" handles them already (care about
devices, check if vserver already exists, ...), other parts were only
relevant for old style vservers (vreboot, rebootmgr, ...).
The adjusted script reproduces the same package selection and the same
/dev tree in the new vserver.
I send a patch as well as the complete newvserver script.
regards
Daniel
-- System Information:
Debian Release: 3.1
APT prefers testing
APT policy: (500, 'testing'), (200, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.4.26-ath64.ws
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Versions of packages vserver-debiantools depends on:
ii binutils 2.15-5 The GNU assembler, linker and bina
ii debootstrap 0.2.45-0.2 Bootstrap a basic Debian system
ii rsync 2.6.3-2 fast remote file copy program (lik
ii util-vserver 0.30.204-4 tools for Virtual private servers
-- debconf-show failed
--- newvserver.orig 2005-04-17 17:46:11.000000000 +0200
+++ newvserver 2005-04-17 18:54:08.000000000 +0200
@@ -62,9 +62,6 @@
# Default network interface for vservers:
INTERFACE="eth0"
-# Copy vreboot/vhalt/vshutdown utility into /usr/local/sbin/
-COPY_VREBOOT="true"
-
if [ -r /etc/vservers/util-vserver-vars ] ; then
. /etc/vservers/util-vserver-vars
fi
@@ -96,15 +93,13 @@
{
cat << EOF
Usage: ${0##*/} [OPTIONS] --hostname x --domain y.z --ip 1.2.3.4
-Creates a new Debian vserver by downloading packages via HTTP/FTP
+Creates a new Debian vserver by calling "vserver ... build"
Options:
-h, --help this help
-V, --version copyright and version information
--arch set target architecture (eg. --arch "i386")
(autodetected on Debian host if dpkg available)
- --copy-vreboot install "vreboot/vshutdown/vhalt"
- --no-copy-vreboot don't install "vreboot/vshutdown/vhalt"
--dist defaults to "sarge", passed to debootstrap.
--fakeinit use "/sbin/init" to boot vserver
--conffile extra configuration file to load.
@@ -184,14 +179,6 @@
fi
shift 2
;;
- --copy-vreboot)
- COPY_VREBOOT="true"
- shift
- ;;
- --no-copy-vreboot)
- COPY_VREBOOT=""
- shift
- ;;
--dist)
case "$2" in
[a-z]*)
@@ -341,16 +328,6 @@
##############################################################################
-# Check we've got debootstrap available
-if [ ! -x /usr/sbin/debootstrap ]; then
- cat << EOF 1>&2
-${0##*/}: Requires the debootstrap package to bootstrap Debian
- Debian Host: apt-get install debootstrap
- RPM Host: rpm -i
http://people.debian.org/~blade/install/debootstrap/debootstrap-0.1.17.3-2.i386.rpm
-EOF
- exit 1
-fi
-
if ! cat /proc/self/status | grep '^s_context:[^0-9]0$'; then
echo "${0##*/} error:"
echo " Must be run from the host server (security context 0)" 1>&2
@@ -364,33 +341,19 @@
exit 1
fi
-# check for /vserver/$VHOST/etc/ incase we are on pre-mounted LVM partition
-# (used to just check for "/vserver/$VHOST/" existing
-if [ -d "$VROOTDIR/$VHOST/etc/" -o -f "/etc/vservers/$VHOST.conf" ] ; then
- cat << EOF 1>&2
-${0##*/} error: Virtual Server "$VHOST" appears to already exist
- check "/etc/vservers/$VHOST.conf" or "/vservers/$VHOST/etc/";
-EOF
- exit 1
-fi
-
-# This is used to keep a cache of the downloaded .deb packges for next install
-if [ -d "$VROOTDIR/ARCHIVES/$DIST" ]; then
- mkdir -p "$VROOTDIR/$VHOST/var/cache/apt/archives"
- cp -a "$VROOTDIR/ARCHIVES/$DIST/"*.deb
"$VROOTDIR/$VHOST/var/cache/apt/archives" > /dev/null 2>&1
-fi
-
# We only want to pass the Architecture if we need to (autodectected otherwise)
if [ -n "$ARCH" ]; then
ARCH_ARGUMENT="--arch $ARCH"
fi
-# Fire off `debootstrap' to do all the hard work
-# like downloading and installing
-if ! /usr/sbin/debootstrap $ARCH_ARGUMENT \
- "--include=$INSTALL_PACKAGES" "--exclude=$REMOVE_PACKAGES" \
- "$DIST" "$VROOTDIR/$VHOST" "$MIRROR" ; then
- echo "${0##*/}: error: debootstrap failure. Cannot continue."
+## use "vserver ... build" to build the new vserver
+if ! /usr/sbin/vserver "$VHOST" build -m debootstrap \
+ --rootdir "$VROOTDIR" --hostname "$VHOST" --interface "$INTERFACE:$IP" \
+ -- -d "$DIST" -m "$MIRROR" \
+ -- $ARCH_ARGUMENT \
+ --include="$INSTALL_PACKAGES" --exclude="$REMOVE_PACKAGES"
+ then
+ echo "${0##*/}: error: vserver-build failure. Cannot continue."
exit 1
fi
@@ -406,15 +369,8 @@
EOF
-# Fix up the available device nodes, for security
+# Fix up the available device nodes (mostly done by vserver-build above)
if cd "$VROOTDIR/$VHOST/dev"; then
- mkdir -p /var/lib/vserver-debiantools
- tar cfp /var/lib/vserver-debiantools/dev.tar.$$ full null ptmx random tty
urandom zero
- rm -rf *
- tar xfp /var/lib/vserver-debiantools/dev.tar.$$
- rm -f /var/lib/vserver-debiantools/dev.tar.$$
- mkdir pts
- mkdir shm
ln -s /proc/self/fd fd
ln -s fd/2 stderr
ln -s fd/0 stdin
@@ -467,14 +423,6 @@
proc /proc proc defaults 0 0
EOF
-# The new vserver patch now automatically mounts /proc
-# Debian needs /dev/pts mounting "gid=5,mode=620" by vserver
-cat << EOF > "$VROOTDIR/$VHOST/etc/mtab"
-/dev/hdv1 / vfs none 0 0
-proc /proc proc rw 0 0
-devpts /dev/pts devpts rw,gid=5,mode=620 0 0
-EOF
-
# Create a reduced inittab that doesn't start getty on the consoles
cat << EOF > "$VROOTDIR/$VHOST/etc/inittab"
# /etc/inittab: init(8) configuration.
@@ -549,22 +497,6 @@
EOF
-# Create default /etc/vservers entry
-cat << EOF > /etc/vservers/$VHOST.conf
-S_HOSTNAME="$VHOST"
-IPROOT="$IP"
-IPROOTDEV="$INTERFACE"
-ONBOOT="yes"
-S_NICE=""
-S_FLAGS="lock nproc$FAKEINIT"
-ULIMIT="-H -n 1024"
-S_CAPS="CAP_NET_RAW"
-
-# *NOT* DNS domain name, for NIS only
-S_DOMAINNAME=""
-
-EOF
-
if [ -n "$EXTRA_PACKAGES" ]; then
EXTRA_PACKAGES_INSTALL="apt-get --assume-yes install ${EXTRA_PACKAGES//,/
}"
fi
@@ -601,6 +533,9 @@
EOF
+## start vserver before we can exec anything inside it
+vserver $VHOST start
+
# Run the above commands from within the server
chmod 755 $VROOTDIR/$VHOST/vserver-config.sh
vserver $VHOST exec /vserver-config.sh
@@ -622,30 +557,12 @@
chmod 600 "$VROOTDIR/$VHOST/root/.ssh/authorized_keys"
fi
-# Install the vreboot/rebootmgr utility--hopefully this will disappear soon
-VREBOOT_LOCATION="/usr/lib/util-vserver/vreboot"
-if [ "$COPY_VREBOOT" == "true" -a -x "$VREBOOT_LOCATION" ]; then
- cp -a "$VREBOOT_LOCATION" "$VROOTDIR/$VHOST/usr/local/sbin/"
- chmod 750 "$VROOTDIR/$VHOST/usr/local/sbin/vreboot"
- # ln -s "$VROOTDIR/$VHOST/usr/local/sbin/"{vshutdown,vreboot}
- # ln -s "$VROOTDIR/$VHOST/usr/local/sbin/"{vhalt,vreboot}
-fi
-
-# Stop all the processes that were started inside the server
-export PREVLEVEL=2
-vserver $VHOST exec /etc/init.d/rc 0
+## stop the vserver
vserver $VHOST stop
-# Populate the archive for future virtual servers
-if [ ! -d $VROOTDIR/ARCHIVES/$DIST ]; then
- mkdir -p $VROOTDIR/ARCHIVES/$DIST
-fi
-cp $VROOTDIR/$VHOST/var/cache/apt/archives/*.deb $VROOTDIR/ARCHIVES/$DIST
-
-echo "Restarting rebootmgr."
-invoke-rc.d rebootmgr restart
echo
-echo "You should now adjust /etc/vservers/$VHOST.conf to suit your needs,"
+echo "You should now adjust the configuration in /etc/vservers/$VHOST/"
+echo "to suit your needs,"
echo "or else just go ahead and type \`vserver $VHOST start' to start"
echo "your new virtual server. debian/rules!"
echo
newvserver
Description: application/shellscript

