forked from alastria/alastria-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·121 lines (102 loc) · 3.83 KB
/
start.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
set -u
set -e
MESSAGE='Usage: start.sh <--clean> <--monitor> <--watch>'
MONITOR=0
WATCH=0
CLEAN=0
while [[ $# -gt 0 ]]
do
key="$1"
case "$key" in
-m|-M|--monitor)
MONITOR=1
;;
-w|-W|--watch)
WATCH=1
;;
-c|-C|--clean)
CLEAN=1
;;
-h|-H|--help)
echo $MESSAGE
exit
;;
esac
shift
done
CURRENT_HOST_IP="$(dig +short myip.opendns.com @resolver1.opendns.com 2>/dev/null || curl -s --retry 2 icanhazip.com)"
CONSTELLATION_PORT=9000
check_constellation_isStarted(){
set +e
RETVAL=""
while [ "$RETVAL" == "" ]
do
RETVAL="$(ss -nutlp | grep $CONSTELLATION_PORT)"
[ "$RETVAL" != "" ] && echo "[*] constellation node at $CONSTELLATION_PORT is now up."
[ "$RETVAL" == "" ] && echo "[*] constellation node at $CONSTELLATION_PORT is still starting. Awaiting 5 seconds." && sleep 5
done
echo "[*] resuming start procedure"
set -e
}
NETID=82584648528
mapfile -t IDENTITY <~/alastria/data/IDENTITY
GLOBAL_ARGS="--networkid $NETID --identity $IDENTITY --permissioned --rpc --rpcaddr 0.0.0.0 --rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,istanbul --rpcport 22000 --port 21000 --istanbul.requesttimeout 10000 --ethstats $IDENTITY:bb98a0b6442386d0cdf8a31b267892c1@netstats.testnet.alastria.io.builders:80 --verbosity 3 --vmdebug --emitcheckpoints --targetgaslimit 18446744073709551615 --syncmode full --vmodule consensus/istanbul/core/core.go=5 "
_TIME=$(date +%Y%m%d%H%M%S)
mapfile -t NODE_TYPE <~/alastria/data/NODE_TYPE
if ([ $CLEAN -gt 0 ])
then
echo "Cleaning your node ..."
rm -rf ~/alastria/logs/quorum_*
rm -rf ~/alastria/data/geth/chainData
rm -rf ~/alastria/data/geth/nodes
rm -f ~/alastria/data/geth/transactions.rlp
rm -f ~/alastria/data/geth.ipc
rm -rf ~/alastria/data/constellation/data
rm -f ~/alastria/data/constellation/constellation.ipc
rm -rf ~/alastria/data/geth/lightchaindata
rm -rf ~/alastria/data/geth/chaindata
./init.sh auto $NODE_TYPE $IDENTITY
fi
CONSTELLATION=${ENABLE_CONSTELLATION:-}
if [ "$NODE_TYPE" == "general" ] && [ ! -z "$CONSTELLATION" ]; then
echo "[*] Starting Constellation node"
nohup constellation-node ~/alastria/data/constellation/constellation.conf 2>> ~/alastria/logs/constellation_"${_TIME}".log &
check_constellation_isStarted
fi
if [[ ! -f "permissioned-nodes.json" ]]; then
# Se corrige el arranque del nodo en docker.
rm -Rf permissioned-nodes.json
# Esto es necesario por un bug de Quorum https://github.com/jpmorganchase/quorum/issues/225
ln -s ~/alastria/data/permissioned-nodes.json permissioned-nodes.json
echo "Relinking permissioning file"
fi
echo "[*] Starting quorum node"
if [[ "$NODE_TYPE" == "general" ]]; then
if [[ ! -z "$CONSTELLATION" ]]; then
nohup env PRIVATE_CONFIG=~/alastria/data/constellation/constellation.conf geth --datadir ~/alastria/data $GLOBAL_ARGS 2>> ~/alastria/logs/quorum_"${_TIME}".log &
else
nohup env geth --datadir ~/alastria/data $GLOBAL_ARGS 2>> ~/alastria/logs/quorum_"${_TIME}".log &
fi
else
if [[ "$NODE_TYPE" == "validator" ]]; then
if [[ "$CURRENT_HOST_IP" == "52.56.69.220" ]]; then
nohup geth --datadir ~/alastria/data $GLOBAL_ARGS --mine --minerthreads $(grep -c "processor" /proc/cpuinfo) --unlock 0 --password ~/alastria/data/passwords.txt 2>> ~/alastria/logs/quorum_"${_TIME}".log &
else
nohup geth --datadir ~/alastria/data $GLOBAL_ARGS --mine --minerthreads $(grep -c "processor" /proc/cpuinfo) 2>> ~/alastria/logs/quorum_"${_TIME}".log &
fi
fi
fi
if ([ $MONITOR -gt 0 ])
then
echo "[*] Monitor enabled. Starting monitor..."
RP=`readlink -m "$0"`
RD=`dirname "$RP"`
nohup $RD/monitor.sh start > /dev/null &
fi
if ([ $WATCH -gt 0 ])
then
tail -100f ~/alastria/logs/quorum_"${_TIME}".log
fi
set +u
set +e