1# #-- edns_cache.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
8get_random_port 3
9UNBOUND_PORT=$RND_PORT
10STUB1_PORT=$(($RND_PORT + 1))
11STUB2_PORT=$(($RND_PORT + 2))
12echo "UNBOUND_PORT=$UNBOUND_PORT" >> .tpkg.var.test
13echo "STUB1_PORT=$STUB1_PORT" >> .tpkg.var.test
14echo "STUB2_PORT=$STUB2_PORT" >> .tpkg.var.test
15
16# start stub1
17get_ldns_testns
18$LDNS_TESTNS -6 -p $STUB1_PORT edns_cache.stub1 >stub1.log 2>&1 &
19STUB1_PID=$!
20echo "STUB1_PID=$STUB1_PID" >> .tpkg.var.test
21
22# start stub2
23$LDNS_TESTNS -p $STUB2_PORT edns_cache.stub2 >stub2.log 2>&1 &
24STUB2_PID=$!
25echo "STUB2_PID=$STUB2_PID" >> .tpkg.var.test
26
27# make config file
28sed -e 's/@PORT\@/'$UNBOUND_PORT'/' -e 's/@STUB1_PORT\@/'$STUB1_PORT'/' -e 's/@STUB2_PORT\@/'$STUB2_PORT'/' < edns_cache.conf > ub.conf
29# start unbound in the background
30PRE="../.."
31$PRE/unbound -d -c ub.conf >unbound.log 2>&1 &
32UNBOUND_PID=$!
33echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test
34
35cat .tpkg.var.test
36
37# wait for stubs to come up
38wait_ldns_testns_up stub1.log
39wait_ldns_testns_up stub2.log
40
41# wait for unbound to come up
42wait_unbound_up unbound.log
43
44