From 9158cc482a6b5e07fa06a23e000936898006f51d Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 26 Nov 2010 16:51:41 +0000 Subject: 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. --- debian/changelog | 8 +++++ scripts/liw-vm-clone | 87 --------------------------------------------------- scripts/liw-vm-create | 19 +++++++++++ 3 files changed, 27 insertions(+), 87 deletions(-) delete mode 100755 scripts/liw-vm-clone create mode 100755 scripts/liw-vm-create 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 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 -- cgit v1.2.1