X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=scripts%2Fcreate-vm-debian.sh;h=5d3f638c152534ec857da7c819455a6381829958;hb=fbc6aec1ec4e083bf0e048e366ff2a812da01918;hp=b10f39dfb271dd39d9effe381bb177c05043b388;hpb=1fd4f7a5126deaf12014b182e4a00abc4709531d;p=infrastructure.git diff --git a/scripts/create-vm-debian.sh b/scripts/create-vm-debian.sh index b10f39d..5d3f638 100755 --- a/scripts/create-vm-debian.sh +++ b/scripts/create-vm-debian.sh @@ -61,7 +61,14 @@ case $PERSO in 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 ? " @@ -70,13 +77,18 @@ fi $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//var/run -> /run +# /vservers//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