summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2012-10-10 18:00:39 +0200
committervarac <varacanero@zeromail.org>2012-10-10 18:00:39 +0200
commit7e5d36c77bbc4af5087f5f88b83c8290fb933043 (patch)
tree07482e8d580bd825e9425ba2228dabe2b7e30d4f
parent738cebb625cb225439f2ff21570ce8c147842aac (diff)
disk size values
-rwxr-xr-xcreate-guest-with-cloudinit13
1 files changed, 10 insertions, 3 deletions
diff --git a/create-guest-with-cloudinit b/create-guest-with-cloudinit
index feecdcc..8258f11 100755
--- a/create-guest-with-cloudinit
+++ b/create-guest-with-cloudinit
@@ -4,7 +4,7 @@
# apt-get install virtinst libvirt-bin dosfstools mtools kvm kvm-qemu
# apt-get install -t wheezy util-linux
-# defaults
+# defaults, configurable in config
VG='vg01'
ETC='/etc/cloudinit'
CONFIG="$ETC/cloudinit.cfg"
@@ -12,9 +12,14 @@ VARDIR='/var/lib/libvirt/cloudinit'
SCRIPTDIR='/usr/local/bin/leap_cloudadmin'
KVM_URI='qemu:///system'
+
# overwrite defaults
[ -e $CONFIG] && . $CONFIG
+# unconfigurable variables
+# swapsize is swapsize of the base image
+SWAPSIZE=4
+MIN_DISKSIZE=10
fail() { [ $# -eq 0 ] || echo "$@"; exit 1; }
bad_usage() { usage 1>&2; [ $# -eq 0 ] || fail "$@"; exit 1; }
@@ -28,7 +33,7 @@ Usage: ${0##*/} [ $options ] guest_name
options:
-h show usage
- -s size disk size in GB
+ -s size disk size in GB, including $SWAPSIZE GB swap. Minimal value is $MIN_DISKSIZE GB.
EOF
}
@@ -55,9 +60,11 @@ done
[ $# -lt 1 ] && bad_usage "must provide guest name"
[ $# -gt 1 ] && bad_usage "too many arguments"
+[ $size -lt $MIN_DISKSIZE ] && bad_usage "Minimal disk size is 10 GB !"
+
# requirements
echo "mtools_skip_check=1">~/.mtoolsrc
-[ -e /var/lib/libvirt/cloudinit ] || ( mkdir /var/lib/libvirt/cloudinit ; chown libvirt-qemu /var/lib/libvirt/cloudinit )
+[ -e $VARDIR ] || ( mkdir $VARDIR ; chown libvirt-qemu $VARDIR )
vmname=$1