forked from dk808/Raptoreum_SmartNode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
77 lines (71 loc) · 1.51 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
#!/bin/bash
EXECUTABLE='thetad'
DIR='/theta/.thetacore'
CONF_FILE='theta.conf'
FILE=$DIR/$CONF_FILE
# Create directory and config file if it does not exist yet
if [ ! -e "$FILE" ]; then
mkdir -p $DIR
if [ -n "$BLS_KEY" ]; then
cat << EOF > $FILE
rpcuser=$(pwgen -1 8 -n)
rpcpassword=$(pwgen -1 20 -n)
rpcallowip=127.0.0.1
rpcbind=127.0.0.1
index=1
txindex=1
addressindex=1
server=1
listen=1
par=2
dbcache=1024
smartnodeblsprivkey=${BLS_KEY}
externalip=${EXTERNALIP}
addnode=chain.thetaspere.com
addnode=91.90.11.205
addnode=78.186.117.161
addnode=84.42.20.117
addnode=37.192.138.15
addnode=5.2.212.100
addnode=81.133.36.219
addnode=31.173.170.169
addnode=185.31.32.208
EOF
else
cat << EOF > $FILE
rpcuser=$(pwgen -1 8 -n)
rpcpassword=$(pwgen -1 20 -n)
rpcallowip=127.0.0.1
rpcbind=127.0.0.1
server=1
listen=1
addnode=chain.thetaspere.com
addnode=91.90.11.205
addnode=78.186.117.161
addnode=84.42.20.117
addnode=37.192.138.15
addnode=5.2.212.100
addnode=81.133.36.219
addnode=31.173.170.169
addnode=185.31.32.208
EOF
fi
fi
# Create script for HEALTHCHECK
if [ ! -e /usr/local/bin/healthcheck.sh ]; then
touch healthcheck.sh
cat << EOF > healthcheck.sh
#!/bin/bash
POSE_SCORE=\$(curl -s "https://chain.thetaspere.com/api/protx?command=info&protxhash=${PROTX_HASH}" | jq -r '.state.PoSePenalty')
if ((POSE_SCORE>0)); then
kill -15 -1
sleep 15
kill -9 -1
else
echo "Smartnode seems to be healthy..."
fi
EOF
chmod 755 healthcheck.sh
mv healthcheck.sh /usr/local/bin
fi
exec $EXECUTABLE -datadir=$DIR -conf=$FILE