bootstrap-network.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #! /bin/sh
  2. #
  3. # 1. potentially stop running network
  4. # 2. bootstrap a network from scratch as quickly as possible
  5. # 3. tail -F all the tor log files
  6. #
  7. # NOTE: leaves debris around by renaming directory net/nodes
  8. # and creating a new net/nodes
  9. #
  10. # Usage:
  11. # cd YOUR-CHUTNEY-DIRECTORY
  12. # tools/bootstrap-network.sh [network-flavour]
  13. # network-flavour: one of the files in the networks directory,
  14. # (default: 'basic')
  15. #
  16. VOTING_OFFSET=6
  17. CHUTNEY=./chutney
  18. myname=$(basename "$0")
  19. [ -x $CHUTNEY ] || { echo "$myname: missing $CHUTNEY"; exit 1; }
  20. [ -d networks ] || { echo "$myname: missing directory: networks"; exit 1; }
  21. flavour=basic; [ -n "$1" ] && { flavour=$1; shift; }
  22. $CHUTNEY stop networks/$flavour
  23. [ -d net/nodes ] && {
  24. DEST=net/nodes.$(date +%s)
  25. echo "$myname: NOTE: renaming net/nodes to $DEST"
  26. mv net/nodes $DEST
  27. }
  28. echo "$myname: boostrapping network: $flavour"
  29. $CHUTNEY configure networks/$flavour
  30. # TODO: Make 'chutney configure' take an optional offset argument and
  31. # use the templating system in Chutney to set this instead of editing
  32. # files like this.
  33. offset=$(expr \( $(date +%s) + $VOTING_OFFSET \) % 300)
  34. CONFOPT="TestingV3AuthVotingStartOffset"
  35. for file in net/nodes/*a/torrc; do
  36. sed -i.bak -e "s/^${CONFOPT}.*$/${CONFOPT} $offset/1" $file
  37. done
  38. $CHUTNEY start networks/$flavour
  39. $CHUTNEY status networks/$flavour
  40. #echo "tail -F net/nodes/*/notice.log"