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 . $PWD/scripts/function.sh
23 [ `id -u` -eq 0 ] || die "You must be root to run $0"
24 [ -f $ROOTIMG ] || die "Root image $ROOTIMG not found"
25 [ -f $HOSTDIR ] || die "Hosts directory $HOSTSDIR not found"
27 check_commands partprobe qemu-img qemu-nbd
35 if [ "$#" -eq 0 ]; then
36 HOSTS=$STRONGSWANHOSTS
42 do_on_exit qemu-nbd -d $NBDEV
43 do_on_exit umount $LOOPDIR
47 log_action "Creating guest image for $host"
48 execute "qemu-img create -b $ROOTIMG -f $IMGEXT $GUESTIMGDIR/$host.$IMGEXT" 0
49 execute "qemu-nbd -c $NBDEV $GUESTIMGDIR/$host.$IMGEXT" 0
51 execute "mount $NBDPARTITION $LOOPDIR" 0
52 execute "cp -rf $HOSTSDIR/${host}/etc $LOOPDIR" 0
53 execute "cp -rf $HOSTSDIR/default/* $LOOPDIR" 0
54 if [ "$host" = "winnetou" ]
56 execute "mkdir $LOOPDIR/var/log/apache2/ocsp" 0
57 execute "cp -rf $PWD/images $LOOPDIR/var/www/" 0
58 execute_chroot "ln -s /etc/openssl/certs /var/www/certs" 0
59 execute_chroot "/etc/openssl/generate-crl" 0
60 execute_chroot "update-rc.d apache2 defaults" 0
61 execute_chroot "update-rc.d slapd defaults" 0
62 execute_chroot "rm -rf /var/lib/ldap/*" 0
63 execute_chroot "slapadd -l /etc/ldap/ldif.txt -f /etc/ldap/slapd.conf" 0
64 execute_chroot "chown -R openldap:openldap /var/lib/ldap" 0
67 execute "umount $LOOPDIR" 0
68 execute "qemu-nbd -d $NBDEV" 0