linux64) arch=amd64;;
esac
-command="$PERSO vserver ${HOSTNAME} build -m debootstrap --interface eth0:${ip}/21 --hostname ${fqdn} -- -d ${DISTRO} -m http://ftp2.fr.debian.org/debian/ -- --verbose --arch=${arch} "
+case $DISTRO in
+ squeeze|wheezy) DEBMIRROR=http://ftp2.fr.debian.org/debian/ ;;
+# from the vserver man page DEBMIRROR=http://us.archive.ubuntu.com/ubuntu/ ;;
+ oneiric|precise|quantal) DEBMIRROR=http://mir1.ovh.net/ubuntu/ubuntu/ ;;
+ *) echo unknown distro $DISTRO; exit 1;;
+esac
+
+command="$PERSO vserver ${HOSTNAME} build -m debootstrap --interface eth0:${ip}/21 --hostname ${fqdn} -- -d ${DISTRO} -m ${DEBMIRROR} -- --verbose --arch=${arch} "
if [ -n "$INTERACTIVE" ] ; then
echo -n "Run $command OK ? "
$command
-### it looks like this is done too early or something
-sleep 5
-# with wheezy at least, we need to manually create these 2 directories when trying to vserver start for the first time..
-### post processing for starting up
-for dir in run lock; do
- echo "Checking for dir /var/$dir ..."
- [ -d /vservers/${HOSTNAME}/var/$dir ] || mkdir /vservers/${HOSTNAME}/var/$dir
-done
+## stolen from vbuild-util-vserver (might be that we can actually use that one as-is...)
+# turns out that with wheezy at least, at this point we're getting
+# /vservers/<vs>/var/run -> /run
+# /vservers/<vs>/var/lock -> /run/lock
+# trying to fix this with relative links does not appear to work fine
+# when trying to vserver start we're then getting
+# + exec /usr/sbin/vspace --mount --fs --new -- /usr/sbin/vserver ----nonamespace debuild09 start
+# fakerunlevel: open("/var/run/utmp"): No such file or directory
+# so instead we bluntly create empty dirs and hope for the best
+[ -h /vservers/${HOSTNAME}/var/run ] && [ ! -d /vservers/${HOSTNAME}/var/run ] && \
+ { rm -f /vservers/${HOSTNAME}/var/run ; mkdir /vservers/${HOSTNAME}/var/run ; }
+[ -h /vservers/${HOSTNAME}/var/lock ] && [ ! -d /vservers/${HOSTNAME}/var/lock ] && \
+ { rm -f /vservers/${HOSTNAME}/var/lock ; mkdir /vservers/${HOSTNAME}/var/lock ; }
vserver ${HOSTNAME} start