aboutsummaryrefslogtreecommitdiff
path: root/tools/bootstrap-network.sh
blob: cd18e3d76aa8e70d467ec6c1aec1cf5bdd96bf07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /bin/sh
#
# 1. potentially stop running network
# 2. bootstrap a network from scratch as quickly as possible
# 3. tail -F all the tor log files
#
# NOTE: leaves debris around by renaming directory net/nodes
#       and creating a new net/nodes
#
# Usage:
#    cd YOUR-CHUTNEY-DIRECTORY
#    tools/bootstrap-network.sh [network-flavour]
#    network-flavour: one of the files in the networks directory,
#                     (default: 'basic')
#

VOTING_OFFSET=6
CHUTNEY=./chutney

[ -x $CHUTNEY ] || { echo "$0: missing $CHUTNEY"; exit 1; }
[ -d networks ] || { echo "$0: missing directory: networks"; exit 1; }
[ -d net ] || { echo "$0: missing directory: net"; exit 1; }
flavour=basic; [ -n "$1" ] && { flavour=$1; shift; }

$CHUTNEY stop networks/$flavour
[ -d net/nodes ] && mv net/nodes net/nodes.$(date +%s)
echo "$0: boostrapping network: $flavour"
$CHUTNEY configure networks/$flavour

# TODO: Make 'chutney configure' take an optional offset argument and
# use the templating system in Chutney to set this instead of editing
# files like this.
offset=$(expr \( $(date +%s) + $VOTING_OFFSET \) % 300)
CONFOPT="TestingV3AuthVotingStartOffset"
for file in net/nodes/*a/torrc; do
    sed -i.bak -e "s/^${CONFOPT}.*$/${CONFOPT} $offset/1" $file
done

$CHUTNEY start networks/$flavour
tail -F net/nodes/*/notice.log