--- vserver-0.21.orig/man/vdu.8 +++ vserver-0.21/man/vdu.8 @@ -0,0 +1,33 @@ +.TH "vps" "8" "0.1.0" "Klavs Klavsen " "System Administration" +.SH "NAME" +.LP +vdu \- The vdu utility is a wrapper for the kill program. +.SH "SYNTAX" +.LP +vdu [\fIoptions\fP] + +.SH "DESCRIPTION" +.LP +vdu \- The vdu utility is a wrapper for the du program, that enables kill to make disk usage listing on a virtual server. +.SH "OPTIONS" +.LP +.TP +See man kill. +.SH "FILES" +.LP +\fI/usr/sbin/vdu\fP + + +.SH "EXAMPLES" +.LP +vdu /vservers/test +.LP +Please contribute some, if you feel it's important. +.SH "AUTHORS" +.LP +This Man page was written by Ola Lundqvist using the vps manpage written by Klavs Klavsen . +.SH "SEE ALSO" +.LP +du(8) chcontext(8) rebootmgr(8) reducecap(8) +chbind(8) vpstree(8) vrpm(8) vserver(8) +vserver\-stat(8) vtop(8) vps(8) --- vserver-0.21.orig/man/vkill.8 +++ vserver-0.21/man/vkill.8 @@ -0,0 +1,31 @@ +.TH "vps" "8" "0.1.0" "Klavs Klavsen " "System Administration" +.SH "NAME" +.LP +vkill \- The vkill utility is simply a wrapper for the kill program. +.SH "SYNTAX" +.LP +vkill [\fIoptions\fP] + +.SH "DESCRIPTION" +.LP +vkill \- The vkill utility is simply a wrapper for the kill program, that enables kill to kill processes on the entire system, instead of only the ones in the current s_context (see cat /proc/self/status). +.SH "OPTIONS" +.LP +.TP +See man kill. +.SH "FILES" +.LP +\fI/usr/sbin/vkill\fP + + +.SH "EXAMPLES" +.LP +Please contribute some, if you feel it's important. +.SH "AUTHORS" +.LP +This Man page was written by Ola Lundqvist using the vps manpage written by Klavs Klavsen . +.SH "SEE ALSO" +.LP +kill(8) chcontext(8) rebootmgr(8) reducecap(8) +chbind(8) vpstree(8) vrpm(8) vserver(8) +vserver\-stat(8) vtop(8) vps(8) --- vserver-0.21.orig/Makefile +++ vserver-0.21/Makefile @@ -88,6 +88,7 @@ mkdir -p $(RPM_BUILD_ROOT)$(USR_SBIN) mkdir -p $(RPM_BUILD_ROOT)$(USR_LIB_VSERVER) mkdir -p $(RPM_BUILD_ROOT)/etc/init.d + install -m 644 vserver.conf $(RPM_BUILD_ROOT)/etc mkdir -p $(RPM_BUILD_ROOT)/$(MANDIR)/man8 install -m 755 chbind $(RPM_BUILD_ROOT)$(USR_SBIN) install -m 755 chcontext $(RPM_BUILD_ROOT)$(USR_SBIN) --- vserver-0.21.orig/distrib/install-post.sh +++ vserver-0.21/distrib/install-post.sh @@ -1,6 +1,12 @@ #!/bin/sh # Complete the installation of a vserver +VSERVER_ROOT=/vservers USR_LIB_VSERVER=/usr/lib/vserver + +if [ -e /etc/vserver.conf ] ; then + . /etc/vserver.conf +fi + vserver_mknod() { mknod $1 $2 $3 $4 @@ -10,10 +16,10 @@ if [ $# != 1 ] ; then echo install-post.sh vserver else - VROOT=/vservers/$1 + VROOT=$VSERVER_ROOT/$1 rm -fr $VROOT/dev - mkdir $VROOT/dev && chmod 755 $VROOT/dev - mkdir $VROOT/dev/pts + mkdir -p $VROOT/dev/pts + chmod 755 $VROOT/dev vserver_mknod $VROOT/dev/null c 1 3 666 vserver_mknod $VROOT/dev/zero c 1 5 666 vserver_mknod $VROOT/dev/full c 1 7 666 @@ -21,23 +27,23 @@ vserver_mknod $VROOT/dev/urandom c 1 9 644 vserver_mknod $VROOT/dev/tty c 5 0 666 vserver_mknod $VROOT/dev/ptmx c 5 2 666 - test -f /etc/vservers/$1.conf || cp $USR_LIB_VSERVER/sample.conf /etc/vservers/$1.conf + test -f /etc/vservers/$1.conf || cp /usr/share/doc/vserver/examples/sample.conf /etc/vservers/$1.conf test -f /etc/vservers/$1.sh || cp $USR_LIB_VSERVER/sample.sh /etc/vservers/$1.sh - echo NETWORKING=yes >$VROOT/etc/sysconfig/network - echo HOSTNAME=$1 >>$VROOT/etc/sysconfig/network + #echo NETWORKING=yes >$VROOT/etc/sysconfig/network + #echo HOSTNAME=$1 >>$VROOT/etc/sysconfig/network ( - cd $VROOT/etc/rc.d/init.d || cd $VROOT/etc/init.d + cd $VROOT/etc/init.d for serv in * do case $serv in *.bak|*~|functions|killall|halt|single) ;; *) - $USR_LIB_VSERVER/capchroot /vservers/$1 /sbin/chkconfig --level 2345 $serv off + #$USR_LIB_VSERVER/capchroot $VSERVER_ROOT/$1 /sbin/chkconfig --level 2345 $serv off ;; esac done - rm -f $VROOT/etc/rc.d/rc6.d/S*reboot + rm -f $VROOT/etc/rc6.d/S*reboot ) if [ ! -f $VROOT/etc/fstab ] ; then echo /dev/hdv1 / ext2 defaults 1 1 >$VROOT/etc/fstab @@ -46,4 +52,3 @@ cp -a $USR_LIB_VSERVER/vreboot $VROOT/sbin/. ln -sf vreboot $VROOT/sbin/vhalt fi - --- vserver-0.21.orig/vservers.sysv +++ vserver-0.21/vservers.sysv @@ -7,29 +7,29 @@ # See how we were called. case "$1" in - start) + start) echo "Starting the virtual servers" + touch /var/lock/subsys/vservers cd /etc/vservers - for serv in *.conf - do - ONBOOT= - . $serv - name=`basename $serv .conf` - if [ "$ONBOOT" = "yes" ] ; then - $USR_SBIN/vserver $name start - else - echo virtual server $name not configured for on boot start - fi + for serv in $(find . -name "*.conf") ; do + ONBOOT=no + [ -r "$serv" ] || continue + . ./$serv + name=`basename $serv .conf` + if [ "$ONBOOT" = "yes" ] ; then + $USR_SBIN/vserver $name start + else + echo virtual server $name not configured for on boot start + fi done - touch /var/lock/subsys/vservers ;; stop) echo "Stopping the virtual servers" cd /etc/vservers - for serv in *.conf - do - name=`basename $serv .conf` - $USR_SBIN/vserver $name stop + for serv in $(find . -name "*.conf") ; do + [ -r "$serv" ] || continue + name=`basename $serv .conf` + $USR_SBIN/vserver $name stop done rm -f /var/lock/subsys/vservers ;; @@ -37,18 +37,21 @@ $0 stop $0 start ;; + force-reload) + $0 restart + ;; reload) echo Not implemented ;; status) cd /etc/vservers - for serv in *.conf - do - ONBOOT=no - name=`basename $serv .conf` - . $serv - echo -n ONBOOT=$ONBOOT " " - $USR_SBIN/vserver $name running + for serv in $(find . -name "*.conf") ; do + ONBOOT=no + name=`basename $serv .conf` + [ -r "$serv" ] || continue + . ./$serv + echo -n ONBOOT=$ONBOOT " " + $USR_SBIN/vserver $name running done ;; *) @@ -57,7 +60,3 @@ esac exit 0 - - - - --- vserver-0.21.orig/rebootmgr.sysv +++ vserver-0.21/rebootmgr.sysv @@ -9,6 +9,11 @@ USR_SBIN=/usr/sbin PIDFILE=/var/run/rebootmgr.pid + +if [ -r /etc/vserver.conf ] ; then + . /etc/vserver.conf +fi + # See how we were called. case "$1" in start) @@ -38,6 +43,9 @@ reload) echo Not implemented ;; + force-reload) + $0 restart + ;; status) if [ -f $PIDFILE ] ; then if kill -0 `cat $PIDFILE` @@ -54,8 +62,3 @@ esac exit 0 - - - - - --- vserver-0.21.orig/debian/t/init.d.ex +++ vserver-0.21/debian/t/init.d.ex @@ -0,0 +1,70 @@ +#! /bin/sh +# +# skeleton example file to build /etc/init.d/ scripts. +# This file should be used to construct scripts for /etc/init.d. +# +# Written by Miquel van Smoorenburg . +# Modified for Debian GNU/Linux +# by Ian Murdock . +# +# Version: @(#)skeleton 1.8 03-Mar-1998 miquels@cistron.nl +# +# This file was automatically customized by dh-make on Tue, 3 Sep 2002 19:13:50 +0200 + +PATH=/sbin:/bin:/usr/sbin:/usr/bin +DAEMON=/usr/sbin/vserver +NAME=vserver +DESC=vserver + +test -f $DAEMON || exit 0 + +set -e + +case "$1" in + start) + echo -n "Starting $DESC: $NAME" + start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \ + --exec $DAEMON + echo "." + ;; + stop) + echo -n "Stopping $DESC: $NAME" + start-stop-daemon --oknodo --stop --quiet --pidfile /var/run/$NAME.pid \ + --exec $DAEMON + echo "." + ;; + #reload) + # + # If the daemon can reload its config files on the fly + # for example by sending it SIGHUP, do it here. + # + # If the daemon responds to changes in its config file + # directly anyway, make this a do-nothing entry. + # + # echo "Reloading $DESC configuration files." + # start-stop-daemon --stop --signal 1 --quiet --pidfile \ + # /var/run/$NAME.pid --exec $DAEMON + #;; + restart|force-reload) + # + # If the "reload" option is implemented, move the "force-reload" + # option to the "reload" entry above. If not, "force-reload" is + # just the same as "restart". + # + echo -n "Restarting $DESC: $NAME" + start-stop-daemon --stop --quiet --pidfile \ + /var/run/$NAME.pid --exec $DAEMON + sleep 1 + start-stop-daemon --start --quiet --pidfile \ + /var/run/$NAME.pid --exec $DAEMON + echo "." + ;; + *) + N=/etc/init.d/$NAME + # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 + echo "Usage: $N {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 --- vserver-0.21.orig/debian/t/watch.ex +++ vserver-0.21/debian/t/watch.ex @@ -0,0 +1,6 @@ +# Example watch control file for uscan +# Rename this file to "watch" and then you can run the "uscan" command +# to check for upstream updates and more. +# Site Directory Pattern Version Script +version=2 +sunsite.unc.edu /pub/Linux/Incoming vserver-(.*)\.tar\.gz debian uupdate --- vserver-0.21.orig/debian/t/postinst.ex +++ vserver-0.21/debian/t/postinst.ex @@ -0,0 +1,48 @@ +#! /bin/sh +# postinst script for vserver +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package +# +# quoting from the policy: +# Any necessary prompting should almost always be confined to the +# post-installation script, and should be protected with a conditional +# so that unnecessary prompting doesn't happen if a package's +# installation fails and the `postinst' is called with `abort-upgrade', +# `abort-remove' or `abort-deconfigure'. + +case "$1" in + configure) + + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + --- vserver-0.21.orig/debian/control +++ vserver-0.21/debian/control @@ -0,0 +1,21 @@ +Source: vserver +Section: base +Priority: optional +Maintainer: Ola Lundqvist +Build-Depends: debhelper (>> 3.0.0) +Standards-Version: 3.5.7 + +Package: vserver +Architecture: any +Depends: ${shlibs:Depends} +Suggests: kernel-patch-ctx +Description: Virtual private servers and context switching + This provides the components and a framework to setup virtual servers. + A virtual server runs inside a linux server. It is nevertheless highly + independent. As such, you can run various services with normal + configuration. The various vservers can't interact with each other + and can't interact with services in the main server. + . + This requires a special kernel supporting the new new_s_context and + set_ipv4root system call, provided by kernels compiled with the + kernel-patch-ctx patch. --- vserver-0.21.orig/debian/create-example.sh +++ vserver-0.21/debian/create-example.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# You will need pbuilder configured to make this work. +mkdir -p sid +cd sid +# etc from pbuilder. +mkdir t +cd t +tar xfz /var/cache/pbuilder/base.tgz +mv etc .. +cd .. +rm -Rf t +# Rest +for A in bin sbin lib usr ; do + mkdir -p $A + umount $(pwd)/$A || true + mount --bind -o ro /$A $A +done +mkdir -p var/run proc mnt root dev +/usr/lib/vserver/install-post.sh sid --- vserver-0.21.orig/debian/rules +++ vserver-0.21/debian/rules @@ -0,0 +1,148 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. +# GNU copyright 1997 by Joey Hess. +# +# This version is for a hypothetical package that builds an +# architecture-dependant package, as well as an architecture-independent +# package. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# This is the debhelper compatibility version to use. +export DH_COMPAT=3 + +VSERVERDIR=$(CURDIR)/debian/vserver + +ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) + CFLAGS += -g +endif +ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) + INSTALL_PROGRAM += -s +endif + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + touch configure-stamp + + +build-arch: configure-stamp build-arch-stamp +build-arch-stamp: + dh_testdir + + # Add here command to compile/build the package. + $(MAKE) + + touch build-arch-stamp + +build-indep: configure-stamp build-indep-stamp +build-indep-stamp: + dh_testdir + + # Add here command to compile/build the arch indep package. + # It's ok not to do anything here, if you don't need to build + # anything for this package. + #/usr/bin/docbook-to-man debian/vserver.sgml > vserver.1 + + touch build-indep-stamp + +build: build-arch build-indep + +clean: + dh_testdir + dh_testroot + rm -f build-arch-stamp build-indep-stamp configure-stamp + + # Add here commands to clean up after the build process. + -$(MAKE) clean + + dh_clean + +install: DH_OPTIONS= +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/vserver. + $(MAKE) install DESTDIR=$(VSERVERDIR) RPM_BUILD_ROOT=$(VSERVERDIR) + + # Clean out things that do not work on Debian. + rm $(VSERVERDIR)/etc/init.d/v_* + rm $(VSERVERDIR)/usr/sbin/newvserver + rm $(VSERVERDIR)/usr/lib/vserver/vunify + rm $(VSERVERDIR)/usr/sbin/vfiles + rm $(VSERVERDIR)/usr/lib/vserver/install-rh* + rm $(VSERVERDIR)/usr/lib/vserver/sample* + # Make sure that you can not escape from the vservers. + chmod 000 $(VSERVERDIR)/var/lib/vservers + # Copy in a debian version of install-post.sh + #cp -a debian/install-post.sh $(VSERVERDIR)/usr/lib/vserver/ +# dh_movefiles + +# Build architecture-independent files here. +# Pass -i to all debhelper commands in this target to reduce clutter. +binary-indep: build install + +binary-indep-forlater: + dh_testdir -i + dh_testroot -i +# dh_installdebconf -i + dh_installdocs -i + dh_installexamples -i + dh_installmenu -i +# dh_installlogrotate -i +# dh_installemacsen -i +# dh_installpam -i +# dh_installmime -i + dh_installinit -i + dh_installcron -i +# dh_installman -i + dh_installinfo -i +# dh_undocumented -i + dh_installchangelogs -i + dh_link -i + dh_compress -i + dh_fixperms -i + dh_installdeb -i +# dh_perl -i + dh_gencontrol -i + dh_md5sums -i + dh_builddeb -i + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir -a + dh_testroot -a +# dh_installdebconf -a + dh_installdocs -a + dh_installexamples -a + dh_installmenu -a +# dh_installlogrotate -a +# dh_installemacsen -a +# dh_installpam -a +# dh_installmime -a +# dh_installinit -a + dh_installcron -a +# dh_installman -a + dh_installinfo -a +# dh_undocumented -a + dh_installchangelogs -a + dh_strip -a + dh_link -a + dh_compress -a + dh_fixperms -a -Xvar/lib/vservers +# dh_makeshlibs -a + dh_installdeb -a +# dh_perl -a + dh_shlibdeps -a + dh_gencontrol -a + dh_md5sums -a + dh_builddeb -a + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure --- vserver-0.21.orig/debian/vserver.postrm +++ vserver-0.21/debian/vserver.postrm @@ -0,0 +1,40 @@ +#! /bin/sh +# postrm script for vserver +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' overwrit>r> +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + purge) + update-rc.d rebootmgr remove > /dev/null + update-rc.d vservers remove > /dev/null + ;; + remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + + ;; + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 --- vserver-0.21.orig/debian/changelog +++ vserver-0.21/debian/changelog @@ -0,0 +1,35 @@ +vserver (0.21-1) unstable; urgency=low + + * New upstream release, closes #170971. + * Changed the environment variable name that controls the vservers + location from VSERVER_ROOT to VSERVERS_ROOT to make it more obvious + that it handles all vservers and not just one. + + -- Ola Lundqvist Thu, 5 Dec 2002 10:01:43 +0100 + +vserver (0.19-4) unstable; urgency=low + + * Now suggests kernel-patch-ctx, closes: #171325. + + -- Ola Lundqvist Mon, 2 Dec 2002 08:44:16 +0100 + +vserver (0.19-3) unstable; urgency=low + + * Fixed a typo in find script in vserver init, closes: #171019. + * Added /var/lock/subsys directory. + + -- Ola Lundqvist Thu, 28 Nov 2002 07:23:50 +0100 + +vserver (0.19-2) unstable; urgency=low + + * Fixed vservers init file, thanks to Chris Dukes + for suggestions. Closes: #170627. + + -- Ola Lundqvist Mon, 25 Nov 2002 12:16:20 +0100 + +vserver (0.19-1) unstable; urgency=low + + * Initial release, closes: #161445. + + -- Ola Lundqvist Tue, 3 Sep 2002 19:13:50 +0200 + --- vserver-0.21.orig/debian/vserver.preinst +++ vserver-0.21/debian/vserver.preinst @@ -0,0 +1,44 @@ +#! /bin/sh +# preinst script for vserver +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `install' +# * `install' +# * `upgrade' +# * `abort-upgrade' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + install|upgrade) +# if [ "$1" = "upgrade" ] +# then +# start-stop-daemon --stop --quiet --oknodo \ +# --pidfile /var/run/vserver.pid \ +# --exec /usr/sbin/vserver 2>/dev/null || true +# fi + ;; + + abort-upgrade) + ;; + + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + --- vserver-0.21.orig/debian/vserver.prerm +++ vserver-0.21/debian/vserver.prerm @@ -0,0 +1,48 @@ +#! /bin/sh +# prerm script for vserver +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `upgrade' +# * `failed-upgrade' +# * `remove' `in-favour' +# * `deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + remove|upgrade|deconfigure) + if [ -x "/etc/init.d/vservers" ] ; then + true + fi + if [ -x "/etc/init.d/vservers" ] ; then + if [ -x /usr/sbin/invoke-rc.d ] ; then + invoke-rc.d rebootmgr stop + else + /etc/init.d/rebootmgr stop + fi + fi + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + --- vserver-0.21.orig/debian/vserver-linuxconf.files +++ vserver-0.21/debian/vserver-linuxconf.files @@ -0,0 +1 @@ +usb/sbin/newvserver --- vserver-0.21.orig/debian/vserver.README.Debian +++ vserver-0.21/debian/vserver.README.Debian @@ -0,0 +1,71 @@ +vserver for Debian +------------------ + + Vservers root: + ============== + + In this debian package the vserver root is changed from /vservsers to + /var/lib/vservers. This is because the /vservers directory is not LSB + compliant. You can change this back to the original behaviour by creating + that directory and change /etc/vserver.conf. You can of course use other + places like /home/vservers or similar. + + # Create the dir. + mkdir /vservers + # This is an important security fix! + chmod 000 /vservers + # change vserver.conf (or simply remove it). + perl -pi -e "s|/var/lib/vservers|/vservers|" /etc/vserver.conf + + If you change this make sure that you shut down rebootmgr and vservers + before you make the changes. + + Note about different releases: + ============================== + + You will probably have problem to run a woody chroot inside a sid + box. At least I did not make it work properly. It was due to some + issues with libc6 (or similar). I can not explain it but it should + hopefully be possible to fix in the future. You can start it and + it seems to run but you can not enter it... + + Create a system to test: + ======================== + + Alternative 1 (the debian way): + ------------- + + Use debootstrap + + Alternative 2 (for test purposes mostly): + ------------- + + echo 'HOSTNAME="test"' > /etc/vservers/test.conf + cd /vservers (or /var/lib/vservers) + mkdir test + cd test + mkdir -p bin sbin lib tmp dev etc root home var/run var/tmp var/cache + # If you have a pbuilder etc then you can use that instead. + cp /etc/* etc + mount --bind -o ro /bin bin + mount --bind -o ro /sbin sbin + mount --bind -o ro /lib lib + /usr/lib/vserver/install-post.sh + + Use the vserver: + ================ + + Now you can start the vserver by using: + vserver test start + And stop it using: + vserver test stop + + To enter the vserver: + vserver test enter + + More documentation: + =================== + + http://www.solucorp.qc.ca/miscprj/s_context.hc + + -- Ola Lundqvist , Tue, 3 Sep 2002 19:13:50 +0200 --- vserver-0.21.orig/debian/vserver.postinst +++ vserver-0.21/debian/vserver.postinst @@ -0,0 +1,64 @@ +#! /bin/sh +# postinst script for vserver +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package +# +# quoting from the policy: +# Any necessary prompting should almost always be confined to the +# post-installation script, and should be protected with a conditional +# so that unnecessary prompting doesn't happen if a package's +# installation fails and the `postinst' is called with `abort-upgrade', +# `abort-remove' or `abort-deconfigure'. + +case "$1" in + configure) + if [ -x "/etc/init.d/vservers" ] ; then + update-rc.d vservers defaults > /dev/null + if [ -x /usr/sbin/invoke-rc.d ] ; then + invoke-rc.d vservers start + else + /etc/init.d/vservers start + fi + fi + if [ -x "/etc/init.d/vservers" ] ; then + update-rc.d rebootmgr defaults > /dev/null + if [ -x /usr/sbin/invoke-rc.d ] ; then + invoke-rc.d rebootmgr start + else + /etc/init.d/rebootmgr start + fi + fi + + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + --- vserver-0.21.orig/debian/vserver-linuxconf.dirs +++ vserver-0.21/debian/vserver-linuxconf.dirs @@ -0,0 +1 @@ +usb/sbin --- vserver-0.21.orig/debian/copyright +++ vserver-0.21/debian/copyright @@ -0,0 +1,25 @@ +This package was debianized by Ola Lundqvist on +Tue, 3 Sep 2002 19:13:50 +0200. + +It was downloaded from: + http://www.solucorp.qc.ca/miscprj/s_context.hc + +Upstream Author: + +Copyright: + + This is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2, or (at your option) any later + version. + + This is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License with + your Debian GNU/Linux system, in /usr/share/common-licenses/GPL, or with + the vserver source package as the file LICENSE. If not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. --- vserver-0.21.orig/debian/vserver.dirs +++ vserver-0.21/debian/vserver.dirs @@ -0,0 +1,4 @@ +usr/sbin +etc/vservers +var/lib/vservers +var/lock/subsys --- vserver-0.21.orig/debian/vserver.docs +++ vserver-0.21/debian/vserver.docs @@ -0,0 +1,2 @@ +README +TODO --- vserver-0.21.orig/debian/vserver.examples +++ vserver-0.21/debian/vserver.examples @@ -0,0 +1,3 @@ +v_*.sysv +distrib/*.* +debian/create-example.sh --- vserver-0.21.orig/vservers.grabinfo.sh +++ vserver-0.21/vservers.grabinfo.sh @@ -1,7 +1,14 @@ #!/bin/sh # Produce some XML statistics about vservers USR_SBIN=/usr/sbin -cd /vservers + +VSERVERS_ROOT=/vservers + +if [ -r /etc/vserver.conf ] ; then + . /etc/vserver.conf +fi + +cd $VSERVERS_ROOT for vserv in * do if [ -f /etc/vservers/$vserv.conf ] ; then --- vserver-0.21.orig/v_httpd.sysv +++ vserver-0.21/v_httpd.sysv @@ -3,4 +3,3 @@ # description: Wrapper to start httpd bound to a single IP USR_LIB_VSERVER=/usr/lib/vserver exec $USR_LIB_VSERVER/vsysvwrapper httpd $* - --- vserver-0.21.orig/rebootmgr.cc +++ vserver-0.21/rebootmgr.cc @@ -39,14 +39,25 @@ { fprintf (stderr,"rebootmgr version %s\n",VERSION); fprintf (stderr,"\n"); - fprintf (stderr,"rebootmgr [--pidfile file ] vserver-name [ vserver-name ...]\n"); + fprintf (stderr,"rebootmgr [--pidfile file ] vserver-name [ vserver-name ...]\n\n"); + fprintf (stderr,"rebootmgr vserver-name [ vserver-name ...]\n\n"); + fprintf (stderr,"An environment variable VSERVERS_ROOT can change the default directory\n"); + fprintf (stderr,"/vservers to somewhere else.\n"); } static int rebootmgr_opensocket (const char *vname) { int ret = -1; char sockn[PATH_MAX]; - sprintf (sockn,"/vservers/%s/dev/reboot",vname); + char* vrootenv = getenv("VSERVERS_ROOT"); + if (strlen(vrootenv)+strlen(vname)+strlen("//dev/reboot") > PATH_MAX) { + fprintf (stderr,"Environment VSERVERS_ROOT + vservername exceeds the maximum path length, using default root /vservers."); + vrootenv = NULL; + } + if (vrootenv == NULL) { + vrootenv = "/vservers"; + } + sprintf (sockn,"%s/%s/dev/reboot",vrootenv,vname); unlink (sockn); int fd = socket (AF_UNIX,SOCK_STREAM,0); if (fd == -1){ --- vserver-0.21.orig/vunify.cc +++ vserver-0.21/vunify.cc @@ -24,6 +24,7 @@ static bool undo = false; static int ext2flags = EXT2_IMMUTABLE_FILE_FL | EXT2_IMMUTABLE_LINK_FL; +string * vservroot; struct EXCLDIR{ string prefix; int len; @@ -65,7 +66,9 @@ "set on the files. So if you want no immutable flags, you must\n" "use --noflags. If you want a single flag, you must use\n" "--noflags first, then the --immutable or --immutable-mayunlink\n" - "flag.\n" + "flag.\n\n" + "An environment variable VSERVERS_ROOT can change the default directory\n" + "/vservers to somewhere else.\n" ; } @@ -102,7 +105,7 @@ { if (files.empty()){ if (debug) cout << "Loading files for package " << name << endl; - string cmd = "/usr/sbin/chroot /vservers/" + ref + " /bin/rpm -ql --dump " + string cmd = "/usr/sbin/chroot " + *vservroot + "/" + ref + " /bin/rpm -ql --dump " + name + "-" + version; FILE *fin = popen (cmd.c_str(),"r"); if (fin == NULL){ @@ -179,7 +182,7 @@ cmd = "/bin/rpm -qa" " --queryformat \"%{name}=%{version}-%{release}\\n\""; }else{ - cmd = "/usr/sbin/chroot /vservers/" + refserver + " /bin/rpm -qa" + cmd = "/usr/sbin/chroot " + *vservroot + "/" + refserver + " /bin/rpm -qa" " --queryformat \"%{name}=%{version}-%{release}\\n\""; } // cout << "command " << cmd << endl; @@ -221,8 +224,8 @@ {} void operator()(const string &file) { - string refpath = "/vservers/" + ref_server + file; - string dstpath = "/vservers/" + target_server + file; + string refpath = *vservroot + "/" + ref_server + file; + string dstpath = *vservroot + "/" + target_server + file; if (debug) cout << "Unify " << refpath << " -> " << dstpath << endl; struct stat st; if (stat(refpath.c_str(),&st)==-1){ @@ -343,12 +346,17 @@ { int ret = -1; int i; + char * tmp = getenv("VSERVERS_ROOT"); + if (tmp == NULL) { + tmp = "/servers"; + } + vservroot = new string(tmp); for (i=1; i/dev/null | grep -v lost+found | wc -l` + NBSUB=`ls $VSERVERS_ROOT/$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 $VSERVERS_ROOT/$1 already exist else - if [ ! -d /vservers ] ; then - mkdir /vservers || exit 1 - chmod 000 /vservers - echo Directory /vservers was created with permissions 000 - fi - mkdir -p /vservers/$1 || exit 1 - chmod 755 /vservers/$1 - cp -ax /sbin /bin /etc /usr /var /lib /vservers/$1/. || exit 1 - cd /vservers/$1 || exit 1 + if [ ! -d $VSERVERS_ROOT ] ; then + mkdir $VSERVERS_ROOT || exit 1 + chmod 000 $VSERVERS_ROOT + echo Directory $VSERVERS_ROOT was created with permissions 000 + fi + mkdir -p $VSERVERS_ROOT/$1 || exit 1 + chmod 755 $VSERVERS_ROOT/$1 + cp -ax /sbin /bin /etc /usr /var /lib $VSERVERS_ROOT/$1/. || exit 1 + cd $VSERVERS_ROOT/$1 || exit 1 rm -fr lib/modules/* rm -f var/spool/mail/* rm -f `find var/run -type f` @@ -238,7 +244,7 @@ *.bak|*~|functions|killall|halt|single) ;; *) - #$USR_LIB_VSERVER/capchroot /vservers/$1 /sbin/chkconfig --level 2345 $serv off + #$USR_LIB_VSERVER/capchroot $VSERVERS_ROOT/$1 /sbin/chkconfig --level 2345 $serv off $0 --silent $1 chkconfig --level 2345 $serv off ;; esac @@ -254,7 +260,7 @@ cp -a $USR_LIB_VSERVER/vreboot sbin/. ln -sf vreboot sbin/vhalt - echo Directory /vservers/$1 has been populated + echo Directory $VSERVERS_ROOT/$1 has been populated if [ ! -d /etc/vservers ] ; then mkdir /etc/vservers chmod 600 /etc/vservers @@ -325,8 +331,8 @@ 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 $VSERVERS_ROOT/$1/. ] ; then + echo No directory for this vserver: $VSERVERS_ROOT/$1 exit 1 elif [ "$2" = "start" ] ; then echo Starting the virtual server $1 @@ -342,11 +348,11 @@ S_FLAGS= . /etc/vservers/$1.conf ifconfig_iproot $1 - cd /vservers/$1 || exit 1 + cd $VSERVERS_ROOT/$1 || exit 1 rm -f `find var/run -type f` touch var/run/utmp rm -f var/lock/subsys/* - mountproc /vservers/$1 + mountproc $VSERVERS_ROOT/$1 CTXOPT= HOSTOPT= DOMAINOPT= @@ -355,7 +361,7 @@ CAPS= get_initdefault $1 STARTCMD="/etc/rc.d/rc $INITDEFAULT" - if [ -x /vservers/$1/etc/init.d/rc ] ; then + if [ -x $VSERVERS_ROOT/$1/etc/init.d/rc ] ; then STARTCMD="/etc/init.d/rc $INITDEFAULT" fi @@ -408,9 +414,9 @@ fi #echo FLAGS=$FLAGS #echo CAPS=$CAPS - # We switch to /vservers/$1 now, because after the - # security context switch /vservers directory becomes a dead zone. - cd /vservers/$1 + # We switch to $VSERVERS_ROOT/$1 now, because after the + # security context switch $VSERVERS_ROOT directory becomes a dead zone. + cd $VSERVERS_ROOT/$1 IPOPT=`setipopt $IPROOT` export PATH=/sbin:/usr/sbin:/bin:/usr/bin $NICECMD $CHBIND_CMD $SILENT $IPOPT --bcast $IPROOTBCAST \ @@ -457,13 +463,13 @@ test -x /etc/vservers/$1.sh && /etc/vservers/$1.sh pre-stop $1 ifconfig_iproot $1 . /var/run/vservers/$1.ctx - cd /vservers/$1 - mountproc /vservers/$1 + cd $VSERVERS_ROOT/$1 + mountproc $VSERVERS_ROOT/$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 $VSERVERS_ROOT/$1/etc/init.d/rc ] ; then STOPCMD="/etc/init.d/rc 6" fi for f in $S_FLAGS dummy @@ -478,7 +484,7 @@ esac done - cd /vservers/$1 + cd $VSERVERS_ROOT/$1 IPOPT=`setipopt $IPROOT` export PATH=/sbin:/usr/sbin:/bin:/usr/bin $CHBIND_CMD $SILENT $IPOPT --bcast $IPROOTBCAST \ @@ -493,7 +499,7 @@ fi # We umount anyway, because "enter" establish the mount # but when you exit, the server is considered not running - umountproc /vservers/$1 + umountproc $VSERVERS_ROOT/$1 test -x /etc/vservers/$1.sh && /etc/vservers/$1.sh post-stop $1 ifconfig_iproot_off $1 elif [ "$2" = "restart" ] ; then @@ -508,9 +514,9 @@ IPROOTBCAST= IPROOTDEV= . /etc/vservers/$1.conf - cd /vservers/$1 + cd $VSERVERS_ROOT/$1 ifconfig_iproot $1 - mountproc /vservers/$1 + mountproc $VSERVERS_ROOT/$1 PS1="[\u@vserver:$1 \W]" export PS1 VSERVER=$1 @@ -533,7 +539,7 @@ if $0 $VSERVER running >/dev/null then . /var/run/vservers/$VSERVER.ctx - cd /vservers/$VSERVER + cd $VSERVERS_ROOT/$VSERVER IPOPT=`setipopt $IPROOT` export PATH=/sbin:/usr/sbin:/bin:/usr/bin $CHBIND_CMD $SILENT $IPOPT --bcast $IPROOTBCAST \ @@ -555,7 +561,7 @@ DOMAINOPT="--domainname $S_DOMAINNAME" fi mkdir -p /var/run/vservers - cd /vservers/$VSERVER + cd $VSERVERS_ROOT/$VSERVER IPOPT=`setipopt $IPROOT` export PATH=/sbin:/usr/sbin:/bin:/usr/bin $CHBIND_CMD $SILENT $IPOPT --bcast $IPROOTBCAST \ @@ -586,9 +592,9 @@ fi if [ $# != 2 ] ; then echo Invalid argument, expected vserver name chkconfig [ --level nnn ] service on\|off - elif [ -x /vservers/$VSERVER/sbin/chkconfig ] ; then + elif [ -x $VSERVERS_ROOT/$VSERVER/sbin/chkconfig ] ; then exec $0 --silent $VSERVER exec /sbin/chkconfig "$@" - elif [ -x /vservers/$VSERVER/usr/sbin/update-rc.d ] ; then + elif [ -x $VSERVERS_ROOT/$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