2 # Create UML root filesystem
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"
23 source $DIR/../testing.conf
25 STRONGSWANVERSION=`basename $STRONGSWAN .tar.bz2`
27 cecho-n " * Looking for strongSwan at '$STRONGSWAN'.."
28 if [ -f "$STRONGSWAN" ]
31 cecho " * strongSwan version is '$STRONGSWANVERSION'"
37 cecho-n " * Looking for gentoo root filesystem at '$ROOTFS'.."
46 [ -d $BUILDDIR ] || die "!! Directory '$BUILDDIR' does not exist"
48 HOSTCONFIGDIR=$BUILDDIR/hosts
50 [ -d $HOSTCONFIGDIR ] || die "!! Directory '$HOSTCONFIGDIR' does not exist"
52 LOGFILE=$BUILDDIR/testing.log
56 cecho-n " * Logfile '$LOGFILE' does not exist..creating.."
61 ROOTFSDIR=$BUILDDIR/root-fs
63 if [ ! -d $ROOTFSDIR ]
65 cecho-n " * Root file system directory '$ROOTFSDIR' does not exist..creating.."
72 LOOPDIR=$ROOTFSDIR/loop
79 ######################################################
80 # creating reiser-based uml root filesystem
83 cecho-n " * Building basic root filesystem (gentoo).."
84 dd if=/dev/zero of=gentoo-fs count=$ROOTFSSIZE bs=1M >> $LOGFILE 2>&1
85 mkreiserfs -q -f gentoo-fs >> $LOGFILE 2>&1
86 mount -o loop gentoo-fs $LOOPDIR >> $LOGFILE 2>&1
87 tar xjpf $ROOTFS -C $LOOPDIR >> $LOGFILE 2>&1
90 ######################################################
91 # remove /etc/resolv.conf
93 cecho " * Removing /etc/resolv.conf"
94 rm -f $LOOPDIR/etc/resolv.conf
96 ######################################################
97 # copying default /etc/hosts to the root filesystem
99 cecho " * Copying '$HOSTCONFIGDIR/default/etc/hosts' to the root filesystem"
100 cp -fp $HOSTCONFIGDIR/default/etc/hosts $LOOPDIR/etc/hosts
102 #####################################################
103 # extracting strongSwan into the root filesystem
105 cecho " * Extracting strongSwan into the root filesystem"
106 tar xjf $STRONGSWAN -C $LOOPDIR/root >> $LOGFILE 2>&1
108 ######################################################
109 # setting up mountpoint for shared source tree
111 if [ "${SHAREDTREE+set}" = "set" ]; then
112 cecho " * setting up shared strongswan tree at '$SHAREDTREE'"
113 mkdir $LOOPDIR/root/strongswan-shared
114 echo "" >> $LOOPDIR/etc/fstab
115 echo "none /root/strongswan-shared hostfs $SHAREDTREE" >> $LOOPDIR/etc/fstab
118 ######################################################
119 # installing strongSwan and setting the local timezone
122 INSTALLSHELL=${LOOPDIR}/install.sh
124 cecho " * Preparing strongSwan installation script"
125 echo "ln -sf /usr/share/zoneinfo/${TZUML} /etc/localtime" >> $INSTALLSHELL
127 echo "cd /root/${STRONGSWANVERSION}" >> $INSTALLSHELL
128 echo -n "./configure --sysconfdir=/etc" >> $INSTALLSHELL
129 echo -n " --with-random-device=/dev/urandom" >> $INSTALLSHELL
130 echo -n " --disable-load-warning" >> $INSTALLSHELL
132 if [ "$USE_LIBCURL" = "yes" ]
134 echo -n " --enable-curl" >> $INSTALLSHELL
137 if [ "$USE_LDAP" = "yes" ]
139 echo -n " --enable-ldap" >> $INSTALLSHELL
142 if [ "$USE_EAP_AKA" = "yes" ]
144 echo -n " --enable-eap-aka" >> $INSTALLSHELL
145 echo -n " --enable-eap-aka-3gpp2" >> $INSTALLSHELL
148 if [ "$USE_EAP_SIM" = "yes" ]
150 echo -n " --enable-eap-sim" >> $INSTALLSHELL
151 echo -n " --enable-eap-sim-file" >> $INSTALLSHELL
154 if [ "$USE_EAP_MD5" = "yes" ]
156 echo -n " --enable-eap-md5" >> $INSTALLSHELL
159 if [ "$USE_EAP_MSCHAPV2" = "yes" ]
161 echo -n " --enable-md4" >> $INSTALLSHELL
162 echo -n " --enable-eap-mschapv2" >> $INSTALLSHELL
165 if [ "$USE_EAP_IDENTITY" = "yes" ]
167 echo -n " --enable-eap-identity" >> $INSTALLSHELL
170 if [ "$USE_EAP_RADIUS" = "yes" ]
172 echo -n " --enable-eap-radius" >> $INSTALLSHELL
175 if [ "$USE_EAP_TLS" = "yes" ]
177 echo -n " --enable-eap-tls" >> $INSTALLSHELL
180 if [ "$USE_EAP_TTLS" = "yes" ]
182 echo -n " --enable-eap-ttls" >> $INSTALLSHELL
185 if [ "$USE_EAP_PEAP" = "yes" ]
187 echo -n " --enable-eap-peap" >> $INSTALLSHELL
190 if [ "$USE_EAP_TNC" = "yes" ]
192 echo -n " --enable-eap-tnc" >> $INSTALLSHELL
195 if [ "$USE_TNC_PDP" = "yes" ]
197 echo -n " --enable-tnc-pdp" >> $INSTALLSHELL
200 if [ "$USE_TNC_IMC" = "yes" ]
202 echo -n " --enable-tnc-imc" >> $INSTALLSHELL
205 if [ "$USE_TNC_IMV" = "yes" ]
207 echo -n " --enable-tnc-imv" >> $INSTALLSHELL
210 if [ "$USE_TNCCS_11" = "yes" ]
212 echo -n " --enable-tnccs-11" >> $INSTALLSHELL
215 if [ "$USE_TNCCS_20" = "yes" ]
217 echo -n " --enable-tnccs-20" >> $INSTALLSHELL
220 if [ "$USE_TNCCS_DYNAMIC" = "yes" ]
222 echo -n " --enable-tnccs-dynamic" >> $INSTALLSHELL
225 if [ "$USE_IMC_TEST" = "yes" ]
227 echo -n " --enable-imc-test" >> $INSTALLSHELL
230 if [ "$USE_IMV_TEST" = "yes" ]
232 echo -n " --enable-imv-test" >> $INSTALLSHELL
235 if [ "$USE_IMC_SCANNER" = "yes" ]
237 echo -n " --enable-imc-scanner" >> $INSTALLSHELL
240 if [ "$USE_IMV_SCANNER" = "yes" ]
242 echo -n " --enable-imv-scanner" >> $INSTALLSHELL
245 if [ "$USE_IMC_ATTESTATION" = "yes" ]
247 echo -n " --enable-imc-attestation" >> $INSTALLSHELL
250 if [ "$USE_IMV_ATTESTATION" = "yes" ]
252 echo -n " --enable-imv-attestation" >> $INSTALLSHELL
255 if [ "$USE_SQL" = "yes" ]
257 echo -n " --enable-sql --enable-sqlite" >> $INSTALLSHELL
260 if [ "$USE_MEDIATION" = "yes" ]
262 echo -n " --enable-mediation" >> $INSTALLSHELL
265 if [ "$USE_OPENSSL" = "yes" ]
267 echo -n " --enable-openssl" >> $INSTALLSHELL
270 if [ "$USE_BLOWFISH" = "yes" ]
272 echo -n " --enable-blowfish" >> $INSTALLSHELL
275 if [ "$USE_KERNEL_PFKEY" = "yes" ]
277 echo -n " --enable-kernel-pfkey" >> $INSTALLSHELL
280 if [ "$USE_INTEGRITY_TEST" = "yes" ]
282 echo -n " --enable-integrity-test" >> $INSTALLSHELL
285 if [ "$USE_LEAK_DETECTIVE" = "yes" ]
287 echo -n " --enable-leak-detective" >> $INSTALLSHELL
290 if [ "$USE_LOAD_TESTER" = "yes" ]
292 echo -n " --enable-load-tester" >> $INSTALLSHELL
295 if [ "$USE_TEST_VECTORS" = "yes" ]
297 echo -n " --enable-test-vectors" >> $INSTALLSHELL
300 if [ "$USE_GCRYPT" = "yes" ]
302 echo -n " --enable-gcrypt" >> $INSTALLSHELL
305 if [ "$USE_SOCKET_DEFAULT" = "yes" ]
307 echo -n " --enable-socket-default" >> $INSTALLSHELL
310 if [ "$USE_SOCKET_DYNAMIC" = "yes" ]
312 echo -n " --enable-socket-dynamic" >> $INSTALLSHELL
315 if [ "$USE_DHCP" = "yes" ]
317 echo -n " --enable-dhcp" >> $INSTALLSHELL
320 if [ "$USE_FARP" = "yes" ]
322 echo -n " --enable-farp" >> $INSTALLSHELL
325 if [ "$USE_ADDRBLOCK" = "yes" ]
327 echo -n " --enable-addrblock" >> $INSTALLSHELL
330 if [ "$USE_CTR" = "yes" ]
332 echo -n " --enable-ctr" >> $INSTALLSHELL
335 if [ "$USE_CCM" = "yes" ]
337 echo -n " --enable-ccm" >> $INSTALLSHELL
340 if [ "$USE_GCM" = "yes" ]
342 echo -n " --enable-gcm" >> $INSTALLSHELL
345 if [ "$USE_CMAC" = "yes" ]
347 echo -n " --enable-cmac" >> $INSTALLSHELL
350 if [ "$USE_HA" = "yes" ]
352 echo -n " --enable-ha" >> $INSTALLSHELL
355 if [ "$USE_AF_ALG" = "yes" ]
357 echo -n " --enable-af-alg" >> $INSTALLSHELL
360 if [ "$USE_WHITELIST" = "yes" ]
362 echo -n " --enable-whitelist" >> $INSTALLSHELL
365 if [ "$USE_PKCS8" = "yes" ]
367 echo -n " --enable-pkcs8" >> $INSTALLSHELL
370 if [ "$USE_IFMAP" = "yes" ]
372 echo -n " --enable-tnc-ifmap" >> $INSTALLSHELL
375 if [ "$USE_CISCO_QUIRKS" = "yes" ]
377 echo -n " --enable-cisco-quirks" >> $INSTALLSHELL
380 echo "" >> $INSTALLSHELL
381 echo "make -j" >> $INSTALLSHELL
382 echo "make install" >> $INSTALLSHELL
383 echo "ldconfig" >> $INSTALLSHELL
385 cecho-n " * Compiling $STRONGSWANVERSION within the root file system as chroot.."
386 chroot $LOOPDIR /bin/bash /install.sh >> $LOGFILE 2>&1
390 ######################################################
391 # copying default /etc/ipsec.d/tables.sql to the root filesystem
393 cecho " * Copying '$HOSTCONFIGDIR/default/etc/ipsec.d/tables.sql' to the root filesystem"
394 cp -fp $HOSTCONFIGDIR/default/etc/ipsec.d/tables.sql $LOOPDIR/etc/ipsec.d/tables.sql
396 ######################################################
397 # copying the host's ssh public key
400 if [ ! -d $LOOPDIR/root/.ssh ]
402 mkdir $LOOPDIR/root/.ssh
404 cp ~/.ssh/id_rsa.pub $LOOPDIR/root/.ssh/authorized_keys
406 ######################################################
407 # setup public key based login among all hosts
409 cp $LOOPDIR/etc/ssh/ssh_host_rsa_key $LOOPDIR/root/.ssh/id_rsa
411 for host in $STRONGSWANHOSTS
413 eval ip="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F- '{ print $1 }' | awk '{ print $1 }'`"
414 echo "$host,$ip `cat $HOSTCONFIGDIR/ssh_host_rsa_key.pub`" >> $LOOPDIR/root/.ssh/known_hosts
415 echo "`cat $HOSTCONFIGDIR/ssh_host_rsa_key.pub` root@$host" >> $LOOPDIR/root/.ssh/authorized_keys
418 ######################################################
419 # defining an empty modules.dep
424 mkdir $LOOPDIR/lib/modules/`basename $UMLPATCH .bz2 | sed s/uml-patch-//`um
425 touch $LOOPDIR/lib/modules/`basename $UMLPATCH .bz2 | sed s/uml-patch-//`um/modules.dep
427 mkdir $LOOPDIR/lib/modules/$KERNELVERSION
428 touch $LOOPDIR/lib/modules/$KERNELVERSION/modules.dep