added clone-baseimage.sh
authorvarac <varacanero@zeromail.org>
Tue, 18 Dec 2012 09:15:14 +0000 (10:15 +0100)
committervarac <varacanero@zeromail.org>
Tue, 18 Dec 2012 09:15:14 +0000 (10:15 +0100)
clone-baseimage.sh [new file with mode: 0644]

diff --git a/clone-baseimage.sh b/clone-baseimage.sh
new file mode 100644 (file)
index 0000000..dde8559
--- /dev/null
@@ -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
+