load-testconfig 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #!/bin/bash
  2. # Load test specific host configurations
  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 `readlink -f $0`)
  17. . $DIR/../testing.conf
  18. . $DIR/function.sh
  19. SSHCONF="-F $DIR/../ssh_config"
  20. ##########################################################################
  21. # load-testconfig requires a testname as an argument
  22. #
  23. testname=$1
  24. DEFAULTTESTSDIR=$DIR/../tests
  25. [ -d $DEFAULTTESTSDIR ] || die "Directory 'tests' not found"
  26. [ -d $DEFAULTTESTSDIR/$testname ] || die "Test '$testname' not found"
  27. [ -f $DEFAULTTESTSDIR/$testname/test.conf ] || die "File 'test.conf' is missing"
  28. TESTSDIR=$BUILDDIR/tests
  29. [ -d $TESTSDIR ] || mkdir $TESTSDIR
  30. TESTDIR=$TESTSDIR/${testname}
  31. rm -rf $TESTDIR
  32. mkdir -p $TESTDIR
  33. cp -rfp $DEFAULTTESTSDIR/${testname}/* $TESTDIR
  34. ##############################################################################
  35. # assign IP for each host to hostname
  36. #
  37. for host in $STRONGSWANHOSTS
  38. do
  39. eval ipv4_${host}="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
  40. eval ipv6_${host}="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
  41. case $host in
  42. moon)
  43. eval ipv4_moon1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
  44. eval ipv6_moon1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
  45. ;;
  46. sun)
  47. eval ipv4_sun1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
  48. eval ipv6_sun1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
  49. ;;
  50. alice)
  51. eval ipv4_alice1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
  52. eval ipv6_alice1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
  53. ;;
  54. venus)
  55. ;;
  56. bob)
  57. ;;
  58. carol)
  59. eval ipv4_carol1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
  60. eval ipv6_carol1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
  61. ;;
  62. dave)
  63. eval ipv4_dave1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
  64. eval ipv6_dave1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
  65. ;;
  66. winnetou)
  67. ;;
  68. esac
  69. done
  70. ##############################################################################
  71. # replace IP wildcards with actual IPv4 and IPv6 addresses
  72. #
  73. for host in $STRONGSWANHOSTS
  74. do
  75. case $host in
  76. moon)
  77. searchandreplace PH_IP_MOON1 $ipv4_moon1 $TESTDIR
  78. searchandreplace PH_IP_MOON $ipv4_moon $TESTDIR
  79. searchandreplace PH_IP6_MOON1 $ipv6_moon1 $TESTDIR
  80. searchandreplace PH_IP6_MOON $ipv6_moon $TESTDIR
  81. ;;
  82. sun)
  83. searchandreplace PH_IP_SUN1 $ipv4_sun1 $TESTDIR
  84. searchandreplace PH_IP_SUN $ipv4_sun $TESTDIR
  85. searchandreplace PH_IP6_SUN1 $ipv6_sun1 $TESTDIR
  86. searchandreplace PH_IP6_SUN $ipv6_sun $TESTDIR
  87. ;;
  88. alice)
  89. searchandreplace PH_IP_ALICE1 $ipv4_alice1 $TESTDIR
  90. searchandreplace PH_IP_ALICE $ipv4_alice $TESTDIR
  91. searchandreplace PH_IP6_ALICE1 $ipv6_alice1 $TESTDIR
  92. searchandreplace PH_IP6_ALICE $ipv6_alice $TESTDIR
  93. ;;
  94. venus)
  95. searchandreplace PH_IP_VENUS $ipv4_venus $TESTDIR
  96. searchandreplace PH_IP6_VENUS $ipv6_venus $TESTDIR
  97. ;;
  98. bob)
  99. searchandreplace PH_IP_BOB $ipv4_bob $TESTDIR
  100. searchandreplace PH_IPV6_BOB $ipv6_bob $TESTDIR
  101. ;;
  102. carol)
  103. searchandreplace PH_IP_CAROL1 $ipv4_carol1 $TESTDIR
  104. searchandreplace PH_IP_CAROL $ipv4_carol $TESTDIR
  105. searchandreplace PH_IP6_CAROL1 $ipv6_carol1 $TESTDIR
  106. searchandreplace PH_IP6_CAROL $ipv6_carol $TESTDIR
  107. ;;
  108. dave)
  109. searchandreplace PH_IP_DAVE1 $ipv4_dave1 $TESTDIR
  110. searchandreplace PH_IP_DAVE $ipv4_dave $TESTDIR
  111. searchandreplace PH_IP6_DAVE1 $ipv6_dave1 $TESTDIR
  112. searchandreplace PH_IP6_DAVE $ipv6_dave $TESTDIR
  113. ;;
  114. winnetou)
  115. searchandreplace PH_IP_WINNETOU $ipv4_winnetou $TESTDIR
  116. searchandreplace PH_IP6_WINNETOU $ipv6_winnetou $TESTDIR
  117. ;;
  118. esac
  119. done
  120. source $TESTDIR/test.conf
  121. ##########################################################################
  122. # copy test specific configurations to uml hosts
  123. #
  124. if [ -d $TESTDIR/hosts ]
  125. then
  126. for host in `ls $TESTDIR/hosts`
  127. do
  128. eval HOSTLOGIN=root@\$ipv4_${host}
  129. scp $SSHCONF -r $TESTDIR/hosts/$host/etc $HOSTLOGIN:/ > /dev/null 2>&1
  130. done
  131. fi
  132. ##########################################################################
  133. # clear auth.log and daemon.log where IKE messages are logged
  134. #
  135. for host in $IPSECHOSTS
  136. do
  137. eval HOSTLOGIN=root@\$ipv4_${host}
  138. ssh $SSHCONF $HOSTLOGIN 'rm -f /var/log/auth.log /var/log/daemon.log; \
  139. kill -SIGHUP `cat /var/run/rsyslogd.pid`' > /dev/null 2>&1
  140. done
  141. ##########################################################################
  142. # clear daemon.log and radius.log on FreeRadius servers
  143. #
  144. for host in $RADIUSHOSTS
  145. do
  146. eval HOSTLOGIN=root@\$ipv4_${host}
  147. ssh $SSHCONF $HOSTLOGIN 'rm -f /var/log/daemon.log /var/log/freeradius/radius.log; \
  148. kill -SIGHUP `cat /var/run/rsyslogd.pid`' > /dev/null 2>&1
  149. done