summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2010-11-26 16:51:41 +0000
committerLars Wirzenius <liw@liw.fi>2010-11-26 16:51:41 +0000
commit9158cc482a6b5e07fa06a23e000936898006f51d (patch)
treedebe0511d97a705d3ff03e7be8cd2276610702e1
parenta178066cf03f50a30e833eaeab5bd02aa9a95126 (diff)
downloadliw-automation-9158cc482a6b5e07fa06a23e000936898006f51d.tar.gz
Replace liw-vm-clone with liw-vm-create. It is too hard to maintain
a library of base images which would be cloned. Easier to just create new ones from scratch.
-rw-r--r--debian/changelog8
-rwxr-xr-xscripts/liw-vm-clone87
-rwxr-xr-xscripts/liw-vm-create19
3 files changed, 27 insertions, 87 deletions
diff --git a/debian/changelog b/debian/changelog
index 4118072..e976468 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+liw-automation (8.1) squeeze; urgency=low
+
+ * Replace liw-vm-clone with liw-vm-create. It is too hard to maintain
+ a library of base images which would be cloned. Easier to just
+ create new ones from scratch.
+
+ -- Lars Wirzenius <liw@liw.fi> Fri, 26 Nov 2010 16:50:57 +0000
+
liw-automation (8.0.2) squeeze; urgency=low
* Move scripts to a subdirectory. Install everything in there.
diff --git a/scripts/liw-vm-clone b/scripts/liw-vm-clone
deleted file mode 100755
index fc5b40d..0000000
--- a/scripts/liw-vm-clone
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/sh
-
-set -e
-
-die()
-{
- printf -- "%s\n" "$*" 1>&2
- exit 1
-}
-
-
-clone()
-{
- local oldname="$1"
- local newname="$2"
- local img="$3"
-
- if [ -e "$img" ]
- then
- echo "Image file $img already exists. Skipping clone."
- else
- echo "Cloning $oldname to $newname"
- virt-clone --connect qemu:///system -o "$oldname" -n "$newname" \
- -f "$img"
- chmod 770 "$img"
- fi
-}
-
-
-fixup()
-{
- local oldname="$1"
- local mountpt="$2"
-
- if grep -x -e "$oldname" "$mountpt/etc/hostname" > /dev/null
- then
- echo "fixing up /etc/hostname on $oldname"
- sed -i "s/$oldname/$newname/g" "$mountpt/etc/hostname"
-
- echo "fixing up /etc/hosts on $oldname"
- sed -i "s/$oldname/$newname/g" "$mountpt/etc/hosts"
-
- echo "removing udev's persistent net rule"
- rm -f "$mountpt/etc/udev/rules.d/70-persistent-net.rules"
- else
- echo "EEEK! /etc/hostname does not match $oldname"
- echo "Not touching this filesystem."
- echo "/etc/hostname is:"
- cat $mountpt/etc/hostname
- fi
-}
-
-
-[ $# = 2 ] || die "Usage: $0 oldname newname"
-oldname="$1"
-newname="$2"
-img="/srv/vm/$newname.img"
-
-clone "$oldname" "$newname" "$img"
-
-mountpt=$(mktemp -d)
-tempfile=$(mktemp)
-kpartx -av "$img" > "$tempfile"
-sleep 2 # FIXME: for some reasons things are not immediate
-
-sed 's/.*(\(.*\)).*/\1/' "$tempfile" |
-while read pair
-do
- dev="/dev/block/$pair"
- if pvdisplay "$dev" > /dev/null 2>&1
- then
- vg=$(pvdisplay "$dev" | awk '/^ VG Name/ { print $NF }')
- vgchange -ay "$vg" > /dev/null
- for lv in "/dev/$vg"/*
- do
- if mount "$lv" "$mountpt" 2> /dev/null && [ -e "$mountpt/etc" ]
- then
- fixup "$oldname" "$mountpt"
- umount "$mountpt"
- fi
- done
- vgchange -an "$vg" > /dev/null
- fi
-done
-kpartx -d "$img" > /dev/null
-rm -f "$tempfile"
-rmdir "$mountpt"
diff --git a/scripts/liw-vm-create b/scripts/liw-vm-create
new file mode 100755
index 0000000..c5c86af
--- /dev/null
+++ b/scripts/liw-vm-create
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+set -e
+
+if [ $# != 3 ]
+then
+ echo "Usage: $0 vm-name size-in-gigabytes path-to-install-iso" 1>&2
+ exit 1
+fi
+
+name="$1"
+size="$2"
+iso="$3"
+ram=512 # This is hardcoded to be good for install. Fix afterwards.
+
+sudo -p "Password (to run virt-install): " \
+ virt-install -n "$name" -r "$ram" \
+ --disk path="/srv/vm/$name.img",size="$size",bus=virtio \
+ --cdrom "$iso" --vnc --noautoconsole