]>
Commit | Line | Data |
---|---|---|
997358a6 MW |
1 | #!/bin/bash |
2 | # build the hosts configuration directory with the actual IP addresses | |
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 | # RCSID $Id: build-hostconfig,v 1.3 2005/02/08 10:40:48 as Exp $ | |
18 | ||
19 | DIR=`dirname $0` | |
20 | ||
21 | source $DIR/function.sh | |
22 | ||
23 | [ -f $DIR/../testing.conf ] || die "!! Configuration file 'testing.conf' not found" | |
24 | [ -d $DIR/../hosts ] || die "!! Directory 'hosts' not found" | |
25 | ||
26 | source $DIR/../testing.conf | |
27 | ||
28 | if [ ! -d $BUILDDIR ] | |
29 | then | |
30 | cecho " * Creating directory '$BUILDDIR'" | |
31 | mkdir $BUILDDIR | |
32 | fi | |
33 | ||
34 | ######################################## | |
35 | # copy default host configs to $BUILDDIR | |
36 | # | |
37 | ||
38 | HOSTCONFIGDIR=${BUILDDIR}/hosts | |
39 | ||
40 | if [ -d $HOSTCONFIGDIR ] | |
41 | then | |
42 | rm -r $HOSTCONFIGDIR | |
43 | fi | |
44 | ||
45 | mkdir $HOSTCONFIGDIR | |
46 | cp -rfp ${UMLTESTDIR}/testing/hosts $BUILDDIR | |
47 | ||
48 | cecho " * Copied default host config directory to '$HOSTCONFIGDIR'" | |
49 | ||
50 | ######################################## | |
51 | # assign IP for each host to hostname | |
52 | # | |
53 | ||
54 | cecho-n " * Generate default config for.." | |
55 | ||
56 | HOSTIP=`ifconfig eth0 |grep inet |sed -e "s/.*inet addr://" -e "s/ Bcast.*//"` | |
57 | ||
58 | for host in $STRONGSWANHOSTS | |
59 | do | |
60 | cecho-n "${host}.." | |
61 | eval ip_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $1 }' | awk '{ print $1 }'`" | |
62 | ||
63 | [ "`eval echo \\\$ip_${host}`" != "$HOSTIP" ] || die "$host has the same IP as eth0 (Host)! Please change that." | |
64 | ||
65 | case $host in | |
66 | moon) | |
67 | eval ip1_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $2 }' | awk '{ print $1 }'`" | |
68 | [ "`eval echo \\\$ip1_${host}`" != "$HOSTIP" ] || die "eth1 of $host has the same IP as eth0 (Host)! Please change that." | |
69 | searchandreplace PH_IP_MOON $ip_moon $HOSTCONFIGDIR | |
70 | searchandreplace PH_IP1_MOON $ip1_moon $HOSTCONFIGDIR | |
71 | ;; | |
72 | sun) | |
73 | eval ip1_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $2 }' | awk '{ print $1 }'`" | |
74 | [ "`eval echo \\\$ip1_${host}`" != "$HOSTIP" ] || die "eth1 of $host has the same IP as eth0 (Host)! Please change that." | |
75 | searchandreplace PH_IP_SUN $ip_sun $HOSTCONFIGDIR | |
76 | searchandreplace PH_IP1_SUN $ip1_sun $HOSTCONFIGDIR | |
77 | ;; | |
78 | alice) | |
79 | searchandreplace PH_IP_ALICE $ip_alice $HOSTCONFIGDIR | |
80 | ;; | |
81 | venus) | |
82 | searchandreplace PH_IP_VENUS $ip_venus $HOSTCONFIGDIR | |
83 | ;; | |
84 | bob) | |
85 | searchandreplace PH_IP_BOB $ip_bob $HOSTCONFIGDIR | |
86 | ;; | |
87 | carol) | |
88 | eval ip1_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $2 }' | awk '{ print $1 }'`" | |
89 | searchandreplace PH_IP_CAROL $ip_carol $HOSTCONFIGDIR | |
90 | searchandreplace PH_IP1_CAROL $ip1_carol $HOSTCONFIGDIR | |
91 | ;; | |
92 | dave) | |
93 | eval ip1_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $2 }' | awk '{ print $1 }'`" | |
94 | searchandreplace PH_IP_DAVE $ip_dave $HOSTCONFIGDIR | |
95 | searchandreplace PH_IP1_DAVE $ip1_dave $HOSTCONFIGDIR | |
96 | ;; | |
97 | winnetou) | |
98 | searchandreplace PH_IP_WINNETOU $ip_winnetou $HOSTCONFIGDIR | |
99 | ;; | |
100 | esac | |
101 | done | |
102 | ||
103 | cecho "done" |