summaryrefslogtreecommitdiff
path: root/create-vm
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-07-20 15:31:37 +0300
committerLars Wirzenius <liw@liw.fi>2015-07-20 15:31:37 +0300
commit84ccd93ddff7193078735c3d947e0f6beecaa07f (patch)
tree84d232556bf2c7e0453f5c49b70b155660472cf8 /create-vm
parent2ac152b0a0a90b5061db5ad46d08172ab558704d (diff)
downloadansibleness-84ccd93ddff7193078735c3d947e0f6beecaa07f.tar.gz
Check that base path exists
Diffstat (limited to 'create-vm')
-rwxr-xr-xcreate-vm10
1 files changed, 9 insertions, 1 deletions
diff --git a/create-vm b/create-vm
index d5ec376..ecbd8e7 100755
--- a/create-vm
+++ b/create-vm
@@ -11,6 +11,14 @@ base="$2"
# Where are the base images?
imagedir="/big/base-images"
+# Does the base image exist?
+basepath="$imagedir/base-$base.img.xz"
+if [ ! -e "$basepath" ]
+then
+ echo "$basepath does not exist" 1>&2
+ exit 1
+fi
+
# How large are the (uncompressed) images?
size="4G"
@@ -22,7 +30,7 @@ sudo lvcreate --name "$name" --size "$size" "$vg"
lvpath="/dev/$vg/$name"
# Copy uncompressed image to LV.
-unxz < "$imagedir/base-$base.img.xz" |
+unxz < "$basepath" |
pv --size "$size" |
sudo ionice -c3 tee "$lvpath" > /dev/null