summaryrefslogtreecommitdiff
path: root/testing/scripts/build-umlrootfs
blob: 16dd843b95aee76702239d042e87c7e17e0468ef (plain)
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
#!/bin/bash
# Create UML root filesystem
#
# 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 $0`

source $DIR/function.sh

[ -f $DIR/../testing.conf ] || die "!! Configuration file 'testing.conf' not found"

source $DIR/../testing.conf

STRONGSWANVERSION=`basename $STRONGSWAN .tar.bz2`

cecho-n " * Looking for strongSwan at '$STRONGSWAN'.."
if [ -f "$STRONGSWAN" ]
then
    cecho "found it"
    cecho " * strongSwan version is '$STRONGSWANVERSION'"
else
    cecho "none"
    exit
fi

cecho-n " * Looking for gentoo root filesystem at '$ROOTFS'.."
if [ -f "$ROOTFS" ]
then
    cecho "found it"
else
    cecho "none"
    exit
fi

[ -d $BUILDDIR ] || die "!! Directory '$BUILDDIR' does not exist"

HOSTCONFIGDIR=$BUILDDIR/hosts

[ -d $HOSTCONFIGDIR ] || die "!! Directory '$HOSTCONFIGDIR' does not exist"

LOGFILE=$BUILDDIR/testing.log

if [ ! -f $LOGFILE ]
then
    cecho-n " * Logfile '$LOGFILE' does not exist..creating.."
    touch $LOGFILE
    cgecho "done"
fi

ROOTFSDIR=$BUILDDIR/root-fs

if [ ! -d $ROOTFSDIR ]
then
    cecho-n " * Root file system directory '$ROOTFSDIR' does not exist..creating.."
    mkdir $ROOTFSDIR
    cgecho "done"
fi

cd $ROOTFSDIR

LOOPDIR=$ROOTFSDIR/loop

if [ ! -d $LOOPDIR ]
then
    mkdir $LOOPDIR
fi

######################################################
# creating reiser-based uml root filesystem
#

cecho-n " * Building basic root filesystem (gentoo).."
dd if=/dev/zero of=gentoo-fs count=$ROOTFSSIZE bs=1M >> $LOGFILE 2>&1
mkreiserfs -q -f gentoo-fs       >> $LOGFILE 2>&1
mount -o loop gentoo-fs $LOOPDIR >> $LOGFILE 2>&1
tar xjpf $ROOTFS -C $LOOPDIR     >> $LOGFILE 2>&1
cgecho "done"

######################################################
# remove /etc/resolv.conf
#
cecho " * Removing /etc/resolv.conf"
rm -f $LOOPDIR/etc/resolv.conf

######################################################
# copying default /etc/hosts to the root filesystem
#
cecho " * Copying '$HOSTCONFIGDIR/default/etc/hosts' to the root filesystem"
cp -fp $HOSTCONFIGDIR/default/etc/hosts $LOOPDIR/etc/hosts

#####################################################
# extracting strongSwan into the root filesystem
#
cecho " * Extracting strongSwan into the root filesystem"
tar xjf $STRONGSWAN -C $LOOPDIR/root >> $LOGFILE 2>&1

######################################################
# setting up mountpoint for shared source tree
#
if [ "${SHAREDTREE+set}" = "set" ]; then
    cecho " * setting up shared strongswan tree at '$SHAREDTREE'"
    mkdir $LOOPDIR/root/strongswan-shared
    echo "" >> $LOOPDIR/etc/fstab
    echo "none /root/strongswan-shared hostfs $SHAREDTREE" >> $LOOPDIR/etc/fstab
fi

######################################################
# installing strongSwan and setting the local timezone
#

INSTALLSHELL=${LOOPDIR}/install.sh

cecho " * Preparing strongSwan installation script"
echo "ln -sf /usr/share/zoneinfo/${TZUML} /etc/localtime" >> $INSTALLSHELL

echo "cd /root/${STRONGSWANVERSION}" >> $INSTALLSHELL
echo -n "./configure --sysconfdir=/etc" >> $INSTALLSHELL
echo -n " --with-random-device=/dev/urandom" >> $INSTALLSHELL

if [ "$USE_LIBCURL" = "yes" ]
then
    echo -n " --enable-curl" >> $INSTALLSHELL
fi

if [ "$USE_LDAP" = "yes" ]
then
    echo -n " --enable-ldap" >> $INSTALLSHELL
fi

if [ "$USE_EAP_AKA" = "yes" ]
then
    echo -n " --enable-eap-aka" >> $INSTALLSHELL
    echo -n " --enable-eap-aka-3gpp2" >> $INSTALLSHELL
fi

if [ "$USE_EAP_SIM" = "yes" ]
then
    echo -n " --enable-eap-sim" >> $INSTALLSHELL
    echo -n " --enable-eap-sim-file" >> $INSTALLSHELL
fi

if [ "$USE_EAP_MD5" = "yes" ]
then
    echo -n " --enable-eap-md5" >> $INSTALLSHELL
fi

if [ "$USE_EAP_MSCHAPV2" = "yes" ]
then
    echo -n " --enable-md4" >> $INSTALLSHELL
    echo -n " --enable-eap-mschapv2" >> $INSTALLSHELL
fi

if [ "$USE_EAP_IDENTITY" = "yes" ]
then
    echo -n " --enable-eap-identity" >> $INSTALLSHELL
fi

if [ "$USE_EAP_RADIUS" = "yes" ]
then
    echo -n " --enable-eap-radius" >> $INSTALLSHELL
fi

if [ "$USE_SQL" = "yes" ]
then
    echo -n " --enable-sql --enable-sqlite" >> $INSTALLSHELL
    fi

if [ "$USE_MEDIATION" = "yes" ]
then
    echo -n " --enable-mediation" >> $INSTALLSHELL
fi

if [ "$USE_OPENSSL" = "yes" ]
then
    echo -n " --enable-openssl" >> $INSTALLSHELL
fi

if [ "$USE_BLOWFISH" = "yes" ]
then
    echo -n " --enable-blowfish" >> $INSTALLSHELL
fi

if [ "$USE_KERNEL_PFKEY" = "yes" ]
then
    echo -n " --enable-kernel-pfkey" >> $INSTALLSHELL
fi
  
if [ "$USE_INTEGRITY_TEST" = "yes" ]
then
    echo -n " --enable-integrity-test" >> $INSTALLSHELL
fi

if [ "$USE_LEAK_DETECTIVE" = "yes" ]
then
    echo -n " --enable-leak-detective" >> $INSTALLSHELL
fi

if [ "$USE_LOAD_TESTER" = "yes" ]
then
    echo -n " --enable-load-tester" >> $INSTALLSHELL
fi

if [ "$USE_TEST_VECTORS" = "yes" ]
then
    echo -n " --enable-test-vectors" >> $INSTALLSHELL
fi

if [ "$USE_GCRYPT" = "yes" ]
then
    echo -n " --enable-gcrypt" >> $INSTALLSHELL
fi

if [ "$USE_SOCKET_DEFAULT" = "yes" ]
then
    echo -n " --enable-socket-default" >> $INSTALLSHELL
fi

if [ "$USE_SOCKET_DYNAMIC" = "yes" ]
then
    echo -n " --enable-socket-dynamic" >> $INSTALLSHELL
fi

if [ "$USE_DHCP" = "yes" ]
then
    echo -n " --enable-dhcp" >> $INSTALLSHELL
fi

if [ "$USE_FARP" = "yes" ]
then
    echo -n " --enable-farp" >> $INSTALLSHELL
fi

echo "" >> $INSTALLSHELL
echo "make" >> $INSTALLSHELL
echo "make install" >> $INSTALLSHELL
echo "ldconfig" >> $INSTALLSHELL

cecho-n " * Compiling $STRONGSWANVERSION within the root file system as chroot.."
chroot $LOOPDIR /bin/bash /install.sh >> $LOGFILE 2>&1
rm -f $INSTALLSHELL
cgecho "done"

######################################################
# copying default /etc/ipsec.d/tables.sql to the root filesystem
#
cecho " * Copying '$HOSTCONFIGDIR/default/etc/ipsec.d/tables.sql' to the root filesystem"
cp -fp $HOSTCONFIGDIR/default/etc/ipsec.d/tables.sql $LOOPDIR/etc/ipsec.d/tables.sql

######################################################
# copying the host's ssh public key
#

if [ ! -d $LOOPDIR/root/.ssh ]
then
    mkdir $LOOPDIR/root/.ssh
fi
cp ~/.ssh/id_rsa.pub $LOOPDIR/root/.ssh/authorized_keys

######################################################
# setup public key based login among all hosts
#
cp $LOOPDIR/etc/ssh/ssh_host_rsa_key $LOOPDIR/root/.ssh/id_rsa

for host in $STRONGSWANHOSTS
do
    eval ip="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F- '{ print $1 }' | awk '{ print $1 }'`"
    echo "$host,$ip `cat $HOSTCONFIGDIR/ssh_host_rsa_key.pub`" >> $LOOPDIR/root/.ssh/known_hosts
    echo "`cat $HOSTCONFIGDIR/ssh_host_rsa_key.pub` root@$host" >> $LOOPDIR/root/.ssh/authorized_keys
done

######################################################
# defining an empty modules.dep
#

if [ $UMLPATCH ]
then
    mkdir $LOOPDIR/lib/modules/`basename $UMLPATCH .bz2 | sed s/uml-patch-//`um
    touch $LOOPDIR/lib/modules/`basename $UMLPATCH .bz2 | sed s/uml-patch-//`um/modules.dep
else
    mkdir $LOOPDIR/lib/modules/$KERNELVERSION
    touch $LOOPDIR/lib/modules/$KERNELVERSION/modules.dep
fi

umount $LOOPDIR