forked from web3/web3.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeth_binary.sh
executable file
·116 lines (104 loc) · 5.51 KB
/
geth_binary.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
#!/usr/bin/env bash
# TODO: use this code in #5185
ORIGARGS=("$@")
. scripts/env.sh
helpFunction() {
echo "Usage: $0 [start|stop] [background]"
exit 1 # Exit script after printing help
}
getOS(){
case "$OSTYPE" in
solaris*) OS="SOLARIS" ;;
darwin*) OS="OSX" ;;
linux*) OS="LINUX" ;;
bsd*) OS="BSD" ;;
msys*) OS="WINDOWS" ;;
cygwin*) OS="ALSO WINDOWS" ;;
*) OS="unknown: $OSTYPE" ;;
esac
}
getDownloadLink(){
case "$OS" in
SOLARIS*) LINK="-" ;;
OSX*) LINK="https://gethstore.blob.core.windows.net/builds/geth-darwin-arm64-1.13.14-2bd6bd01.tar.gz" ;;
LINUX*) LINK="https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.13.14-2bd6bd01.tar.gz" ;;
BSD*) LINK="https://gethstore.blob.core.windows.net/builds/geth-darwin-arm64-1.13.14-2bd6bd01.tar.gz" ;;
WINDOWS*) LINK="https://gethstore.blob.core.windows.net/builds/geth-windows-amd64-1.13.14-2bd6bd01.exe" ;;
"ALSO WINDOWS"*) LINK="https://gethstore.blob.core.windows.net/builds/geth-windows-amd64-1.13.14-2bd6bd01.exe" ;;
*) LINK="-" ;;
esac
}
setArchiveFolder(){
for entry in $TMP_FOLDER/*
do
FOLDER=$entry
done
}
download(){
if [ ! -e "$TMP_FOLDER/geth" ]
then
getOS
getDownloadLink
if [[ ! -e "$TMP_FOLDER" ]]; then
mkdir "$TMP_FOLDER"
fi
wget -O "$TMP_FOLDER/geth.tar.gz" "$LINK"
tar -xf "$TMP_FOLDER/geth.tar.gz" -C "$TMP_FOLDER"
rm "$TMP_FOLDER/geth.tar.gz"
setArchiveFolder
echo "$FOLDER"
mv "$FOLDER/geth" "$TMP_FOLDER/geth"
rm -rf "$FOLDER"
fi
}
start() {
download
if [ -z "${ORIGARGS[1]}" ]; then
echo "Starting geth..."
echo "geth --ipcpath $IPC_PATH --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev --mine --dev.period=0"
${TMP_FOLDER}/geth --ipcpath $IPC_PATH --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev --mine --dev.period=0 --rpc.enabledeprecatedpersonal
else
echo "Starting geth..."
echo "geth --ipcpath $IPC_PATH --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev --mine --dev.period=0 &>/dev/null &"
${TMP_FOLDER}/geth --ipcpath $IPC_PATH --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev --mine --dev.period=0 --rpc.enabledeprecatedpersonal &>/dev/null &
echo "Waiting for geth..."
npx wait-port -t 10000 "$WEB3_SYSTEM_TEST_PORT"
fi
}
startManual() {
download
echo "Starting manual geth..."
echo "geth --ipcpath $IPC_PATH --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev --mine --dev.period=0 --dev.gaslimit 9000000000000000 --rpc.txfeecap=1000000 &>/dev/null &"
${TMP_FOLDER}/geth --ipcpath $IPC_PATH --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev --mine --dev.period=0 --rpc.enabledeprecatedpersonal --dev.gaslimit 9000000000000000 --rpc.txfeecap=1000000 &>/dev/null &
echo "Waiting for geth..."
npx wait-port -t 10000 "$WEB3_SYSTEM_TEST_PORT"
}
startSync() {
download
${TMP_FOLDER}/geth --datadir ./tmp/data1 init ./scripts/genesis.json
${TMP_FOLDER}/geth --datadir ./tmp/data2 init ./scripts/genesis.json
${TMP_FOLDER}/geth --datadir ./tmp/data1 --ipcpath $IPC_PATH_1 --nodiscover --networkid 1234 --ws --ws.addr 0.0.0.0 --ws.port 18545 --http --http.addr 0.0.0.0 --http.port 18545 --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net &>/dev/null &
${TMP_FOLDER}/geth --datadir ./tmp/data2 --ipcpath $IPC_PATH_2 --nodiscover --networkid 1234 --port 30304 --authrpc.port 8552 --ws --ws.addr 0.0.0.0 --ws.port 28545 --http --http.addr 0.0.0.0 --http.port 28545 --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net &>/dev/null &
npx wait-port -t 10000 18545
npx wait-port -t 10000 28545
}
syncStop() {
WEB3_SYSTEM_TEST_PORT=18545
stop
WEB3_SYSTEM_TEST_PORT=28545
stop
}
stop() {
echo "Stopping geth ..."
processID=`lsof -Fp -i:${WEB3_SYSTEM_TEST_PORT}| grep '^p'`
kill -9 ${processID##p}
}
case $1 in
manualStart) startManual ;;
syncStart) startSync ;;
syncStop) syncStop ;;
start) start ;;
stop) stop ;;
download) download ;;
*) helpFunction ;; # Print helpFunction in case parameter is non-existent
esac