forked from peterjah/massa-core-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmassa-guard.sh
44 lines (34 loc) · 916 Bytes
/
massa-guard.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
#!/bin/bash
# Import custom library
. /massa-guard/sources/lib.sh
WaitBootstrap
#====================== Check and load ==========================#
# Load Wallet and Node key or create it and stake wallet
CheckOrCreateWalletAndNodeKey
#==================== Massa-guard circle =========================#
# Infinite check
while true; do
# Check node status
CheckNodeResponsive
NodeResponsive=$?
# Check ram consumption percent in integer
CheckNodeRam
ramCheck=$?
# Restart node if issue
if [[ $NodeResponsive -eq 1 || $ramCheck -eq 1 ]]; then
RestartNode
return
fi
# Buy max roll or 1 roll if possible when candidate roll amount = 0
BuyOrSellRoll
# If dynamical IP feature enable and public IP is new
if [[ "$DYNIP" == "1" ]]; then
CheckPublicIP
publicIpChanged=$?
if [[ $publicIpChanged -eq 1 ]]; then
# Refresh config.toml + restart node
RefreshPublicIP
fi
fi
sleep 2m
done