2 # create specific guest images
4 # Copyright (C) 2004 Eric Marchionni, Patrik Rayo
5 # Zuercher Hochschule Winterthur
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the
9 # Free Software Foundation; either version 2 of the License, or (at your
10 # option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 echo "Creating guest images"
19 DIR
=$
(dirname `readlink -f $0`)
20 .
$DIR/..
/testing.conf
23 HOSTSDIR
=$DIR/..
/hosts
25 [ `id -u` -eq 0 ] || die
"You must be root to run $0"
26 [ -f $ROOTIMG ] || die
"Root image $ROOTIMG not found"
27 [ -f $HOSTDIR ] || die
"Hosts directory $HOSTSDIR not found"
28 running_any
$STRONGSWANHOSTS && die
"Please stop test environment before running $0"
30 check_commands partprobe qemu-img qemu-nbd
38 do_on_exit qemu-nbd
-d $NBDEV
39 do_on_exit umount
$LOOPDIR
41 for host in $STRONGSWANHOSTS
43 log_action
"Creating guest image for $host"
44 execute
"qemu-img create -b $ROOTIMG -f $IMGEXT $IMGDIR/$host.$IMGEXT" 0
45 execute
"qemu-nbd -c $NBDEV $IMGDIR/$host.$IMGEXT" 0
47 execute
"mount $NBDPARTITION $LOOPDIR" 0
48 execute
"cp -rf $HOSTSDIR/${host}/etc $LOOPDIR" 0
49 execute
"cp -rf $HOSTSDIR/default/* $LOOPDIR" 0
50 execute_chroot
"ldconfig" 0
51 execute
"mkdir $LOOPDIR/etc/pts" 0
53 if [ "$host" = "alice" ]
55 execute
"mkdir $LOOPDIR/var/log/apache2/tnc" 0
56 execute_chroot
"chgrp www-data /etc/pts" 0
57 execute_chroot
"chmod g+w /etc/pts" 0
59 if [ "$host" = "winnetou" ]
61 execute
"mkdir $LOOPDIR/var/log/apache2/ocsp" 0
62 execute
"cp -rf $DIR/../images $LOOPDIR/var/www/" 0
63 execute
"mkdir $LOOPDIR/var/www/testresults" 0
64 echo "echo /testresults ... >> $LOOPDIR/etc/fstab" >>$LOGFILE 2>&1
65 echo "/testresults /var/www/testresults 9p trans=virtio,version=9p2000.L 0 0" >> $LOOPDIR/etc
/fstab
66 execute_chroot
"a2enmod -q cgid" 0
67 execute_chroot
"a2enmod -q rewrite" 0
68 execute_chroot
"ln -s /etc/openssl/certs /var/www/certs" 0
69 execute_chroot
"/etc/openssl/generate-crl" 0
70 execute_chroot
"rm -rf /var/lib/ldap/*" 0
71 execute_chroot
"slapadd -l /etc/ldap/ldif.txt -f /etc/ldap/slapd.conf" 0
72 execute_chroot
"chown -R openldap:openldap /var/lib/ldap" 0
73 execute_chroot
"dnssec-signzone -K /etc/bind -o strongswan.org. /etc/bind/db.strongswan.org" 0
74 execute_chroot
"dnssec-signzone -K /etc/bind -o org. /etc/bind/db.org" 0
75 execute_chroot
"dnssec-signzone -K /etc/bind -o . /etc/bind/db.root" 0
77 for service
in "apache2 slapd bind9"
79 execute_chroot
"systemctl enable $service" 0
83 execute
"umount -l $LOOPDIR" 0
84 execute
"qemu-nbd -d $NBDEV" 0