aboutsummaryrefslogtreecommitdiff
path: root/src/service/dht/dhtu_testbed_deploy.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/dht/dhtu_testbed_deploy.sh')
-rwxr-xr-xsrc/service/dht/dhtu_testbed_deploy.sh95
1 files changed, 95 insertions, 0 deletions
diff --git a/src/service/dht/dhtu_testbed_deploy.sh b/src/service/dht/dhtu_testbed_deploy.sh
new file mode 100755
index 000000000..e8ac8d5d1
--- /dev/null
+++ b/src/service/dht/dhtu_testbed_deploy.sh
@@ -0,0 +1,95 @@
1#!/bin/bash
2# This file is in the public domain.
3
4# Getting location for temporary files
5GNUNET_TMP="$(gnunet-config -f -s PATHS -o GNUNET_TMP)"
6
7# We will use UDP ports above this number.
8MINPORT=10000
9
10# Cleanup to run whenever we exit
11function cleanup()
12{
13 for n in `jobs -p`
14 do
15 kill $n 2> /dev/null || true
16 done
17 wait
18}
19
20# Install cleanup handler (except for kill -9)
21trap cleanup EXIT
22
23if test -z "$1"
24then
25 echo "Call with the number of peers to launch."
26 exit 1
27fi
28
29echo -n "Testing for GNU parallel ..."
30
31if test ! -x `which parallel`
32then
33 echo "This script requires GNU parallel"
34 exit 1
35fi
36
37parallel -V | grep "GNU parallel" > /dev/null || exit 1
38
39echo " OK"
40
41
42
43if test ! -x `which gnunet-service-dht`
44then
45 echo "This script requires gnunet-service-dht in \$PATH"
46 exit 1
47fi
48
49if test ! -x `which gnunet-dht-hello`
50then
51 echo "This script requires gnunet-dht-hello in \$PATH"
52 exit 1
53fi
54
55MAX=`expr $1 - 1`
56
57export GNUNET_FORCE_LOG="dht*;;;;DEBUG"
58
59echo -n "Starting $1 peers "
60mkdir -p "$GNUNET_TMP/deployment"
61for n in `seq 0 $MAX`
62do
63 PORT=`expr $MINPORT + $n`
64 CFG="$GNUNET_TMP/deployment/${n}.conf"
65 cat dhtu_testbed_deploy.conf | sed -e "s/%N%/$PORT/" > $CFG
66 gnunet-service-dht -c $CFG -L DEBUG &> "$GNUNET_TMP/deployment/$n.log" &
67 echo -n "."
68done
69
70echo ""
71echo "$1 peers ready".
72
73unset GNUNET_FORCE_LOG
74
75function connect()
76{
77 n=$1
78}
79
80echo -n "Connecting peers ..."
81
82export MAX
83if test 0 != $MAX
84then
85 seq 0 $MAX | parallel ./dhtu_testbed_connect.sh :::
86fi
87
88
89echo ""
90echo "Network ready. Press ENTER to terminate the testbed!"
91echo "Interact with peers using '-c $GNUNET_TMP/deployment/\$N.conf'"
92
93read
94
95exit 0