X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=scripts%2Fcreate-vm.sh;h=f509c0daca92ba652db2e86b6e0303b54ef6782b;hb=c83e260c64091dc565294a670212218d7101ebe0;hp=c8c26c71999d7808fbe9715ac7db2610143e2a9e;hpb=7e2e404fb0dbd6ddff89fc23389216b3efc585b5;p=infrastructure.git diff --git a/scripts/create-vm.sh b/scripts/create-vm.sh index c8c26c7..f509c0d 100755 --- a/scripts/create-vm.sh +++ b/scripts/create-vm.sh @@ -16,18 +16,20 @@ LOGS=$HOME/machines 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" echo "examples" echo " create-vm.sh sandbox" @@ -39,13 +41,14 @@ 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 ;; i) IMAGE=$OPTARG ;; m) MEMORY=$OPTARG ;; n) VM_HOSTNAME=$OPTARG ;; + s) DO_NOT_START_VM=true ;; ?|h) usage "" ;; esac done @@ -59,16 +62,17 @@ container="$1" ; shift [ -d "$BUILD" ] || usage "Could not find directory $BUILD" [ -d /vservers/$container ] && usage "container $container already exists in /vservers" -# comopute all vars from args +# 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 # prepare initvm command initvm="$BUILD/lbuild-initvm.sh" -initvm="$initvm -f $DISTRO" +[ -z "$IMAGE" ] && initvm="$initvm -f $DISTRO" || initvm="$initvm -i $IMAGE" initvm="$initvm -n $fqdn" -[ -n "$IMAGE" ] && initvm="$initvm -i $IMAGE" +[ -n "$DO_NOT_START_VM" ] && initvm="$initvm -s" [ -n "$MEMORY" ] && initvm="$initvm -m $MEMORY" initvm="$initvm $container"