-
Notifications
You must be signed in to change notification settings - Fork 56
/
runnode.sh
executable file
·39 lines (39 loc) · 1.52 KB
/
runnode.sh
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
#!/bin/bash
IMGNAME="ethereum/client-go:v1.8.12"
NODE_NAME=$1
NODE_NAME=${NODE_NAME:-"node1"}
DETACH_FLAG=${DETACH_FLAG:-"-d"}
CONTAINER_NAME="ethereum-$NODE_NAME"
DATA_ROOT=${DATA_ROOT:-"$(pwd)/.ether-$NODE_NAME"}
DATA_HASH=${DATA_HASH:-"$(pwd)/.ethash"}
echo "Destroying old container $CONTAINER_NAME..."
docker stop $CONTAINER_NAME
docker rm $CONTAINER_NAME
RPC_PORTMAP=
RPC_ARG=
if [[ ! -z $RPC_PORT ]]; then
# RPC_ARG='--ws --wsaddr=0.0.0.0 --wsport 8546 --wsapi=db,eth,net,web3,personal --wsorigins "*" --rpc --rpcaddr=0.0.0.0 --rpcport 8545 --rpcapi=db,eth,net,web3,personal --rpccorsdomain "*"'
RPC_ARG='--rpc --rpcaddr=0.0.0.0 --rpcport 8545 --rpcapi=db,eth,net,web3,personal --rpccorsdomain "*"'
RPC_PORTMAP="-p $RPC_PORT:8545"
fi
BOOTNODE_URL=${BOOTNODE_URL:-$(./getbootnodeurl.sh)}
if [ ! -f $(pwd)/genesis.json ]; then
echo "No genesis.json file found, please run 'genesis.sh'. Aborting."
exit
fi
if [ ! -d $DATA_ROOT/keystore ]; then
echo "$DATA_ROOT/keystore not found, running 'geth init'..."
docker run --rm \
-v $DATA_ROOT:/root/.ethereum \
-v $(pwd)/genesis.json:/opt/genesis.json \
$IMGNAME init /opt/genesis.json
echo "...done!"
fi
echo "Running new container $CONTAINER_NAME..."
docker run $DETACH_FLAG --name $CONTAINER_NAME \
--network ethereum \
-v $DATA_ROOT:/root/.ethereum \
-v $DATA_HASH:/root/.ethash \
-v $(pwd)/genesis.json:/opt/genesis.json \
$RPC_PORTMAP \
$IMGNAME --bootnodes=$BOOTNODE_URL $RPC_ARG --cache=512 --verbosity=4 --maxpeers=3 ${@:2}