1# #-- root_zonemd.pre--# 2# source the master var file when it's there 3[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4# use .tpkg.var.test for in test variable passing 5[ -f .tpkg.var.test ] && source .tpkg.var.test 6 7. ../common.sh 8 9# attempt to download the root zone 10from=k.root-servers.net 11dig @$from . AXFR > root.txt 12if test $? -ne 0; then 13 echo "could not fetch root zone" 14 skip_test "could not fetch root zone" 15fi 16grep " SOA " root.txt | head -1 > root.soa 17cat root.soa >> root.zone 18grep -v " SOA " root.txt >> root.zone 19echo "fetched root.zone" 20ls -l root.zone 21cat root.soa 22 23get_random_port 2 24UNBOUND_PORT=$RND_PORT 25FWD_PORT=$(($RND_PORT + 1)) 26echo "UNBOUND_PORT=$UNBOUND_PORT" >> .tpkg.var.test 27echo "FWD_PORT=$FWD_PORT" >> .tpkg.var.test 28 29# start forwarder 30get_ldns_testns 31$LDNS_TESTNS -p $FWD_PORT root_zonemd.testns >fwd.log 2>&1 & 32FWD_PID=$! 33echo "FWD_PID=$FWD_PID" >> .tpkg.var.test 34 35# make config file 36CONTROL_PATH=/tmp 37CONTROL_PID=$$ 38sed -e 's/@PORT\@/'$UNBOUND_PORT'/' -e 's/@TOPORT\@/'$FWD_PORT'/' -e 's?@CONTROL_PATH\@?'$CONTROL_PATH'?' -e 's/@CONTROL_PID@/'$CONTROL_PID'/' < root_zonemd.conf > ub.conf 39# start unbound in the background 40PRE="../.." 41$PRE/unbound -d -c ub.conf >unbound.log 2>&1 & 42UNBOUND_PID=$! 43echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test 44echo "CONTROL_PATH=$CONTROL_PATH" >> .tpkg.var.test 45echo "CONTROL_PID=$CONTROL_PID" >> .tpkg.var.test 46 47cat .tpkg.var.test 48wait_ldns_testns_up fwd.log 49wait_unbound_up unbound.log 50 51