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"
29 check_commands partprobe qemu-img qemu-nbd
37 do_on_exit qemu-nbd -d $NBDEV
38 do_on_exit umount $LOOPDIR
40 for host in $STRONGSWANHOSTS
42 log_action "Creating guest image for $host"
43 execute "qemu-img create -b $ROOTIMG -f $IMGEXT $IMGDIR/$host.$IMGEXT" 0
44 execute "qemu-nbd -c $NBDEV $IMGDIR/$host.$IMGEXT" 0
46 execute "mount $NBDPARTITION $LOOPDIR" 0
47 execute "cp -rf $HOSTSDIR/${host}/etc $LOOPDIR" 0
48 execute "cp -rf $HOSTSDIR/default/* $LOOPDIR" 0
49 execute_chroot "ldconfig" 0
51 if [ "$host" = "winnetou" ]
53 execute "mkdir $LOOPDIR/var/log/apache2/ocsp" 0
54 execute "cp -rf $DIR/../images $LOOPDIR/var/www/" 0
55 execute_chroot "ln -s /etc/openssl/certs /var/www/certs" 0
56 execute_chroot "/etc/openssl/generate-crl" 0
57 execute_chroot "update-rc.d apache2 defaults" 0
58 execute_chroot "update-rc.d slapd defaults" 0
59 execute_chroot "rm -rf /var/lib/ldap/*" 0
60 execute_chroot "slapadd -l /etc/ldap/ldif.txt -f /etc/ldap/slapd.conf" 0
61 execute_chroot "chown -R openldap:openldap /var/lib/ldap" 0
62 execute_chroot "dnssec-signzone -K /etc/bind -o strongswan.org. /etc/bind/db.strongswan.org" 0
63 execute_chroot "dnssec-signzone -K /etc/bind -o org. /etc/bind/db.org" 0
64 execute_chroot "dnssec-signzone -K /etc/bind -o . /etc/bind/db.root" 0
65 execute_chroot "update-rc.d bind9 defaults" 0
68 execute "umount $LOOPDIR" 0
69 execute "qemu-nbd -d $NBDEV" 0