1# #-- tcp_reuse.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 7PRE="../.." 8. ../common.sh 9get_random_port 2 10UNBOUND_PORT=$RND_PORT 11UPSTREAM_PORT=$(($RND_PORT + 1)) 12echo "UNBOUND_PORT=$UNBOUND_PORT" >> .tpkg.var.test 13echo "UPSTREAM_PORT=$UPSTREAM_PORT" >> .tpkg.var.test 14 15# make config file 16sed -e 's/@PORT\@/'$UNBOUND_PORT'/' -e 's/@TOPORT\@/'$UPSTREAM_PORT'/' < tcp_reuse.conf > ub.conf 17# start unbound in the background 18#$PRE/unbound -d -c ub.conf >unbound.log 2>&1 & 19$PRE/unbound -d -c ub.conf 2>&1 | tee unbound.log & 20UNBOUND_PID=$! 21echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test 22wait_unbound_up unbound.log 23 24# make upstream config file 25sed -e 's/@PORT\@/'$UPSTREAM_PORT'/' -e 's/@TOPORT\@/'$UPSTREAM_PORT'/' < tcp_reuse.conf2 > ub2.conf 26# start upstream unbound in the background 27#$PRE/unbound -d -c ub2.conf >unbound2.log 2>&1 & 28$PRE/unbound -d -c ub2.conf 2>&1 | tee unbound2.log & 29UPSTREAM_PID=$! 30echo "UPSTREAM_PID=$UPSTREAM_PID" >> .tpkg.var.test 31wait_unbound_up unbound2.log 32 33cat .tpkg.var.test 34 35