]> git.ipfire.org Git - people/ms/strongswan.git/commitdiff
testing: Ensure no guest is running when modifying images
authorTobias Brunner <tobias@strongswan.org>
Fri, 10 Oct 2014 16:37:13 +0000 (18:37 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 10 Oct 2014 17:03:50 +0000 (19:03 +0200)
Sometimes guests are not stopped properly. If images are then modified
they will be corrupted.

testing/scripts/build-baseimage
testing/scripts/build-guestimages
testing/scripts/build-rootimage
testing/scripts/build-strongswan
testing/scripts/function.sh

index 552e98c52fb31de3898096856e5e6de1882a2422..075fd8e1e4334fde7c2eb272f0d36099c0660bc8 100755 (executable)
@@ -7,6 +7,7 @@ DIR=$(dirname `readlink -f $0`)
 . $DIR/function.sh
 
 [ `id -u` -eq 0 ] || die "You must be root to run $0"
+running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0"
 
 check_commands debootstrap mkfs.ext3 partprobe qemu-img qemu-nbd sfdisk
 
index 245fc2524591725582374fff815165fb0edd66a5..3e107c062064837a72ca36adc6fe52c074e65822 100755 (executable)
@@ -25,6 +25,7 @@ HOSTSDIR=$DIR/../hosts
 [ `id -u` -eq 0 ] || die "You must be root to run $0"
 [ -f $ROOTIMG ] || die "Root image $ROOTIMG not found"
 [ -f $HOSTDIR ] || die "Hosts directory $HOSTSDIR not found"
+running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0"
 
 check_commands partprobe qemu-img qemu-nbd
 
index 8e10ce5f3ad7ff39160f2057077fa643ecf4728f..a84104a901aa7b4bd11c4de959b9952f2047fdbd 100755 (executable)
@@ -22,6 +22,7 @@ DIR=$(dirname `readlink -f $0`)
 
 [ `id -u` -eq 0 ] || die "You must be root to run $0"
 [ -f "$BASEIMG" ] || die "Base image $BASEIMG not found"
+running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0"
 
 check_commands partprobe qemu-img qemu-nbd
 
index 69cb833cd39a20261863c0c762f55162248cabde..c52dddda8d749c523577d445ddfd081a8fe11f83 100755 (executable)
@@ -12,6 +12,7 @@ SWANDIR=${1:+$(readlink -f $1)}
 [ `id -u` -eq 0 ] || die "You must be root to run $0"
 [ -f "$BASEIMG" ] || die "Base image $BASEIMG not found"
 [ -f "$ROOTIMG" ] || die "Root image $ROOTIMG not found"
+running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0"
 
 [ -f $SWANDIR/src/libstrongswan/asn1/oid.txt ] || die "strongSwan not found in $SWANDIR"
 
index c4769678c016017b69cdd2f4dce7962d3c4a8595..2dd465c859a97a3752074c20dc944366f7acfd94 100755 (executable)
@@ -156,6 +156,18 @@ check_commands()
        done
 }
 
+# check if any of the given virtual guests are running
+# $* - names of guests to check
+running_any()
+{
+       command -v virsh >/dev/null || return 1
+       for host in $*
+       do
+               virsh list --name | grep "^$host$" >/dev/null && return 0
+       done
+       return 1
+}
+
 #############################################
 # search and replace strings throughout a
 # whole directory