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
131 if [ "$USE_LIBCURL" = "yes" ]
133 echo -n " --enable-curl" >> $INSTALLSHELL
136 if [ "$USE_LDAP" = "yes" ]
138 echo -n " --enable-ldap" >> $INSTALLSHELL
141 if [ "$USE_EAP_AKA" = "yes" ]
143 echo -n " --enable-eap-aka" >> $INSTALLSHELL
144 echo -n " --enable-eap-aka-3gpp2" >> $INSTALLSHELL
147 if [ "$USE_EAP_SIM" = "yes" ]
149 echo -n " --enable-eap-sim" >> $INSTALLSHELL
150 echo -n " --enable-eap-sim-file" >> $INSTALLSHELL
153 if [ "$USE_EAP_MD5" = "yes" ]
155 echo -n " --enable-eap-md5" >> $INSTALLSHELL
158 if [ "$USE_EAP_MSCHAPV2" = "yes" ]
160 echo -n " --enable-md4" >> $INSTALLSHELL
161 echo -n " --enable-eap-mschapv2" >> $INSTALLSHELL
164 if [ "$USE_EAP_IDENTITY" = "yes" ]
166 echo -n " --enable-eap-identity" >> $INSTALLSHELL
169 if [ "$USE_EAP_RADIUS" = "yes" ]
171 echo -n " --enable-eap-radius" >> $INSTALLSHELL
174 if [ "$USE_SQL" = "yes" ]
176 echo -n " --enable-sql --enable-sqlite" >> $INSTALLSHELL
179 if [ "$USE_MEDIATION" = "yes" ]
181 echo -n " --enable-mediation" >> $INSTALLSHELL
184 if [ "$USE_OPENSSL" = "yes" ]
186 echo -n " --enable-openssl" >> $INSTALLSHELL
189 if [ "$USE_BLOWFISH" = "yes" ]
191 echo -n " --enable-blowfish" >> $INSTALLSHELL
194 if [ "$USE_KERNEL_PFKEY" = "yes" ]
196 echo -n " --enable-kernel-pfkey" >> $INSTALLSHELL
199 if [ "$USE_INTEGRITY_TEST" = "yes" ]
201 echo -n " --enable-integrity-test" >> $INSTALLSHELL
204 if [ "$USE_LEAK_DETECTIVE" = "yes" ]
206 echo -n " --enable-leak-detective" >> $INSTALLSHELL
209 if [ "$USE_LOAD_TESTER" = "yes" ]
211 echo -n " --enable-load-tester" >> $INSTALLSHELL
214 if [ "$USE_TEST_VECTORS" = "yes" ]
216 echo -n " --enable-test-vectors" >> $INSTALLSHELL
219 if [ "$USE_GCRYPT" = "yes" ]
221 echo -n " --enable-gcrypt" >> $INSTALLSHELL
224 if [ "$USE_SOCKET_DEFAULT" = "yes" ]
226 echo -n " --enable-socket-default" >> $INSTALLSHELL
229 if [ "$USE_SOCKET_DYNAMIC" = "yes" ]
231 echo -n " --enable-socket-dynamic" >> $INSTALLSHELL
234 if [ "$USE_DHCP" = "yes" ]
236 echo -n " --enable-dhcp" >> $INSTALLSHELL
239 if [ "$USE_FARP" = "yes" ]
241 echo -n " --enable-farp" >> $INSTALLSHELL
244 if [ "$USE_ADDRBLOCK" = "yes" ]
246 echo -n " --enable-addrblock" >> $INSTALLSHELL
249 echo "" >> $INSTALLSHELL
250 echo "make" >> $INSTALLSHELL
251 echo "make install" >> $INSTALLSHELL
252 echo "ldconfig" >> $INSTALLSHELL
254 cecho-n " * Compiling $STRONGSWANVERSION within the root file system as chroot.."
255 chroot $LOOPDIR /bin/bash /install.sh >> $LOGFILE 2>&1
259 ######################################################
260 # copying default /etc/ipsec.d/tables.sql to the root filesystem
262 cecho " * Copying '$HOSTCONFIGDIR/default/etc/ipsec.d/tables.sql' to the root filesystem"
263 cp -fp $HOSTCONFIGDIR/default/etc/ipsec.d/tables.sql $LOOPDIR/etc/ipsec.d/tables.sql
265 ######################################################
266 # copying the host's ssh public key
269 if [ ! -d $LOOPDIR/root/.ssh ]
271 mkdir $LOOPDIR/root/.ssh
273 cp ~/.ssh/id_rsa.pub $LOOPDIR/root/.ssh/authorized_keys
275 ######################################################
276 # setup public key based login among all hosts
278 cp $LOOPDIR/etc/ssh/ssh_host_rsa_key $LOOPDIR/root/.ssh/id_rsa
280 for host in $STRONGSWANHOSTS
282 eval ip="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F- '{ print $1 }' | awk '{ print $1 }'`"
283 echo "$host,$ip `cat $HOSTCONFIGDIR/ssh_host_rsa_key.pub`" >> $LOOPDIR/root/.ssh/known_hosts
284 echo "`cat $HOSTCONFIGDIR/ssh_host_rsa_key.pub` root@$host" >> $LOOPDIR/root/.ssh/authorized_keys
287 ######################################################
288 # defining an empty modules.dep
293 mkdir $LOOPDIR/lib/modules/`basename $UMLPATCH .bz2 | sed s/uml-patch-//`um
294 touch $LOOPDIR/lib/modules/`basename $UMLPATCH .bz2 | sed s/uml-patch-//`um/modules.dep
296 mkdir $LOOPDIR/lib/modules/$KERNELVERSION
297 touch $LOOPDIR/lib/modules/$KERNELVERSION/modules.dep