forked from rykcod/massa
-
Notifications
You must be signed in to change notification settings - Fork 8
/
massa-guard.sh
47 lines (37 loc) · 1014 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
45
46
47
#!/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
DYNIP="${DYNIP:-0}"
TARGET_ROLL_AMOUNT="${TARGET_ROLL_AMOUNT:-0}"
MINIMAL_FEE="${MINIMAL_FEE:-0}"
#==================== 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