]>
Commit | Line | Data |
---|---|---|
8db01c6a AS |
1 | #!/bin/bash |
2 | ||
8db01c6a | 3 | DIR="$(dirname `readlink -f $0`)/.." |
da8e33f3 TB |
4 | . $DIR/testing.conf |
5 | . $DIR/scripts/function.sh | |
8db01c6a | 6 | |
da8e33f3 TB |
7 | [ `id -u` -eq 0 ] || die "You must be root to run $0" |
8 | [ -f "$BASEIMG" ] || die "Base image $BASEIMG not found" | |
9 | [ -f "$ROOTIMG" ] || die "Root image $ROOTIMG not found" | |
10 | running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0" | |
8db01c6a | 11 | |
da8e33f3 TB |
12 | SRCUID=${SUDO_UID:-$(id -u)} |
13 | SRCGID=${SUDO_GID:-$(id -g)} | |
8db01c6a | 14 | |
da8e33f3 | 15 | check_commands partprobe qemu-img qemu-nbd bindfs |
8db01c6a | 16 | |
da8e33f3 | 17 | load_qemu_nbd |
8db01c6a | 18 | |
da8e33f3 TB |
19 | mkdir -p $LOOPDIR |
20 | mkdir -p $IMGDIR | |
8db01c6a | 21 | |
da8e33f3 TB |
22 | log_action "Connecting root image to NBD device $NBDEV" |
23 | execute "qemu-nbd -c $NBDEV $ROOTIMG" | |
24 | do_on_exit qemu-nbd -d $NBDEV | |
25 | partprobe $NBDEV | |
8db01c6a | 26 | |
da8e33f3 TB |
27 | log_action "Mounting $NBDPARTITION to $LOOPDIR" |
28 | execute "mount $NBDPARTITION $LOOPDIR" | |
29 | do_on_exit umount $LOOPDIR | |
8db01c6a | 30 | |
da8e33f3 TB |
31 | log_action "Mounting proc filesystem to $LOOPDIR/proc" |
32 | execute "mount -t proc none $LOOPDIR/proc" | |
33 | do_on_exit umount $LOOPDIR/proc | |
00f1d097 | 34 | |
da8e33f3 TB |
35 | mkdir -p $LOOPDIR/root/testing |
36 | log_action "Mounting ${DIR} as /root/testing" | |
37 | execute "bindfs -u $SRCUID -g $SRCGID --create-for-user=$SRCUID --create-for-group=$SRCGID ${DIR} $LOOPDIR/root/testing" | |
38 | do_on_exit umount $LOOPDIR/root/testing | |
00f1d097 | 39 | |
da8e33f3 TB |
40 | log_action "Building certificates" |
41 | execute_chroot "/root/testing/scripts/build-certs-chroot" | |
287149cb TB |
42 | |
43 | # rebuild the guest images to generate the CRLs on winnetou | |
44 | if [ -z "$2" ]; then | |
45 | # cleanup before mounting guest images | |
46 | on_exit | |
47 | $DIR/scripts/build-guestimages | |
48 | fi |