bootstrap-network.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. [ -x $CHUTNEY ] || { echo "$0: missing $CHUTNEY"; exit 1; }
  19. [ -d networks ] || { echo "$0: missing directory: networks"; exit 1; }
  20. [ -d net ] || { echo "$0: missing directory: net"; exit 1; }
  21. flavour=basic; [ -n "$1" ] && { flavour=$1; shift; }
  22. $CHUTNEY stop networks/$flavour
  23. [ -d net/nodes ] && mv net/nodes net/nodes.$(date +%s)
  24. echo "$0: boostrapping network: $flavour"
  25. $CHUTNEY configure networks/$flavour
  26. # TODO: Make 'chutney configure' take an optional offset argument and
  27. # use the templating system in Chutney to set this instead of editing
  28. # files like this.
  29. offset=$(expr \( $(date +%s) + $VOTING_OFFSET \) % 300)
  30. CONFOPT="TestingV3AuthVotingStartOffset"
  31. for file in net/nodes/*a/torrc; do
  32. sed -i.bak -e "s/^${CONFOPT}.*$/${CONFOPT} $offset/1" $file
  33. done
  34. $CHUTNEY start networks/$flavour
  35. $CHUTNEY status networks/$flavour
  36. #echo "tail -F net/nodes/*/notice.log"