From d0bbf82b084daccaa9a3a2d859c94db3d59c457b Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 5 Feb 2014 10:52:34 +0100 Subject: [PATCH] trashed create-vm-debian.sh --- scripts/create-vm-debian.sh | 94 ------------------------------------- 1 file changed, 94 deletions(-) delete mode 100755 scripts/create-vm-debian.sh diff --git a/scripts/create-vm-debian.sh b/scripts/create-vm-debian.sh deleted file mode 100755 index 33eebc2..0000000 --- a/scripts/create-vm-debian.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash - -# WARNING: looks like specifying another arch/preso won't work - -COMMAND=$(basename $0) -DIRNAME=$(dirname $0) - -#BUILD="${HOME}/git-build" -DOMAIN=pl.sophia.inria.fr - -DEFAULT_DISTRO=wheezy -DEFAULT_PERSO=linux64 - -INTERACTIVE= -DISTRO=$DEFAULT_DISTRO -PERSO=$DEFAULT_PERSO -function usage () { - message="$@" - echo "usage : $COMMAND [-i] [-f distro] [-p perso] hostname" - echo " default distro is $DEFAULT_DISTRO" - echo " default perso is $DEFAULT_PERSO" - [ -n "$message" ] && echo $message - exit 1 -} - -while getopts "f:p:ih" flag; do - case $flag in - f) DISTRO=$OPTARG;; - p) PERSO=$OPTARG;; - i) INTERACTIVE=true ;; - ?|h) usage "" ;; - esac -done -shift $((OPTIND-1)) -[[ -z "$@" ]] && usage "no hostname provided" -HOSTNAME="$1" ; shift -[[ -n "$@" ]] && usage "extra arguments" "$@" "(hostname=$HOSTNAME)" - - -#[ -d "$BUILD" ] || usage "Could not find directory $BUILD" - -[ -d /vservers/$HOSTNAME ] && usage "vserver $HOSTNAME already exists in /vservers" -# debian distros not found there - skip that -#[ -d /etc/vservers/.distributions/$DISTRO ] || usage "distro $DISTRO not known in /etc/vservers/.distributions/" -rpm -q debootstrap >& /dev/null || usage "You need to first run 'yum install debootstrap'" - -fqdn=$HOSTNAME.$DOMAIN -## compute IP -host $fqdn | grep -q 'has address' || usage "hostname $fqdn not known to DNS" -ip=$(host $fqdn | grep 'has address' | awk '{print $4}') - -#cd $BUILD -#git pull -#cd - - -# single_ip needs to be turned off, vtest-initvm now takes care of that -#command="$BUILD/vtest-initvm.sh -p $PERSO -f $DISTRO $HOSTNAME none -- --interface eth0:$ip --hostname $fqdn" - -case $PERSO in - linux32) arch=i386;; - linux64) arch=amd64;; -esac - -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 ? " - read answer ; case $answer in [nN]*) exit 1 ;; esac -fi - -$command - -## 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 -- 2.43.0