diff options
Diffstat (limited to 'src/service/dht/dhtu_testbed_deploy.sh')
-rwxr-xr-x | src/service/dht/dhtu_testbed_deploy.sh | 95 |
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 | ||
5 | GNUNET_TMP="$(gnunet-config -f -s PATHS -o GNUNET_TMP)" | ||
6 | |||
7 | # We will use UDP ports above this number. | ||
8 | MINPORT=10000 | ||
9 | |||
10 | # Cleanup to run whenever we exit | ||
11 | function 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) | ||
21 | trap cleanup EXIT | ||
22 | |||
23 | if test -z "$1" | ||
24 | then | ||
25 | echo "Call with the number of peers to launch." | ||
26 | exit 1 | ||
27 | fi | ||
28 | |||
29 | echo -n "Testing for GNU parallel ..." | ||
30 | |||
31 | if test ! -x `which parallel` | ||
32 | then | ||
33 | echo "This script requires GNU parallel" | ||
34 | exit 1 | ||
35 | fi | ||
36 | |||
37 | parallel -V | grep "GNU parallel" > /dev/null || exit 1 | ||
38 | |||
39 | echo " OK" | ||
40 | |||
41 | |||
42 | |||
43 | if test ! -x `which gnunet-service-dht` | ||
44 | then | ||
45 | echo "This script requires gnunet-service-dht in \$PATH" | ||
46 | exit 1 | ||
47 | fi | ||
48 | |||
49 | if test ! -x `which gnunet-dht-hello` | ||
50 | then | ||
51 | echo "This script requires gnunet-dht-hello in \$PATH" | ||
52 | exit 1 | ||
53 | fi | ||
54 | |||
55 | MAX=`expr $1 - 1` | ||
56 | |||
57 | export GNUNET_FORCE_LOG="dht*;;;;DEBUG" | ||
58 | |||
59 | echo -n "Starting $1 peers " | ||
60 | mkdir -p "$GNUNET_TMP/deployment" | ||
61 | for n in `seq 0 $MAX` | ||
62 | do | ||
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 "." | ||
68 | done | ||
69 | |||
70 | echo "" | ||
71 | echo "$1 peers ready". | ||
72 | |||
73 | unset GNUNET_FORCE_LOG | ||
74 | |||
75 | function connect() | ||
76 | { | ||
77 | n=$1 | ||
78 | } | ||
79 | |||
80 | echo -n "Connecting peers ..." | ||
81 | |||
82 | export MAX | ||
83 | if test 0 != $MAX | ||
84 | then | ||
85 | seq 0 $MAX | parallel ./dhtu_testbed_connect.sh ::: | ||
86 | fi | ||
87 | |||
88 | |||
89 | echo "" | ||
90 | echo "Network ready. Press ENTER to terminate the testbed!" | ||
91 | echo "Interact with peers using '-c $GNUNET_TMP/deployment/\$N.conf'" | ||
92 | |||
93 | read | ||
94 | |||
95 | exit 0 | ||