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_TNC" = "yes" ]
187 echo -n " --enable-eap-tnc" >> $INSTALLSHELL
190 if [ "$USE_TNC_IMC" = "yes" ]
192 echo -n " --enable-tnc-imc" >> $INSTALLSHELL
195 if [ "$USE_TNC_IMV" = "yes" ]
197 echo -n " --enable-tnc-imv" >> $INSTALLSHELL
200 if [ "$USE_TNCCS_11" = "yes" ]
202 echo -n " --enable-tnccs-11" >> $INSTALLSHELL
205 if [ "$USE_TNCCS_20" = "yes" ]
207 echo -n " --enable-tnccs-20" >> $INSTALLSHELL
210 if [ "$USE_TNCCS_DYNAMIC" = "yes" ]
212 echo -n " --enable-tnccs-dynamic" >> $INSTALLSHELL
215 if [ "$USE_SQL" = "yes" ]
217 echo -n " --enable-sql --enable-sqlite" >> $INSTALLSHELL
220 if [ "$USE_MEDIATION" = "yes" ]
222 echo -n " --enable-mediation" >> $INSTALLSHELL
225 if [ "$USE_OPENSSL" = "yes" ]
227 echo -n " --enable-openssl" >> $INSTALLSHELL
230 if [ "$USE_BLOWFISH" = "yes" ]
232 echo -n " --enable-blowfish" >> $INSTALLSHELL
235 if [ "$USE_KERNEL_PFKEY" = "yes" ]
237 echo -n " --enable-kernel-pfkey" >> $INSTALLSHELL
240 if [ "$USE_INTEGRITY_TEST" = "yes" ]
242 echo -n " --enable-integrity-test" >> $INSTALLSHELL
245 if [ "$USE_LEAK_DETECTIVE" = "yes" ]
247 echo -n " --enable-leak-detective" >> $INSTALLSHELL
250 if [ "$USE_LOAD_TESTER" = "yes" ]
252 echo -n " --enable-load-tester" >> $INSTALLSHELL
255 if [ "$USE_TEST_VECTORS" = "yes" ]
257 echo -n " --enable-test-vectors" >> $INSTALLSHELL
260 if [ "$USE_GCRYPT" = "yes" ]
262 echo -n " --enable-gcrypt" >> $INSTALLSHELL
265 if [ "$USE_SOCKET_DEFAULT" = "yes" ]
267 echo -n " --enable-socket-default" >> $INSTALLSHELL
270 if [ "$USE_SOCKET_DYNAMIC" = "yes" ]
272 echo -n " --enable-socket-dynamic" >> $INSTALLSHELL
275 if [ "$USE_DHCP" = "yes" ]
277 echo -n " --enable-dhcp" >> $INSTALLSHELL
280 if [ "$USE_FARP" = "yes" ]
282 echo -n " --enable-farp" >> $INSTALLSHELL
285 if [ "$USE_ADDRBLOCK" = "yes" ]
287 echo -n " --enable-addrblock" >> $INSTALLSHELL
290 if [ "$USE_CTR" = "yes" ]
292 echo -n " --enable-ctr" >> $INSTALLSHELL
295 if [ "$USE_CCM" = "yes" ]
297 echo -n " --enable-ccm" >> $INSTALLSHELL
300 if [ "$USE_GCM" = "yes" ]
302 echo -n " --enable-gcm" >> $INSTALLSHELL
305 if [ "$USE_HA" = "yes" ]
307 echo -n " --enable-ha" >> $INSTALLSHELL
310 if [ "$USE_CISCO_QUIRKS" = "yes" ]
312 echo -n " --enable-cisco-quirks" >> $INSTALLSHELL
315 echo "" >> $INSTALLSHELL
316 echo "make -j" >> $INSTALLSHELL
317 echo "make install" >> $INSTALLSHELL
318 echo "ldconfig" >> $INSTALLSHELL
320 cecho-n " * Compiling $STRONGSWANVERSION within the root file system as chroot.."
321 chroot $LOOPDIR /bin/bash /install.sh >> $LOGFILE 2>&1
325 ######################################################
326 # copying default /etc/ipsec.d/tables.sql to the root filesystem
328 cecho " * Copying '$HOSTCONFIGDIR/default/etc/ipsec.d/tables.sql' to the root filesystem"
329 cp -fp $HOSTCONFIGDIR/default/etc/ipsec.d/tables.sql $LOOPDIR/etc/ipsec.d/tables.sql
331 ######################################################
332 # copying the host's ssh public key
335 if [ ! -d $LOOPDIR/root/.ssh ]
337 mkdir $LOOPDIR/root/.ssh
339 cp ~/.ssh/id_rsa.pub $LOOPDIR/root/.ssh/authorized_keys
341 ######################################################
342 # setup public key based login among all hosts
344 cp $LOOPDIR/etc/ssh/ssh_host_rsa_key $LOOPDIR/root/.ssh/id_rsa
346 for host in $STRONGSWANHOSTS
348 eval ip="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F- '{ print $1 }' | awk '{ print $1 }'`"
349 echo "$host,$ip `cat $HOSTCONFIGDIR/ssh_host_rsa_key.pub`" >> $LOOPDIR/root/.ssh/known_hosts
350 echo "`cat $HOSTCONFIGDIR/ssh_host_rsa_key.pub` root@$host" >> $LOOPDIR/root/.ssh/authorized_keys
353 ######################################################
354 # defining an empty modules.dep
359 mkdir $LOOPDIR/lib/modules/`basename $UMLPATCH .bz2 | sed s/uml-patch-//`um
360 touch $LOOPDIR/lib/modules/`basename $UMLPATCH .bz2 | sed s/uml-patch-//`um/modules.dep
362 mkdir $LOOPDIR/lib/modules/$KERNELVERSION
363 touch $LOOPDIR/lib/modules/$KERNELVERSION/modules.dep