X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=scripts%2Fcreate-vm.sh;h=c9487718636b093468d15465016c33c082bbef8c;hb=7f325790e1194f697976d03e2a38d368b05bc709;hp=995e083525da76c9808ae8bfd032537d8c734802;hpb=826f95460c5dd06ab6ec04eb8cc0d6d98b9d09b8;p=infrastructure.git diff --git a/scripts/create-vm.sh b/scripts/create-vm.sh index 995e083..c948771 100755 --- a/scripts/create-vm.sh +++ b/scripts/create-vm.sh @@ -5,28 +5,24 @@ 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=f20 +DEFAULT_DISTRO=f22 +DEFAULT_MEMORY=4096 CONFIRM= function usage () { message="$@" - echo "usage : $COMMAND [-c] [-f distro] [-i image] [ -m memory ] [ -n hostname ] container" + echo "usage : $COMMAND [-c] [-f distro] [-i image] [ -m memory ] [ -n hostname ] [-s] container" echo " -c : confirm, will show the command and prompt for confirmation " echo " -f : set distro, default is $DEFAULT_DISTRO" echo " -i : if specified, image is rsynced into /vservers" echo " warning: we cannot use an image already in /vservers..." - echo " -m : memory size in Mb - default is 512" + echo " -m : memory size in Mb - default is $DEFAULT_MEMORY" echo " -n : specify hostname if different from container" echo " -s : do not start VM" echo " container : used for /vservers/foo as well as the lxc/libvirt name" @@ -40,7 +36,7 @@ function usage () { } # using HOSTNAME won't work as this is already set in environment -while getopts "cf:i:m:n:h" flag; do +while getopts "cf:i:m:n:sh" flag; do case $flag in c) CONFIRM=true ;; f) DISTRO=$OPTARG ;; @@ -61,8 +57,14 @@ container="$1" ; shift [ -d "$BUILD" ] || usage "Could not find directory $BUILD" [ -d /vservers/$container ] && usage "container $container already exists in /vservers" +echo "Updating $BUILD" +cd $BUILD +git pull +cd - + # compute all vars from args [ -z "$DISTRO" ] && DISTRO="$DEFAULT_DISTRO" +[ -z "$MEMORY" ] && MEMORY="$DEFAULT_MEMORY" [ -z "$VM_HOSTNAME" ] && VM_HOSTNAME="$container" fqdn=$VM_HOSTNAME.$DOMAIN