No Description

go.sh 1022B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash
  2. BASE_PORT="3030"
  3. BASE_RPC_PORT="810"
  4. NETWORK_ID="791"
  5. APP_CORS_DOMAIN="http://localhost:8000"
  6. init() {
  7. echo "Initialising $NODE in directory 'nodes/$PWD'"
  8. geth --datadir $PWD/nodes/$NODE init $PWD/nodes/genesis791.json
  9. }
  10. start() {
  11. init
  12. NODE_NUMBER=${NODE:4}
  13. PORT=$BASE_PORT$NODE_NUMBER
  14. RPC_PORT=$BASE_RPC_PORT$NODE_NUMBER
  15. echo "Starting $NODE"
  16. geth --datadir $PWD/nodes/$NODE --port $PORT --rpc --rpcport $RPC_PORT --networkid $NETWORK_ID --nodiscover --verbosity 5 --rpccorsdomain $APP_CORS_DOMAIN --ipcpath $PWD/nodes/$NODE/geth.ipc
  17. }
  18. console() {
  19. geth attach $PWD/nodes/$NODE/geth.ipc
  20. }
  21. usage() {
  22. echo "Usage:"
  23. echo "start <node name from 0 to 9 (node0, node1, node2 etc.)> : starts the node in the network"
  24. echo "console <node name from 0 to 9 (node0, node1, node2 etc.)> : attaches a js console to the node"
  25. }
  26. OPTION="$1"
  27. [ ! -z $2 ] && NODE="$2" || NODE="node0"
  28. case $OPTION in
  29. start)
  30. start
  31. ;;
  32. console)
  33. console
  34. ;;
  35. *)
  36. usage
  37. esac