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
17 # RCSID $Id: build-hostconfig,v 1.3 2005/02/08 10:40:48 as Exp $
21 source $DIR/function.sh
23 [ -f $DIR/../testing.conf ] || die "!! Configuration file 'testing.conf' not found"
24 [ -d $DIR/../hosts ] || die "!! Directory 'hosts' not found"
26 source $DIR/../testing.conf
30 cecho " * Creating directory '$BUILDDIR'"
34 ########################################
35 # copy default host configs to $BUILDDIR
38 HOSTCONFIGDIR=${BUILDDIR}/hosts
40 if [ -d $HOSTCONFIGDIR ]
46 cp -rfp ${UMLTESTDIR}/testing/hosts $BUILDDIR
48 cecho " * Copied default host config directory to '$HOSTCONFIGDIR'"
50 ########################################
51 # assign IP for each host to hostname
54 cecho-n " * Generate default config for.."
56 HOSTIP=`ifconfig eth0 |grep inet |sed -e "s/.*inet addr://" -e "s/ Bcast.*//"`
58 for host in $STRONGSWANHOSTS
61 eval ipv4_${host}="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
62 eval ipv6_${host}="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
64 [ "`eval echo \\\$ipv4_${host}`" != "$HOSTIP" ] || die "$host has the same IP as eth0 (Host)! Please change that."
68 eval ipv4_moon1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
69 [ "`eval echo \\\$ipv4_moon1`" != "$HOSTIP" ] || die "eth1 of $host has the same IP as eth0 (Host)! Please change that."
70 searchandreplace PH_IP_MOON1 $ipv4_moon1 $HOSTCONFIGDIR
71 searchandreplace PH_IP_MOON $ipv4_moon $HOSTCONFIGDIR
72 eval ipv6_moon1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
73 searchandreplace PH_IP6_MOON1 $ipv6_moon1 $HOSTCONFIGDIR
74 searchandreplace PH_IP6_MOON $ipv6_moon $HOSTCONFIGDIR
77 eval ipv4_sun1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
78 [ "`eval echo \\\$ipv4_sun1`" != "$HOSTIP" ] || die "eth1 of $host has the same IP as eth0 (Host)! Please change that."
79 searchandreplace PH_IP_SUN1 $ipv4_sun1 $HOSTCONFIGDIR
80 searchandreplace PH_IP_SUN $ipv4_sun $HOSTCONFIGDIR
81 eval ipv6_sun1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
82 searchandreplace PH_IP6_SUN1 $ipv6_sun1 $HOSTCONFIGDIR
83 searchandreplace PH_IP6_SUN $ipv6_sun $HOSTCONFIGDIR
86 eval ipv4_alice1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
87 searchandreplace PH_IP_ALICE1 $ipv4_alice1 $HOSTCONFIGDIR
88 searchandreplace PH_IP_ALICE $ipv4_alice $HOSTCONFIGDIR
89 eval ipv6_alice1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
90 searchandreplace PH_IP6_ALICE1 $ipv6_alice1 $HOSTCONFIGDIR
91 searchandreplace PH_IP6_ALICE $ipv6_alice $HOSTCONFIGDIR
94 searchandreplace PH_IP_VENUS $ipv4_venus $HOSTCONFIGDIR
95 searchandreplace PH_IP6_VENUS $ipv6_venus $HOSTCONFIGDIR
98 searchandreplace PH_IP_BOB $ipv4_bob $HOSTCONFIGDIR
99 searchandreplace PH_IP6_BOB $ipv6_bob $HOSTCONFIGDIR
102 eval ipv4_carol1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
103 searchandreplace PH_IP_CAROL1 $ipv4_carol1 $HOSTCONFIGDIR
104 searchandreplace PH_IP_CAROL $ipv4_carol $HOSTCONFIGDIR
105 eval ipv6_carol1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
106 searchandreplace PH_IP6_CAROL1 $ipv6_carol1 $HOSTCONFIGDIR
107 searchandreplace PH_IP6_CAROL $ipv6_carol $HOSTCONFIGDIR
110 eval ipv4_dave1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
111 searchandreplace PH_IP_DAVE1 $ipv4_dave1 $HOSTCONFIGDIR
112 searchandreplace PH_IP_DAVE $ipv4_dave $HOSTCONFIGDIR
113 eval ipv6_dave1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
114 searchandreplace PH_IP6_DAVE1 $ipv6_dave1 $HOSTCONFIGDIR
115 searchandreplace PH_IP6_DAVE $ipv6_dave $HOSTCONFIGDIR
118 searchandreplace PH_IP_WINNETOU $ipv4_winnetou $HOSTCONFIGDIR
119 searchandreplace PH_IP6_WINNETOU $ipv6_winnetou $HOSTCONFIGDIR