forked from ethersphere/eth-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gethup.sh
81 lines (69 loc) · 2.72 KB
/
gethup.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/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
# 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=311$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/keystore/
# 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, ...)
echo "$GETH --datadir=$datadir \
--identity="$dd" \
--bzzaccount=$BZZKEY --bzzport=86$dd \
--port=$port \
--unlock=$BZZKEY \
--password=<(echo -n $dd) \
--rpc --rpcport=$rpcport --rpccorsdomain='*' $* \
2>&1 | tee "$stablelog" > "$log" & # comment out if you pipe it to a tty etc.
"
$GETH --datadir=$datadir \
--identity="$dd" \
--bzzaccount=$BZZKEY --bzzport=86$dd \
--port=$port \
--unlock=$BZZKEY \
--password=<(echo -n $dd) \
--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