Annotation of embedaddon/strongswan/testing/scripts/load-testconfig, revision 1.1
1.1 ! misho 1: #!/bin/bash
! 2: # Load test specific host configurations
! 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: DIR=$(dirname `readlink -f $0`)
! 18: . $DIR/../testing.conf
! 19: . $DIR/function.sh
! 20: SSHCONF="-F $DIR/../ssh_config"
! 21:
! 22: ##########################################################################
! 23: # load-testconfig requires a testname as an argument
! 24: #
! 25:
! 26: testname=$1
! 27:
! 28: DEFAULTTESTSDIR=$DIR/../tests
! 29:
! 30: [ -d $DEFAULTTESTSDIR ] || die "Directory 'tests' not found"
! 31: [ -d $DEFAULTTESTSDIR/$testname ] || die "Test '$testname' not found"
! 32: [ -f $DEFAULTTESTSDIR/$testname/test.conf ] || die "File 'test.conf' is missing"
! 33:
! 34: TESTSDIR=$BUILDDIR/tests
! 35: [ -d $TESTSDIR ] || mkdir $TESTSDIR
! 36:
! 37: TESTDIR=$TESTSDIR/${testname}
! 38: rm -rf $TESTDIR
! 39: mkdir -p $TESTDIR
! 40: cp -rfp $DEFAULTTESTSDIR/${testname}/* $TESTDIR
! 41:
! 42: ##############################################################################
! 43: # assign IP for each host to hostname
! 44: #
! 45:
! 46: for host in $STRONGSWANHOSTS
! 47: do
! 48: eval ipv4_${host}="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
! 49: eval ipv6_${host}="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
! 50:
! 51: case $host in
! 52: moon)
! 53: eval ipv4_moon1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
! 54: eval ipv6_moon1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
! 55: ;;
! 56: sun)
! 57: eval ipv4_sun1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
! 58: eval ipv6_sun1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
! 59: ;;
! 60: alice)
! 61: eval ipv4_alice1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
! 62: eval ipv6_alice1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
! 63: ;;
! 64: venus)
! 65: ;;
! 66: bob)
! 67: ;;
! 68: carol)
! 69: eval ipv4_carol1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
! 70: eval ipv6_carol1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
! 71: ;;
! 72: dave)
! 73: eval ipv4_dave1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
! 74: eval ipv6_dave1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
! 75: ;;
! 76: winnetou)
! 77: ;;
! 78: esac
! 79: done
! 80:
! 81: ##############################################################################
! 82: # replace IP wildcards with actual IPv4 and IPv6 addresses
! 83: #
! 84:
! 85: for host in $STRONGSWANHOSTS
! 86: do
! 87: case $host in
! 88: moon)
! 89: searchandreplace PH_IP_MOON1 $ipv4_moon1 $TESTDIR
! 90: searchandreplace PH_IP_MOON $ipv4_moon $TESTDIR
! 91: searchandreplace PH_IP6_MOON1 $ipv6_moon1 $TESTDIR
! 92: searchandreplace PH_IP6_MOON $ipv6_moon $TESTDIR
! 93: ;;
! 94: sun)
! 95: searchandreplace PH_IP_SUN1 $ipv4_sun1 $TESTDIR
! 96: searchandreplace PH_IP_SUN $ipv4_sun $TESTDIR
! 97: searchandreplace PH_IP6_SUN1 $ipv6_sun1 $TESTDIR
! 98: searchandreplace PH_IP6_SUN $ipv6_sun $TESTDIR
! 99: ;;
! 100: alice)
! 101: searchandreplace PH_IP_ALICE1 $ipv4_alice1 $TESTDIR
! 102: searchandreplace PH_IP_ALICE $ipv4_alice $TESTDIR
! 103: searchandreplace PH_IP6_ALICE1 $ipv6_alice1 $TESTDIR
! 104: searchandreplace PH_IP6_ALICE $ipv6_alice $TESTDIR
! 105: ;;
! 106: venus)
! 107: searchandreplace PH_IP_VENUS $ipv4_venus $TESTDIR
! 108: searchandreplace PH_IP6_VENUS $ipv6_venus $TESTDIR
! 109: ;;
! 110: bob)
! 111: searchandreplace PH_IP_BOB $ipv4_bob $TESTDIR
! 112: searchandreplace PH_IPV6_BOB $ipv6_bob $TESTDIR
! 113: ;;
! 114: carol)
! 115: searchandreplace PH_IP_CAROL1 $ipv4_carol1 $TESTDIR
! 116: searchandreplace PH_IP_CAROL $ipv4_carol $TESTDIR
! 117: searchandreplace PH_IP6_CAROL1 $ipv6_carol1 $TESTDIR
! 118: searchandreplace PH_IP6_CAROL $ipv6_carol $TESTDIR
! 119: ;;
! 120: dave)
! 121: searchandreplace PH_IP_DAVE1 $ipv4_dave1 $TESTDIR
! 122: searchandreplace PH_IP_DAVE $ipv4_dave $TESTDIR
! 123: searchandreplace PH_IP6_DAVE1 $ipv6_dave1 $TESTDIR
! 124: searchandreplace PH_IP6_DAVE $ipv6_dave $TESTDIR
! 125: ;;
! 126: winnetou)
! 127: searchandreplace PH_IP_WINNETOU $ipv4_winnetou $TESTDIR
! 128: searchandreplace PH_IP6_WINNETOU $ipv6_winnetou $TESTDIR
! 129: ;;
! 130: esac
! 131: done
! 132:
! 133: source $TESTDIR/test.conf
! 134:
! 135: ##########################################################################
! 136: # copy test specific configurations to uml hosts
! 137: #
! 138:
! 139: if [ -d $TESTDIR/hosts ]
! 140: then
! 141: for host in `ls $TESTDIR/hosts`
! 142: do
! 143: eval HOSTLOGIN=root@\$ipv4_${host}
! 144: scp $SSHCONF -r $TESTDIR/hosts/$host/etc $HOSTLOGIN:/ > /dev/null 2>&1
! 145: done
! 146: fi
! 147:
! 148:
! 149: ##########################################################################
! 150: # clear auth.log and daemon.log where IKE messages are logged
! 151: #
! 152:
! 153: for host in $IPSECHOSTS
! 154: do
! 155: eval HOSTLOGIN=root@\$ipv4_${host}
! 156: ssh $SSHCONF $HOSTLOGIN 'rm -f /var/log/auth.log /var/log/daemon.log; \
! 157: kill -SIGHUP `cat /var/run/rsyslogd.pid`' > /dev/null 2>&1
! 158: done
! 159:
! 160:
! 161: ##########################################################################
! 162: # clear daemon.log and radius.log on FreeRadius servers
! 163: #
! 164:
! 165: for host in $RADIUSHOSTS
! 166: do
! 167: eval HOSTLOGIN=root@\$ipv4_${host}
! 168: ssh $SSHCONF $HOSTLOGIN 'rm -f /var/log/daemon.log /var/log/freeradius/radius.log; \
! 169: kill -SIGHUP `cat /var/run/rsyslogd.pid`' > /dev/null 2>&1
! 170: done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>