-
Notifications
You must be signed in to change notification settings - Fork 19
/
start.sh
85 lines (78 loc) · 1.7 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
#!/bin/bash
EXECUTABLE='raptoreumd'
DIR='/raptoreum/.raptoreumcore'
CONF_FILE='raptoreum.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
txindex=1
listen=1
par=2
dbcache=1024
smartnodeblsprivkey=${BLS_KEY}
externalip=${EXTERNALIP}
addnode=explorer.raptoreum.com
addnode=209.151.150.72
addnode=94.237.79.27
addnode=95.111.216.12
addnode=198.100.149.124
addnode=198.100.146.111
addnode=5.135.187.46
addnode=5.135.179.95
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=explorer.raptoreum.com
addnode=raptor.mopsus.com
addnode=209.151.150.72
addnode=94.237.79.27
addnode=95.111.216.12
addnode=198.100.149.124
addnode=198.100.146.111
addnode=5.135.187.46
addnode=5.135.179.95
EOF
fi
fi
# Setup logrotate for debug log
touch /etc/logrotate.d/rtmdebuglog
cat << EOF > /etc/logrotate.d/rtmdebuglog
/raptoreum/.raptoreumcore/debug.log {
compress
copytruncate
missingok
daily
rotate 7
}
EOF
# 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://explorer.raptoreum.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