PageRenderTime 51ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/strongswan-5.0.0/testing/scripts/build-umlrootfs

#
#! | 446 lines | 357 code | 89 blank | 0 comment | 0 complexity | 79d899c7ada048d746f2b8e87b2baf59 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0
  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. DIR=`dirname $0`
  17. source $DIR/function.sh
  18. [ -f $DIR/../testing.conf ] || die "!! Configuration file 'testing.conf' not found"
  19. source $DIR/../testing.conf
  20. STRONGSWANVERSION=`basename $STRONGSWAN .tar.bz2`
  21. cecho-n " * Looking for strongSwan at '$STRONGSWAN'.."
  22. if [ -f "$STRONGSWAN" ]
  23. then
  24. cecho "found it"
  25. cecho " * strongSwan version is '$STRONGSWANVERSION'"
  26. else
  27. cecho "none"
  28. exit
  29. fi
  30. cecho-n " * Looking for gentoo root filesystem at '$ROOTFS'.."
  31. if [ -f "$ROOTFS" ]
  32. then
  33. cecho "found it"
  34. else
  35. cecho "none"
  36. exit
  37. fi
  38. [ -d $BUILDDIR ] || die "!! Directory '$BUILDDIR' does not exist"
  39. HOSTCONFIGDIR=$BUILDDIR/hosts
  40. [ -d $HOSTCONFIGDIR ] || die "!! Directory '$HOSTCONFIGDIR' does not exist"
  41. LOGFILE=$BUILDDIR/testing.log
  42. if [ ! -f $LOGFILE ]
  43. then
  44. cecho-n " * Logfile '$LOGFILE' does not exist..creating.."
  45. touch $LOGFILE
  46. cgecho "done"
  47. fi
  48. ROOTFSDIR=$BUILDDIR/root-fs
  49. if [ ! -d $ROOTFSDIR ]
  50. then
  51. cecho-n " * Root file system directory '$ROOTFSDIR' does not exist..creating.."
  52. mkdir $ROOTFSDIR
  53. cgecho "done"
  54. fi
  55. cd $ROOTFSDIR
  56. LOOPDIR=$ROOTFSDIR/loop
  57. if [ ! -d $LOOPDIR ]
  58. then
  59. mkdir $LOOPDIR
  60. fi
  61. ######################################################
  62. # creating reiser-based uml root filesystem
  63. #
  64. cecho-n " * Building basic root filesystem (gentoo).."
  65. dd if=/dev/zero of=gentoo-fs count=$ROOTFSSIZE bs=1M >> $LOGFILE 2>&1
  66. mkreiserfs -q -f gentoo-fs >> $LOGFILE 2>&1
  67. mount -o loop gentoo-fs $LOOPDIR >> $LOGFILE 2>&1
  68. tar xjpf $ROOTFS -C $LOOPDIR >> $LOGFILE 2>&1
  69. cgecho "done"
  70. ######################################################
  71. # remove /etc/resolv.conf
  72. #
  73. cecho " * Removing /etc/resolv.conf"
  74. rm -f $LOOPDIR/etc/resolv.conf
  75. ######################################################
  76. # copying default /etc/hosts to the root filesystem
  77. #
  78. cecho " * Copying '$HOSTCONFIGDIR/default/etc/hosts' to the root filesystem"
  79. cp -fp $HOSTCONFIGDIR/default/etc/hosts $LOOPDIR/etc/hosts
  80. #####################################################
  81. # extracting strongSwan into the root filesystem
  82. #
  83. cecho " * Extracting strongSwan into the root filesystem"
  84. tar xjf $STRONGSWAN -C $LOOPDIR/root >> $LOGFILE 2>&1
  85. ######################################################
  86. # setting up mountpoint for shared source tree
  87. #
  88. if [ "${SHAREDTREE+set}" = "set" ]; then
  89. cecho " * setting up shared strongswan tree at '$SHAREDTREE'"
  90. mkdir $LOOPDIR/root/strongswan-shared
  91. echo "" >> $LOOPDIR/etc/fstab
  92. echo "none /root/strongswan-shared hostfs $SHAREDTREE" >> $LOOPDIR/etc/fstab
  93. fi
  94. ######################################################
  95. # installing strongSwan and setting the local timezone
  96. #
  97. INSTALLSHELL=${LOOPDIR}/install.sh
  98. cecho " * Preparing strongSwan installation script"
  99. echo "ln -sf /usr/share/zoneinfo/${TZUML} /etc/localtime" >> $INSTALLSHELL
  100. echo "cd /root/${STRONGSWANVERSION}" >> $INSTALLSHELL
  101. echo -n "./configure --sysconfdir=/etc" >> $INSTALLSHELL
  102. echo -n " --with-random-device=/dev/urandom" >> $INSTALLSHELL
  103. echo -n " --disable-load-warning" >> $INSTALLSHELL
  104. if [ "$USE_LIBCURL" = "yes" ]
  105. then
  106. echo -n " --enable-curl" >> $INSTALLSHELL
  107. fi
  108. if [ "$USE_LDAP" = "yes" ]
  109. then
  110. echo -n " --enable-ldap" >> $INSTALLSHELL
  111. fi
  112. if [ "$USE_EAP_AKA" = "yes" ]
  113. then
  114. echo -n " --enable-eap-aka" >> $INSTALLSHELL
  115. echo -n " --enable-eap-aka-3gpp2" >> $INSTALLSHELL
  116. fi
  117. if [ "$USE_EAP_SIM" = "yes" ]
  118. then
  119. echo -n " --enable-eap-sim" >> $INSTALLSHELL
  120. echo -n " --enable-eap-sim-file" >> $INSTALLSHELL
  121. fi
  122. if [ "$USE_EAP_MD5" = "yes" ]
  123. then
  124. echo -n " --enable-eap-md5" >> $INSTALLSHELL
  125. fi
  126. if [ "$USE_EAP_MSCHAPV2" = "yes" ]
  127. then
  128. echo -n " --enable-md4" >> $INSTALLSHELL
  129. echo -n " --enable-eap-mschapv2" >> $INSTALLSHELL
  130. fi
  131. if [ "$USE_EAP_IDENTITY" = "yes" ]
  132. then
  133. echo -n " --enable-eap-identity" >> $INSTALLSHELL
  134. fi
  135. if [ "$USE_EAP_RADIUS" = "yes" ]
  136. then
  137. echo -n " --enable-eap-radius" >> $INSTALLSHELL
  138. fi
  139. if [ "$USE_EAP_TLS" = "yes" ]
  140. then
  141. echo -n " --enable-eap-tls" >> $INSTALLSHELL
  142. fi
  143. if [ "$USE_EAP_TTLS" = "yes" ]
  144. then
  145. echo -n " --enable-eap-ttls" >> $INSTALLSHELL
  146. fi
  147. if [ "$USE_EAP_PEAP" = "yes" ]
  148. then
  149. echo -n " --enable-eap-peap" >> $INSTALLSHELL
  150. fi
  151. if [ "$USE_EAP_TNC" = "yes" ]
  152. then
  153. echo -n " --enable-eap-tnc" >> $INSTALLSHELL
  154. fi
  155. if [ "$USE_TNC_PDP" = "yes" ]
  156. then
  157. echo -n " --enable-tnc-pdp" >> $INSTALLSHELL
  158. fi
  159. if [ "$USE_TNC_IMC" = "yes" ]
  160. then
  161. echo -n " --enable-tnc-imc" >> $INSTALLSHELL
  162. fi
  163. if [ "$USE_TNC_IMV" = "yes" ]
  164. then
  165. echo -n " --enable-tnc-imv" >> $INSTALLSHELL
  166. fi
  167. if [ "$USE_TNCCS_11" = "yes" ]
  168. then
  169. echo -n " --enable-tnccs-11" >> $INSTALLSHELL
  170. fi
  171. if [ "$USE_TNCCS_20" = "yes" ]
  172. then
  173. echo -n " --enable-tnccs-20" >> $INSTALLSHELL
  174. fi
  175. if [ "$USE_TNCCS_DYNAMIC" = "yes" ]
  176. then
  177. echo -n " --enable-tnccs-dynamic" >> $INSTALLSHELL
  178. fi
  179. if [ "$USE_IMC_TEST" = "yes" ]
  180. then
  181. echo -n " --enable-imc-test" >> $INSTALLSHELL
  182. fi
  183. if [ "$USE_IMV_TEST" = "yes" ]
  184. then
  185. echo -n " --enable-imv-test" >> $INSTALLSHELL
  186. fi
  187. if [ "$USE_IMC_SCANNER" = "yes" ]
  188. then
  189. echo -n " --enable-imc-scanner" >> $INSTALLSHELL
  190. fi
  191. if [ "$USE_IMV_SCANNER" = "yes" ]
  192. then
  193. echo -n " --enable-imv-scanner" >> $INSTALLSHELL
  194. fi
  195. if [ "$USE_IMC_ATTESTATION" = "yes" ]
  196. then
  197. echo -n " --enable-imc-attestation" >> $INSTALLSHELL
  198. fi
  199. if [ "$USE_IMV_ATTESTATION" = "yes" ]
  200. then
  201. echo -n " --enable-imv-attestation" >> $INSTALLSHELL
  202. fi
  203. if [ "$USE_SQL" = "yes" ]
  204. then
  205. echo -n " --enable-sql --enable-sqlite" >> $INSTALLSHELL
  206. fi
  207. if [ "$USE_MEDIATION" = "yes" ]
  208. then
  209. echo -n " --enable-mediation" >> $INSTALLSHELL
  210. fi
  211. if [ "$USE_OPENSSL" = "yes" ]
  212. then
  213. echo -n " --enable-openssl" >> $INSTALLSHELL
  214. fi
  215. if [ "$USE_BLOWFISH" = "yes" ]
  216. then
  217. echo -n " --enable-blowfish" >> $INSTALLSHELL
  218. fi
  219. if [ "$USE_KERNEL_PFKEY" = "yes" ]
  220. then
  221. echo -n " --enable-kernel-pfkey" >> $INSTALLSHELL
  222. fi
  223. if [ "$USE_INTEGRITY_TEST" = "yes" ]
  224. then
  225. echo -n " --enable-integrity-test" >> $INSTALLSHELL
  226. fi
  227. if [ "$USE_LEAK_DETECTIVE" = "yes" ]
  228. then
  229. echo -n " --enable-leak-detective" >> $INSTALLSHELL
  230. fi
  231. if [ "$USE_LOAD_TESTER" = "yes" ]
  232. then
  233. echo -n " --enable-load-tester" >> $INSTALLSHELL
  234. fi
  235. if [ "$USE_TEST_VECTORS" = "yes" ]
  236. then
  237. echo -n " --enable-test-vectors" >> $INSTALLSHELL
  238. fi
  239. if [ "$USE_GCRYPT" = "yes" ]
  240. then
  241. echo -n " --enable-gcrypt" >> $INSTALLSHELL
  242. fi
  243. if [ "$USE_SOCKET_DEFAULT" = "yes" ]
  244. then
  245. echo -n " --enable-socket-default" >> $INSTALLSHELL
  246. fi
  247. if [ "$USE_SOCKET_DYNAMIC" = "yes" ]
  248. then
  249. echo -n " --enable-socket-dynamic" >> $INSTALLSHELL
  250. fi
  251. if [ "$USE_SOCKET_RAW" = "yes" ]
  252. then
  253. echo -n " --enable-socket-raw" >> $INSTALLSHELL
  254. fi
  255. if [ "$USE_DHCP" = "yes" ]
  256. then
  257. echo -n " --enable-dhcp" >> $INSTALLSHELL
  258. fi
  259. if [ "$USE_FARP" = "yes" ]
  260. then
  261. echo -n " --enable-farp" >> $INSTALLSHELL
  262. fi
  263. if [ "$USE_ADDRBLOCK" = "yes" ]
  264. then
  265. echo -n " --enable-addrblock" >> $INSTALLSHELL
  266. fi
  267. if [ "$USE_CTR" = "yes" ]
  268. then
  269. echo -n " --enable-ctr" >> $INSTALLSHELL
  270. fi
  271. if [ "$USE_CCM" = "yes" ]
  272. then
  273. echo -n " --enable-ccm" >> $INSTALLSHELL
  274. fi
  275. if [ "$USE_GCM" = "yes" ]
  276. then
  277. echo -n " --enable-gcm" >> $INSTALLSHELL
  278. fi
  279. if [ "$USE_CMAC" = "yes" ]
  280. then
  281. echo -n " --enable-cmac" >> $INSTALLSHELL
  282. fi
  283. if [ "$USE_HA" = "yes" ]
  284. then
  285. echo -n " --enable-ha" >> $INSTALLSHELL
  286. fi
  287. if [ "$USE_AF_ALG" = "yes" ]
  288. then
  289. echo -n " --enable-af-alg" >> $INSTALLSHELL
  290. fi
  291. if [ "$USE_WHITELIST" = "yes" ]
  292. then
  293. echo -n " --enable-whitelist" >> $INSTALLSHELL
  294. fi
  295. if [ "$USE_XAUTH_GENERIC" = "yes" ]
  296. then
  297. echo -n " --enable-xauth-generic" >> $INSTALLSHELL
  298. fi
  299. if [ "$USE_XAUTH_EAP" = "yes" ]
  300. then
  301. echo -n " --enable-xauth-eap" >> $INSTALLSHELL
  302. fi
  303. if [ "$USE_PKCS8" = "yes" ]
  304. then
  305. echo -n " --enable-pkcs8" >> $INSTALLSHELL
  306. fi
  307. if [ "$USE_IFMAP" = "yes" ]
  308. then
  309. echo -n " --enable-tnc-ifmap" >> $INSTALLSHELL
  310. fi
  311. if [ "$USE_CISCO_QUIRKS" = "yes" ]
  312. then
  313. echo -n " --enable-cisco-quirks" >> $INSTALLSHELL
  314. fi
  315. echo "" >> $INSTALLSHELL
  316. echo "make -j" >> $INSTALLSHELL
  317. echo "make install" >> $INSTALLSHELL
  318. echo "ldconfig" >> $INSTALLSHELL
  319. cecho-n " * Compiling $STRONGSWANVERSION within the root file system as chroot.."
  320. chroot $LOOPDIR /bin/bash /install.sh >> $LOGFILE 2>&1
  321. rm -f $INSTALLSHELL
  322. cgecho "done"
  323. ######################################################
  324. # copying default /etc/ipsec.d/tables.sql to the root filesystem
  325. #
  326. cecho " * Copying '$HOSTCONFIGDIR/default/etc/ipsec.d/tables.sql' to the root filesystem"
  327. cp -fp $HOSTCONFIGDIR/default/etc/ipsec.d/tables.sql $LOOPDIR/etc/ipsec.d/tables.sql
  328. ######################################################
  329. # copying the host's ssh public key
  330. #
  331. if [ ! -d $LOOPDIR/root/.ssh ]
  332. then
  333. mkdir $LOOPDIR/root/.ssh
  334. fi
  335. cp ~/.ssh/id_rsa.pub $LOOPDIR/root/.ssh/authorized_keys
  336. ######################################################
  337. # setup public key based login among all hosts
  338. #
  339. cp $LOOPDIR/etc/ssh/ssh_host_rsa_key $LOOPDIR/root/.ssh/id_rsa
  340. for host in $STRONGSWANHOSTS
  341. do
  342. eval ip="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F- '{ print $1 }' | awk '{ print $1 }'`"
  343. echo "$host,$ip `cat $HOSTCONFIGDIR/ssh_host_rsa_key.pub`" >> $LOOPDIR/root/.ssh/known_hosts
  344. echo "`cat $HOSTCONFIGDIR/ssh_host_rsa_key.pub` root@$host" >> $LOOPDIR/root/.ssh/authorized_keys
  345. done
  346. ######################################################
  347. # defining an empty modules.dep
  348. #
  349. if [ $UMLPATCH ]
  350. then
  351. mkdir $LOOPDIR/lib/modules/`basename $UMLPATCH .bz2 | sed s/uml-patch-//`um
  352. touch $LOOPDIR/lib/modules/`basename $UMLPATCH .bz2 | sed s/uml-patch-//`um/modules.dep
  353. else
  354. mkdir $LOOPDIR/lib/modules/$KERNELVERSION
  355. touch $LOOPDIR/lib/modules/$KERNELVERSION/modules.dep
  356. fi
  357. umount $LOOPDIR