X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=scripts%2Fcreate-vm.sh;h=f4c88f0fc648b6724109d6d76d822ee4107761e6;hb=6025e35cddfac1180021443f73d14fe68e418539;hp=8987106ea2ece82656776842d6431c67a72c46b8;hpb=0b862f2e435cfa1fad281bb2d6479c9f60a96c11;p=infrastructure.git diff --git a/scripts/create-vm.sh b/scripts/create-vm.sh index 8987106..f4c88f0 100755 --- a/scripts/create-vm.sh +++ b/scripts/create-vm.sh @@ -4,57 +4,58 @@ 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-init-vserver now takes care of that -command="$BUILD/vtest-init-vserver.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 +echo "Storing output in $LOGS/$container.log" +$command >& $LOGS/$container.log +