gethup.sh

docker exec -it geth-cluster1 /bin/bash
geth –datadir data0 –networkid 779977 console

root@85547cf26bca:/ethutil# cat gethup.sh 
#!/bin/bash
# Usage:
# bash /path/to/eth-utils/gethup.sh <datadir> <instance_name>

root=$1  # base directory to use for datadir and logs
shift
dd=$1  # double digit instance id like 00 01 02
shift
nodegroup=$1  # nodegroup 0,1,2,...
shift
mine=$1    # mine Y or No
shift

# logs are output to a date-tagged file for each run , while a link is
# created to the latest, so that monitoring be easier with the same filename
# TODO: use this if GETH not set
GETH=geth

# geth CLI params       e.g., (dd=04, run=09)
datetag=`date "+%c%y%m%d-%H%M%S"|cut -d ' ' -f 5`
datadir=$root/data/$dd        # /tmp/eth/04
log=$root/log/$dd.$datetag.log     # /tmp/eth/04.09.log
linklog=$root/log/$dd.current.log     # /tmp/eth/04.09.log
stablelog=$root/log/$dd.log     # /tmp/eth/04.09.log
password=$dd            # 04
port=303$dd              # 30304
rpcport=82$dd            # 8104

mkdir -p $root/data
mkdir -p $root/log
ln -sf "$log" "$linklog"
# if we do not have an account, create one
# will not prompt for password, we use the double digit instance id as passwd
# NEVER EVER USE THESE ACCOUNTS FOR INTERACTING WITH A LIVE CHAIN
if [ ! -d "$root/keystore/$dd" ]; then
  echo create an account with password $dd [DO NOT EVER USE THIS ON LIVE]
  mkdir -p $root/keystore/$dd
  $GETH --datadir $datadir --password <(echo -n $dd) account new
# create account with password 00, 01, ...
  # note that the account key will be stored also separately outside
  # datadir
  # this way you can safely clear the data directory and still keep your key
  # under `<rootdir>/keystore/dd

  cp -R "$datadir/keystore" $root/keystore/$dd
fi

# echo "copying keys $root/keystore/$dd $datadir/keystore"
# ls $root/keystore/$dd/keystore/ $datadir/keystore

# mkdir -p $datadir/keystore
# if [ ! -d "$datadir/keystore" ]; then
echo "copying keys $root/keystore/$dd $datadir/keystore"
cp -R $root/keystore/$dd/keystore/ $datadir/
# fi

BZZKEY=`$GETH --datadir=$datadir account list|head -n1|perl -ne '/([a-f0-9]{40})/ && print $1'`

# bring up node `dd` (double digit)
# - using <rootdir>/<dd>
# - listening on port 303dd, (like 30300, 30301, ...)
# - with the account unlocked
# - launching json-rpc server on port 81dd (like 8100, 8101, 8102, ...)

the_mine=""
if [ "$mine"x = "Y"x ]; then
  the_mine="--mine --minerthreads 1"
else
  the_mine="--fast"
fi

the_bootnodes=""
if [[ "$nodegroup"x != "0"x || "$dd"x != "00"x ]]; then
  the_bootnodes=`cat $CLUSTER_SHAREDIR/bootnode-ip`
  the_bootnodes="--bootnodes $the_bootnodes"
fi

echo "$GETH --datadir=$datadir $the_mine $the_bootnodes \
  --identity="$dd" \
  --port=$port \
  --unlock=$BZZKEY \
  --password=<(echo -n $dd) \
  --rpcapi "db,eth,net,web3,admin"  \
  --rpc --rpcport=$rpcport --rpccorsdomain '*' $* \
  2>&1 | tee "$stablelog" > "$log" &  # comment out if you pipe it to a tty etc.
"

  #--rpc --rpcport=$rpcport --rpccorsdomain '*' $* \
$GETH --datadir=$datadir $the_mine $the_bootnodes \
  --identity="$dd" \
  --port=$port \
  --unlock=$BZZKEY \
  --password=<(echo -n $dd) \
  --rpcapi "db,eth,net,web3,admin"  \
  --rpc --rpcport=$rpcport --rpccorsdomain '*' $* \
  2>&1 | tee "$stablelog" > "$log" &  # comment out if you pipe it to a tty etc.

# to bring up logs, uncomment
# tail -f $log

docker run -i blockchain101/ethereum-geth:1.6.5 geth attach http://45.32.36.97:8201

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值