2 # build the hosts configuration directory with the actual IP addresses
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
19 source $DIR/function.sh
21 [ -f $DIR/../testing.conf ] || die "!! Configuration file 'testing.conf' not found"
22 [ -d $DIR/../hosts ] || die "!! Directory 'hosts' not found"
24 source $DIR/../testing.conf
28 cecho " * Creating directory '$BUILDDIR'"
32 ########################################
33 # copy default host configs to $BUILDDIR
36 HOSTCONFIGDIR=${BUILDDIR}/hosts
38 if [ -d $HOSTCONFIGDIR ]
44 cp -rfp ${UMLTESTDIR}/testing/hosts $BUILDDIR
46 cecho " * Copied default host config directory to '$HOSTCONFIGDIR'"
48 ########################################
49 # assign IP for each host to hostname
52 cecho-n " * Generate default config for.."
54 HOSTIP=`ifconfig eth0 |grep inet |sed -e "s/.*inet addr://" -e "s/ Bcast.*//"`
56 for host in $STRONGSWANHOSTS
59 eval ipv4_${host}="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
60 eval ipv6_${host}="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
62 [ "`eval echo \\\$ipv4_${host}`" != "$HOSTIP" ] || die "$host has the same IP as eth0 (Host)! Please change that."
66 eval ipv4_moon1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
67 [ "`eval echo \\\$ipv4_moon1`" != "$HOSTIP" ] || die "eth1 of $host has the same IP as eth0 (Host)! Please change that."
68 searchandreplace PH_IP_MOON1 $ipv4_moon1 $HOSTCONFIGDIR
69 searchandreplace PH_IP_MOON $ipv4_moon $HOSTCONFIGDIR
70 eval ipv6_moon1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
71 searchandreplace PH_IP6_MOON1 $ipv6_moon1 $HOSTCONFIGDIR
72 searchandreplace PH_IP6_MOON $ipv6_moon $HOSTCONFIGDIR
75 eval ipv4_sun1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
76 [ "`eval echo \\\$ipv4_sun1`" != "$HOSTIP" ] || die "eth1 of $host has the same IP as eth0 (Host)! Please change that."
77 searchandreplace PH_IP_SUN1 $ipv4_sun1 $HOSTCONFIGDIR
78 searchandreplace PH_IP_SUN $ipv4_sun $HOSTCONFIGDIR
79 eval ipv6_sun1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
80 searchandreplace PH_IP6_SUN1 $ipv6_sun1 $HOSTCONFIGDIR
81 searchandreplace PH_IP6_SUN $ipv6_sun $HOSTCONFIGDIR
84 eval ipv4_alice1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
85 searchandreplace PH_IP_ALICE1 $ipv4_alice1 $HOSTCONFIGDIR
86 searchandreplace PH_IP_ALICE $ipv4_alice $HOSTCONFIGDIR
87 eval ipv6_alice1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
88 searchandreplace PH_IP6_ALICE1 $ipv6_alice1 $HOSTCONFIGDIR
89 searchandreplace PH_IP6_ALICE $ipv6_alice $HOSTCONFIGDIR
92 searchandreplace PH_IP_VENUS $ipv4_venus $HOSTCONFIGDIR
93 searchandreplace PH_IP6_VENUS $ipv6_venus $HOSTCONFIGDIR
96 searchandreplace PH_IP_BOB $ipv4_bob $HOSTCONFIGDIR
97 searchandreplace PH_IP6_BOB $ipv6_bob $HOSTCONFIGDIR
100 eval ipv4_carol1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
101 searchandreplace PH_IP_CAROL1 $ipv4_carol1 $HOSTCONFIGDIR
102 searchandreplace PH_IP_CAROL $ipv4_carol $HOSTCONFIGDIR
103 eval ipv6_carol1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
104 searchandreplace PH_IP6_CAROL1 $ipv6_carol1 $HOSTCONFIGDIR
105 searchandreplace PH_IP6_CAROL $ipv6_carol $HOSTCONFIGDIR
108 eval ipv4_dave1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
109 searchandreplace PH_IP_DAVE1 $ipv4_dave1 $HOSTCONFIGDIR
110 searchandreplace PH_IP_DAVE $ipv4_dave $HOSTCONFIGDIR
111 eval ipv6_dave1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
112 searchandreplace PH_IP6_DAVE1 $ipv6_dave1 $HOSTCONFIGDIR
113 searchandreplace PH_IP6_DAVE $ipv6_dave $HOSTCONFIGDIR
116 searchandreplace PH_IP_WINNETOU $ipv4_winnetou $HOSTCONFIGDIR
117 searchandreplace PH_IP6_WINNETOU $ipv6_winnetou $HOSTCONFIGDIR