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
21 source $DIR/function.sh
23 [ -f $DIR/../testing.conf ] || die "!! Configuration file 'testing.conf' not found"
25 source $DIR/../testing.conf
27 STRONGSWANVERSION=`basename $STRONGSWAN .tar.bz2`
29 cecho-n " * Looking for strongSwan at '$STRONGSWAN'.."
30 if [ -f "$STRONGSWAN" ]
33 cecho " * strongSwan version is '$STRONGSWANVERSION'"
39 cecho-n " * Looking for gentoo root filesystem at '$ROOTFS'.."
48 [ -d $BUILDDIR ] || die "!! Directory '$BUILDDIR' does not exist"
50 HOSTCONFIGDIR=$BUILDDIR/hosts
52 [ -d $HOSTCONFIGDIR ] || die "!! Directory '$HOSTCONFIGDIR' does not exist"
54 LOGFILE=$BUILDDIR/testing.log
58 cecho-n " * Logfile '$LOGFILE' does not exist..creating.."
63 ROOTFSDIR=$BUILDDIR/root-fs
65 if [ ! -d $ROOTFSDIR ]
67 cecho-n " * Root file system directory '$ROOTFSDIR' does not exist..creating.."
74 LOOPDIR=$ROOTFSDIR/loop
81 ######################################################
82 # creating reiser-based uml root filesystem
85 cecho-n " * Building basic root filesystem (gentoo).."
86 dd if=/dev/zero of=gentoo-fs count=$ROOTFSSIZE bs=1M >> $LOGFILE 2>&1
87 mkreiserfs -q -f gentoo-fs >> $LOGFILE 2>&1
88 mount -o loop gentoo-fs $LOOPDIR >> $LOGFILE 2>&1
89 tar xjpf $ROOTFS -C $LOOPDIR >> $LOGFILE 2>&1
92 ######################################################
93 # remove /etc/resolv.conf
95 cecho " * Removing /etc/resolv.conf"
96 rm -f $LOOPDIR/etc/resolv.conf
98 ######################################################
99 # copying default /etc/hosts to the root filesystem
101 cecho " * Copying '$HOSTCONFIGDIR/default/etc/hosts' to the root filesystem"
102 cp -fp $HOSTCONFIGDIR/default/etc/hosts $LOOPDIR/etc/hosts
104 #####################################################
105 # extracting strongSwan into the root filesystem
107 cecho " * Extracting strongSwan into the root filesystem"
108 tar xjf $STRONGSWAN -C $LOOPDIR/root >> $LOGFILE 2>&1
110 ######################################################
111 # setting up mountpoint for shared source tree
113 if [ "${SHAREDTREE+set}" = "set" ]; then
114 cecho " * setting up shared strongswan tree at '$SHAREDTREE'"
115 mkdir $LOOPDIR/root/strongswan-shared
116 echo "" >> $LOOPDIR/etc/fstab
117 echo "none /root/strongswan-shared hostfs $SHAREDTREE" >> $LOOPDIR/etc/fstab
120 ######################################################
121 # installing strongSwan and setting the local timezone
124 INSTALLSHELL=${LOOPDIR}/install.sh
126 cecho " * Preparing strongSwan installation script"
127 echo "ln -sf /usr/share/zoneinfo/${TZUML} /etc/localtime" >> $INSTALLSHELL
129 echo "cd /root/${STRONGSWANVERSION}" >> $INSTALLSHELL
130 echo -n "./configure --sysconfdir=/etc" >> $INSTALLSHELL
131 echo -n " --with-random-device=/dev/urandom" >> $INSTALLSHELL
133 if [ "$USE_LIBCURL" = "yes" ]
135 echo -n " --enable-curl" >> $INSTALLSHELL
138 if [ "$USE_LDAP" = "yes" ]
140 echo -n " --enable-ldap" >> $INSTALLSHELL
143 if [ "$USE_EAP_AKA" = "yes" ]
145 echo -n " --enable-eap-aka" >> $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_SQL" = "yes" ]
177 echo -n " --enable-sql --enable-sqlite" >> $INSTALLSHELL
180 if [ "$USE_MEDIATION" = "yes" ]
182 echo -n " --enable-mediation" >> $INSTALLSHELL
185 if [ "$USE_OPENSSL" = "yes" ]
187 echo -n " --enable-openssl" >> $INSTALLSHELL
190 if [ "$USE_KERNEL_PFKEY" = "yes" ]
192 echo -n " --enable-kernel-pfkey" >> $INSTALLSHELL
195 if [ "$USE_INTEGRITY_TEST" = "yes" ]
197 echo -n " --enable-integrity-test" >> $INSTALLSHELL
200 if [ "$USE_LEAK_DETECTIVE" = "yes" ]
202 echo -n " --enable-leak-detective" >> $INSTALLSHELL
205 if [ "$USE_LOAD_TESTS" = "yes" ]
207 echo -n " --enable-load-tests" >> $INSTALLSHELL
210 echo "" >> $INSTALLSHELL
211 echo "make" >> $INSTALLSHELL
212 echo "make install" >> $INSTALLSHELL
213 echo "ldconfig" >> $INSTALLSHELL
215 cecho-n " * Compiling $STRONGSWANVERSION within the root file system as chroot.."
216 chroot $LOOPDIR /bin/bash /install.sh >> $LOGFILE 2>&1
220 ######################################################
221 # copying default /etc/ipsec.d/tables.sql to the root filesystem
223 cecho " * Copying '$HOSTCONFIGDIR/default/etc/ipsec.d/tables.sql' to the root filesystem"
224 cp -fp $HOSTCONFIGDIR/default/etc/ipsec.d/tables.sql $LOOPDIR/etc/ipsec.d/tables.sql
226 ######################################################
227 # copying the host's ssh public key
230 if [ ! -d $LOOPDIR/root/.ssh ]
232 mkdir $LOOPDIR/root/.ssh
234 cp ~/.ssh/id_rsa.pub $LOOPDIR/root/.ssh/authorized_keys
236 ######################################################
237 # setup public key based login among all hosts
239 cp $LOOPDIR/etc/ssh/ssh_host_rsa_key $LOOPDIR/root/.ssh/id_rsa
241 for host in $STRONGSWANHOSTS
243 eval ip="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F- '{ print $1 }' | awk '{ print $1 }'`"
244 echo "$host,$ip `cat $HOSTCONFIGDIR/ssh_host_rsa_key.pub`" >> $LOOPDIR/root/.ssh/known_hosts
245 echo "`cat $HOSTCONFIGDIR/ssh_host_rsa_key.pub` root@$host" >> $LOOPDIR/root/.ssh/authorized_keys
248 ######################################################
249 # defining an empty modules.dep
254 mkdir $LOOPDIR/lib/modules/`basename $UMLPATCH .bz2 | sed s/uml-patch-//`um
255 touch $LOOPDIR/lib/modules/`basename $UMLPATCH .bz2 | sed s/uml-patch-//`um/modules.dep
257 mkdir $LOOPDIR/lib/modules/$KERNELVERSION
258 touch $LOOPDIR/lib/modules/$KERNELVERSION/modules.dep