From 64d35502e99ba4409177421681a17d0cc1fbab93 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Tue, 4 Feb 2014 13:33:19 +0100 Subject: [PATCH] tweaked for lbuild-initvm --- scripts/create-vm.sh | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/scripts/create-vm.sh b/scripts/create-vm.sh index 6503e20..a4f228f 100755 --- a/scripts/create-vm.sh +++ b/scripts/create-vm.sh @@ -4,57 +4,57 @@ COMMAND=$(basename $0) DIRNAME=$(dirname $0) BUILD="${HOME}/git-build" + +echo "Updating $BUILD" +cd $BUILD +git pull +cd - + +LOGS=$HOME/machines + +[ -d $LOGS ] || { echo "Creating logs dir $LOGS" ; mkdir -p $LOGS; } + DOMAIN=pl.sophia.inria.fr -DEFAULT_DISTRO=f14 -DEFAULT_PERSO=linux64 +DEFAULT_DISTRO=f20 +# do not care about 32 bits anymore +#DEFAULT_PERSO=linux64 INTERACTIVE= DISTRO=$DEFAULT_DISTRO -PERSO=$DEFAULT_PERSO function usage () { message="$@" - echo "usage : $COMMAND [-i] [-f distro] [-p perso] hostname" + echo "usage : $COMMAND [-i] [-f distro] 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 +while getopts "f: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)" +container="$1" ; shift +[[ -n "$@" ]] && usage "extra arguments" "$@" "(hostname=$container)" [ -d "$BUILD" ] || usage "Could not find directory $BUILD" -[ -d /vservers/$HOSTNAME ] && usage "vserver $HOSTNAME already exists in /vservers" -[ -d /etc/vservers/.distributions/$DISTRO ] || usage "distro $DISTRO not known in /etc/vservers/.distributions/" - -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}') +[ -d /vservers/$container ] && usage "container $container already exists in /vservers" -cd $BUILD -git pull -cd - +fqdn=$container.$DOMAIN -# 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" +command="$BUILD/lbuild-initvm.sh -f $DISTRO -n $fqdn $container" if [ -n "$INTERACTIVE" ] ; then echo -n "Run $command OK ? " read answer ; case $answer in [nN]*) exit 1 ;; esac fi -$command +$command 2>&1 > $LOGS/$container.log + -- 2.43.0