Annotation of embedaddon/strongswan/testing/scripts/build-guestimages, revision 1.1

1.1     ! misho       1: #!/bin/bash
        !             2: # create specific guest images
        !             3: #
        !             4: # Copyright (C) 2004  Eric Marchionni, Patrik Rayo
        !             5: # Zuercher Hochschule Winterthur
        !             6: #
        !             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>.
        !            11: #
        !            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
        !            15: # for more details.
        !            16: 
        !            17: echo "Creating guest images"
        !            18: 
        !            19: DIR=$(dirname `readlink -f $0`)
        !            20: . $DIR/../testing.conf
        !            21: . $DIR/function.sh
        !            22: 
        !            23: HOSTSDIR=$DIR/../hosts
        !            24: 
        !            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"
        !            29: 
        !            30: check_commands partprobe qemu-img qemu-nbd
        !            31: 
        !            32: load_qemu_nbd
        !            33: 
        !            34: mkdir -p $IMGDIR
        !            35: mkdir -p $LOOPDIR
        !            36: 
        !            37: # just to be sure
        !            38: do_on_exit qemu-nbd -d $NBDEV
        !            39: do_on_exit umount $LOOPDIR
        !            40: 
        !            41: for host in $STRONGSWANHOSTS
        !            42: do
        !            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
        !            46:        partprobe $NBDEV
        !            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
        !            52: 
        !            53:        if [ "$host" = "alice" ]
        !            54:        then
        !            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
        !            58:        fi
        !            59:        if [ "$host" = "winnetou" ]
        !            60:        then
        !            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 "mkdir /var/www/certs" 0
        !            69:                execute_chroot "mkdir /var/www/certs/research /var/www/certs/sales" 0
        !            70:                execute_chroot "/etc/ca/generate-crl" 0
        !            71:                execute_chroot "rm -rf /var/lib/ldap/*" 0
        !            72:                execute_chroot "slapadd -l /etc/ldap/ldif.txt -f /etc/ldap/slapd.conf" 0
        !            73:                execute_chroot "chown -R openldap:openldap /var/lib/ldap" 0
        !            74:                execute_chroot "dnssec-signzone -K /etc/bind -o strongswan.org. /etc/bind/db.strongswan.org" 0
        !            75:                execute_chroot "dnssec-signzone -K /etc/bind -o org. /etc/bind/db.org" 0
        !            76:                execute_chroot "dnssec-signzone -K /etc/bind -o . /etc/bind/db.root" 0
        !            77: 
        !            78:                for service in "apache2 slapd bind9"
        !            79:                do
        !            80:                        execute_chroot "systemctl enable $service" 0
        !            81:                done
        !            82:        fi
        !            83:        sync
        !            84:        execute "umount -l $LOOPDIR" 0
        !            85:        execute "qemu-nbd -d $NBDEV" 0
        !            86:        log_status 0
        !            87: done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>