forked from FUSIONFoundation/efsn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
108 lines (88 loc) · 2.58 KB
/
docker-entrypoint.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
#!/bin/sh
NODES_ROOT=/fusion-node
# NODES_ROOT=/Users/work/dev/tmp/fusion-node
DATA_DIR=$NODES_ROOT/data
KEYSTORE_DIR=$DATA_DIR/keystore
unlock=
ethstats=
testnet=
autobt=false
mining=true
display_usage() {
echo "Commands for Fusion efsn:"
echo -e "-e value Reporting name of a ethstats service"
echo -e "-u value Account to unlock"
echo -e "-a Auto buy tickets"
echo -e "-tn Connect to testnet"
}
while [ "$1" != "" ]; do
case $1 in
-u | --unlock ) shift
unlock=$1
;;
-e | --ethstats ) shift
ethstats=$1
;;
-tn | --testnet ) testnet=true
;;
-a | --autobt ) autobt=true
;;
--disable-mining ) mining=false
;;
* ) display_usage
exit 1
esac
shift
done
# create data folder if does not exit
if [ ! -d "$DATA_DIR" ]; then
mkdir $DATA_DIR
fi
# create keystore folder if does not exit
if [ ! -d "$KEYSTORE_DIR" ]; then
mkdir $KEYSTORE_DIR
fi
# copy keystore file
cp $NODES_ROOT/UTC* $KEYSTORE_DIR/ 2>/dev/null
# format command option
cmd_options="--datadir $DATA_DIR --password /fusion-node/password.txt"
if [ "$testnet" ]; then
testnet=" --testnet"
cmd_options=$cmd_options$testnet
fi
if [ "$ethstats" ]; then
if [ "$testnet" ]; then
ethstats=" --ethstats $ethstats:devFusioInfo2019142@devnodestats.fusionnetwork.io"
else
ethstats=" --ethstats $ethstats:fsnMainnet@node.fusionnetwork.io"
fi
cmd_options=$cmd_options$ethstats
fi
if [ "$unlock" ]; then
# pattern=$KEYSTORE_DIR/UTC*
# echo "pater: $pattern"
# keystore_files=($pattern)
# # for f in "${keystore_files[@]}"; do
# # echo "file: $f"
# # done
# echo "file: ${keystore_files[0]}"
# utc_json_address="$(cat < ${keystore_files[0]} | jq -r '.address')"
# echo "utc_json_address: $utc_json_address"
# if [ "$utc_json_address" = "$unlock" ]; then
# echo "$unlock is 'valid'"
# fi
# echo "unlock set to: $unlock"
unlock=" --unlock $unlock"
cmd_options=$cmd_options$unlock
fi
if [ "$autobt" = true ]; then
autobt=" --autobt"
cmd_options=$cmd_options$autobt
fi
if [ "$mining" = true ]; then
mining=" --mine"
cmd_options=$cmd_options$mining
fi
echo "efsn flags: $cmd_options"
# efsn --unlock $unlock --ethstats
exec efsn $cmd_options