summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clone-baseimage.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/clone-baseimage.sh b/clone-baseimage.sh
new file mode 100644
index 0000000..dde8559
--- /dev/null
+++ b/clone-baseimage.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+ETC='/etc/libvirt/local'
+CONFIG="$ETC/clone-baseimage.conf"
+
+# please overwrite these defaults in $CONFIG
+IMAGE='leap-baseimage-wheezy'
+SRCHOST='cheetah'
+SRCIMAGEPATH="/dev/vg01/$IMAGE"
+DESTIMAGEPATH=$SRCIMAGEPATH
+
+# overwrite defaults
+[ -e $CONFIG ] && . $CONFIG
+
+
+# test on cheetah
+ssh $SRCHOST "virsh list|grep -q $IMAGE" && echo "$IMAGE is up on cheetah. Stop it before cloning !" && exit 1
+
+# test locally
+virsh list|grep -q $IMAGE && echo "$IMAGE is up, locally. Stop it before cloning !" && exit 1
+
+echo "Cloning..."
+ssh $SRCHOST "dd if=$SRCIMAGEPATH" | dd of=$DESTIMAGEPATH
+