]> git.ipfire.org Git - thirdparty/strongswan.git/blob - testing/scripts/build-umlrootfs
activate --enable-openssl option in uml scenarios
[thirdparty/strongswan.git] / testing / scripts / build-umlrootfs
1 #!/bin/bash
2 # Create UML root filesystem
3 #
4 # Copyright (C) 2004 Eric Marchionni, Patrik Rayo
5 # Zuercher Hochschule Winterthur
6 #
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>.
11 #
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
15 # for more details.
16 #
17 # RCSID $Id$
18
19 DIR=`dirname $0`
20
21 source $DIR/function.sh
22
23 [ -f $DIR/../testing.conf ] || die "!! Configuration file 'testing.conf' not found"
24
25 source $DIR/../testing.conf
26
27 STRONGSWANVERSION=`basename $STRONGSWAN .tar.bz2`
28
29 cecho-n " * Looking for strongSwan at '$STRONGSWAN'.."
30 if [ -f "$STRONGSWAN" ]
31 then
32 cecho "found it"
33 cecho " * strongSwan version is '$STRONGSWANVERSION'"
34 else
35 cecho "none"
36 exit
37 fi
38
39 cecho-n " * Looking for gentoo root filesystem at '$ROOTFS'.."
40 if [ -f "$ROOTFS" ]
41 then
42 cecho "found it"
43 else
44 cecho "none"
45 exit
46 fi
47
48 [ -d $BUILDDIR ] || die "!! Directory '$BUILDDIR' does not exist"
49
50 HOSTCONFIGDIR=$BUILDDIR/hosts
51
52 [ -d $HOSTCONFIGDIR ] || die "!! Directory '$HOSTCONFIGDIR' does not exist"
53
54 LOGFILE=$BUILDDIR/testing.log
55
56 if [ ! -f $LOGFILE ]
57 then
58 cecho-n " * Logfile '$LOGFILE' does not exist..creating.."
59 touch $LOGFILE
60 cgecho "done"
61 fi
62
63 ROOTFSDIR=$BUILDDIR/root-fs
64
65 if [ ! -d $ROOTFSDIR ]
66 then
67 cecho-n " * Root file system directory '$ROOTFSDIR' does not exist..creating.."
68 mkdir $ROOTFSDIR
69 cgecho "done"
70 fi
71
72 cd $ROOTFSDIR
73
74 LOOPDIR=$ROOTFSDIR/loop
75
76 if [ ! -d $LOOPDIR ]
77 then
78 mkdir $LOOPDIR
79 fi
80
81 ######################################################
82 # creating reiser-based uml root filesystem
83 #
84
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
90 cgecho "done"
91
92 ######################################################
93 # remove /etc/resolv.conf
94 #
95 cecho " * Removing /etc/resolv.conf"
96 rm -f $LOOPDIR/etc/resolv.conf
97
98 ######################################################
99 # copying default /etc/hosts to the root filesystem
100 #
101 cecho " * Copying '$HOSTCONFIGDIR/default/etc/hosts' to the root filesystem"
102 cp -fp $HOSTCONFIGDIR/default/etc/hosts $LOOPDIR/etc/hosts
103
104 #####################################################
105 # extracting strongSwan into the root filesystem
106 #
107 cecho " * Extracting strongSwan into the root filesystem"
108 tar xjf $STRONGSWAN -C $LOOPDIR/root >> $LOGFILE 2>&1
109
110 ######################################################
111 # setting up mountpoint for shared source tree
112 #
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
118 fi
119
120 ######################################################
121 # installing strongSwan and setting the local timezone
122 #
123
124 INSTALLSHELL=${LOOPDIR}/install.sh
125
126 cecho " * Preparing strongSwan installation script"
127 echo "ln -sf /usr/share/zoneinfo/${TZUML} /etc/localtime" >> $INSTALLSHELL
128
129 echo "cd /root/${STRONGSWANVERSION}" >> $INSTALLSHELL
130 echo -n "./configure --sysconfdir=/etc" >> $INSTALLSHELL
131 echo -n " --with-random-device=/dev/urandom" >> $INSTALLSHELL
132
133 if [ "$USE_LIBCURL" = "yes" ]
134 then
135 echo -n " --enable-curl" >> $INSTALLSHELL
136 fi
137
138 if [ "$USE_LDAP" = "yes" ]
139 then
140 echo -n " --enable-ldap" >> $INSTALLSHELL
141 fi
142
143 if [ "$USE_EAP_AKA" = "yes" ]
144 then
145 echo -n " --enable-eap-aka" >> $INSTALLSHELL
146 fi
147
148 if [ "$USE_EAP_SIM" = "yes" ]
149 then
150 echo -n " --enable-eap-sim" >> $INSTALLSHELL
151 fi
152
153 if [ "$USE_EAP_MD5" = "yes" ]
154 then
155 echo -n " --enable-eap-md5" >> $INSTALLSHELL
156 fi
157
158 if [ "$USE_SQL" = "yes" ]
159 then
160 echo -n " --enable-sql --enable-sqlite" >> $INSTALLSHELL
161 fi
162
163 if [ "$USE_MEDIATION" = "yes" ]
164 then
165 echo -n " --enable-mediation" >> $INSTALLSHELL
166 fi
167
168 if [ "$USE_OPENSSL" = "yes" ]
169 then
170 echo -n " --enable-openssl" >> $INSTALLSHELL
171 fi
172
173 if [ "$USE_INTEGRITY_TEST" = "yes" ]
174 then
175 echo -n " --enable-integrity-test" >> $INSTALLSHELL
176 fi
177
178 if [ "$USE_LEAK_DETECTIVE" = "yes" ]
179 then
180 echo -n " --enable-leak-detective" >> $INSTALLSHELL
181 fi
182
183 echo "" >> $INSTALLSHELL
184 echo "make" >> $INSTALLSHELL
185 echo "make install" >> $INSTALLSHELL
186 echo "ldconfig" >> $INSTALLSHELL
187
188 cecho-n " * Compiling $STRONGSWANVERSION within the root file system as chroot.."
189 chroot $LOOPDIR /bin/bash /install.sh >> $LOGFILE 2>&1
190 rm -f $INSTALLSHELL
191 cgecho "done"
192
193 ######################################################
194 # copying the host's ssh public key
195 #
196
197 if [ ! -d $LOOPDIR/root/.ssh ]
198 then
199 mkdir $LOOPDIR/root/.ssh
200 fi
201 cp ~/.ssh/id_rsa.pub $LOOPDIR/root/.ssh/authorized_keys
202
203 ######################################################
204 # setup public key based login among all hosts
205 #
206 cp $LOOPDIR/etc/ssh/ssh_host_rsa_key $LOOPDIR/root/.ssh/id_rsa
207
208 for host in $STRONGSWANHOSTS
209 do
210 eval ip="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F- '{ print $1 }' | awk '{ print $1 }'`"
211 echo "$host,$ip `cat $HOSTCONFIGDIR/ssh_host_rsa_key.pub`" >> $LOOPDIR/root/.ssh/known_hosts
212 echo "`cat $HOSTCONFIGDIR/ssh_host_rsa_key.pub` root@$host" >> $LOOPDIR/root/.ssh/authorized_keys
213 done
214
215 ######################################################
216 # defining an empty modules.dep
217 #
218
219 if [ $UMLPATCH ]
220 then
221 mkdir $LOOPDIR/lib/modules/`basename $UMLPATCH .bz2 | sed s/uml-patch-//`um
222 touch $LOOPDIR/lib/modules/`basename $UMLPATCH .bz2 | sed s/uml-patch-//`um/modules.dep
223 else
224 mkdir $LOOPDIR/lib/modules/$KERNELVERSION
225 touch $LOOPDIR/lib/modules/$KERNELVERSION/modules.dep
226 fi
227
228 umount $LOOPDIR