File: load-testconfig

package info (click to toggle)
strongswan 6.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 61,584 kB
  • sloc: ansic: 405,188; sh: 11,621; makefile: 6,254; sql: 2,885; javascript: 1,948; python: 990; xml: 608; perl: 586; cs: 522; lex: 485; yacc: 443; ruby: 398; ada: 114
file content (176 lines) | stat: -rwxr-xr-x 5,908 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/bin/bash
# Load test specific host configurations
#
# Copyright (C) 2004  Eric Marchionni, Patrik Rayo
# Zuercher Hochschule Winterthur
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.

DIR=$(dirname `readlink -f $0`)
. $DIR/../testing.conf
. $DIR/function.sh
SSHCONF="-F $DIR/../ssh_config"

set -e

##########################################################################
# load-testconfig requires a testname as an argument
#

testname=$1

DEFAULTTESTSDIR=$DIR/../tests

[ -d $DEFAULTTESTSDIR ] || die "Directory 'tests' not found"
[ -d $DEFAULTTESTSDIR/$testname ] || die "Test '$testname' not found"
[ -f $DEFAULTTESTSDIR/$testname/test.conf ] || die "File 'test.conf' is missing"

TESTSDIR=$BUILDDIR/tests
[ -d $TESTSDIR ] || mkdir $TESTSDIR

TESTDIR=$TESTSDIR/${testname}
rm -rf $TESTDIR
mkdir -p $TESTDIR
cp -rfp $DEFAULTTESTSDIR/${testname}/* $TESTDIR

##############################################################################
# assign IP for each host to hostname
#

for host in $STRONGSWANHOSTS
do
	eval ipv4_${host}="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
	eval ipv6_${host}="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"

	case $host in
	moon)
		eval ipv4_moon1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
		eval ipv6_moon1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
		;;
	sun)
		eval ipv4_sun1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
		eval ipv6_sun1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
		;;
	alice)
		eval ipv4_alice1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
		eval ipv6_alice1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
		;;
	venus)
		;;
	bob)
		;;
	carol)
		eval ipv4_carol1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
		eval ipv6_carol1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
		;;
	dave)
		eval ipv4_dave1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
		eval ipv6_dave1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
		;;
	winnetou)
		;;
	esac
done

##############################################################################
# replace IP wildcards with actual IPv4 and IPv6 addresses
#

for host in $STRONGSWANHOSTS
do
	case $host in
	moon)
		searchandreplace PH_IP_MOON1     $ipv4_moon1 $TESTDIR
		searchandreplace PH_IP_MOON      $ipv4_moon  $TESTDIR
		searchandreplace PH_IP6_MOON1    $ipv6_moon1 $TESTDIR
		searchandreplace PH_IP6_MOON     $ipv6_moon  $TESTDIR
		;;
	sun)
		searchandreplace PH_IP_SUN1      $ipv4_sun1 $TESTDIR
		searchandreplace PH_IP_SUN       $ipv4_sun  $TESTDIR
		searchandreplace PH_IP6_SUN1     $ipv6_sun1 $TESTDIR
		searchandreplace PH_IP6_SUN      $ipv6_sun  $TESTDIR
		;;
	alice)
		searchandreplace PH_IP_ALICE1    $ipv4_alice1 $TESTDIR
		searchandreplace PH_IP_ALICE     $ipv4_alice  $TESTDIR
		searchandreplace PH_IP6_ALICE1   $ipv6_alice1 $TESTDIR
		searchandreplace PH_IP6_ALICE    $ipv6_alice  $TESTDIR
		;;
	venus)
		searchandreplace PH_IP_VENUS     $ipv4_venus $TESTDIR
		searchandreplace PH_IP6_VENUS    $ipv6_venus $TESTDIR
		;;
	bob)
		searchandreplace PH_IP_BOB       $ipv4_bob $TESTDIR
		searchandreplace PH_IPV6_BOB     $ipv6_bob $TESTDIR
		;;
	carol)
		searchandreplace PH_IP_CAROL1    $ipv4_carol1 $TESTDIR
		searchandreplace PH_IP_CAROL     $ipv4_carol  $TESTDIR
		searchandreplace PH_IP6_CAROL1   $ipv6_carol1 $TESTDIR
		searchandreplace PH_IP6_CAROL    $ipv6_carol  $TESTDIR
		;;
	dave)
		searchandreplace PH_IP_DAVE1     $ipv4_dave1 $TESTDIR
		searchandreplace PH_IP_DAVE      $ipv4_dave  $TESTDIR
		searchandreplace PH_IP6_DAVE1    $ipv6_dave1 $TESTDIR
		searchandreplace PH_IP6_DAVE     $ipv6_dave  $TESTDIR
		;;
	winnetou)
		searchandreplace PH_IP_WINNETOU  $ipv4_winnetou $TESTDIR
		searchandreplace PH_IP6_WINNETOU $ipv6_winnetou $TESTDIR
		;;
	esac
done

source $TESTDIR/test.conf

##########################################################################
# copy test specific configurations to hosts
#

WAIT_FOR=()

if [ -d $TESTDIR/hosts ]
then
	for host in `ls $TESTDIR/hosts`
	do
		eval HOSTLOGIN=root@\$ipv4_${host}
		tar -chf - -C $TESTDIR/hosts/$host etc | ssh $SSHCONF $HOSTLOGIN 'tar --overwrite -xhmf - -C /' &
		WAIT_FOR+=($!)
	done
	wait ${WAIT_FOR[@]}
fi


##########################################################################
# clear auth.log and daemon.log where IKE messages are logged
#

for host in $IPSECHOSTS
do
	eval HOSTLOGIN=root@\$ipv4_${host}
	ssh $SSHCONF $HOSTLOGIN 'rm -f /var/log/auth.log /var/log/daemon.log; \
			pkill -SIGHUP rsyslogd' > /dev/null 2>&1
done


##########################################################################
# clear daemon.log and radius.log on FreeRadius servers
#

for host in $RADIUSHOSTS
do
	eval HOSTLOGIN=root@\$ipv4_${host}
	ssh $SSHCONF $HOSTLOGIN 'rm -f /var/log/daemon.log /var/log/freeradius/radius.log; \
			pkill -SIGHUP rsyslogd' > /dev/null 2>&1
done