]> git.ipfire.org Git - thirdparty/strongswan.git/blame - testing/scripts/build-certs
testing: Automatically build guest images after generating certificates
[thirdparty/strongswan.git] / testing / scripts / build-certs
CommitLineData
8db01c6a
AS
1#!/bin/bash
2
8db01c6a 3DIR="$(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"
10running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0"
8db01c6a 11
da8e33f3
TB
12SRCUID=${SUDO_UID:-$(id -u)}
13SRCGID=${SUDO_GID:-$(id -g)}
8db01c6a 14
da8e33f3 15check_commands partprobe qemu-img qemu-nbd bindfs
8db01c6a 16
da8e33f3 17load_qemu_nbd
8db01c6a 18
da8e33f3
TB
19mkdir -p $LOOPDIR
20mkdir -p $IMGDIR
8db01c6a 21
da8e33f3
TB
22log_action "Connecting root image to NBD device $NBDEV"
23execute "qemu-nbd -c $NBDEV $ROOTIMG"
24do_on_exit qemu-nbd -d $NBDEV
25partprobe $NBDEV
8db01c6a 26
da8e33f3
TB
27log_action "Mounting $NBDPARTITION to $LOOPDIR"
28execute "mount $NBDPARTITION $LOOPDIR"
29do_on_exit umount $LOOPDIR
8db01c6a 30
da8e33f3
TB
31log_action "Mounting proc filesystem to $LOOPDIR/proc"
32execute "mount -t proc none $LOOPDIR/proc"
33do_on_exit umount $LOOPDIR/proc
00f1d097 34
da8e33f3
TB
35mkdir -p $LOOPDIR/root/testing
36log_action "Mounting ${DIR} as /root/testing"
37execute "bindfs -u $SRCUID -g $SRCGID --create-for-user=$SRCUID --create-for-group=$SRCGID ${DIR} $LOOPDIR/root/testing"
38do_on_exit umount $LOOPDIR/root/testing
00f1d097 39
da8e33f3
TB
40log_action "Building certificates"
41execute_chroot "/root/testing/scripts/build-certs-chroot"
287149cb
TB
42
43# rebuild the guest images to generate the CRLs on winnetou
44if [ -z "$2" ]; then
45 # cleanup before mounting guest images
46 on_exit
47 $DIR/scripts/build-guestimages
48fi