-
Notifications
You must be signed in to change notification settings - Fork 8
/
ftcheckports.sh
59 lines (56 loc) · 2.85 KB
/
ftcheckports.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
# Checks what processes are running. Tricky when forks use chia_process names.
# If forkname_process isn't found, check for a chia process with the fork's port
# PREREQUISITES FOR USE OF THIS INCLUDE:
# FORKNAME must be set
# PROCESSEF=$(ps -ef | grep -e 'full_node' -e 'farmer' -e 'harvester' -e 'wallet' -e '_daemon' | grep -v grep | awk '{ print $8 } ' | sort | uniq )
# CHIAPROCS=$(forkss | grep "\"chia" )
# We don't do the last two here because this include can be called inside a loop, and we only want to run those once for performance reasons
PROPERPROCESSNAMES=0
CURRENTCONFIG=$FORKTOOLSHIDDENDIRS/.$FORKNAME/mainnet/config/config.yaml
USINGCHIAPROCESSNAMES=0
SERVICESRUNNING=''
for process in daemon full_node farmer harvester wallet; do
PROCESSRUNNING=1 # Assume it's running, then set it to 0 if we can't find supporting evidence
PROCESSNAME=$( echo "${FORKNAME}_${process}" )
CHECKRUNNING=$( echo $PROCESSEF | c1grep -c -e $PROCESSNAME )
if [[ $CHECKRUNNING > 0 && $FORKNAME != 'chia' ]]; then
PROPERPROCESSNAMES=1 # It found a process - probabaly daemon - named correctly and running
fi
if [[ $CHECKRUNNING == 0 || $FORKNAME == 'chia' ]]; then
if [[ $PROPERPROCESSNAMES == 1 && $CHECKRUNNING == 0 ]]; then # So any we don't find really aren't running
PROCESSRUNNING=0
else
if [[ $PORTPARSINGDONE != 1 ]]; then
. $FORKTOOLSDIR/ftparseports.sh
fi
case "$process" in
"daemon" ) PORTTOSEARCH=$DAEMONPORT;;
"full_node" ) PORTTOSEARCH=$FULLNODEPORT;;
"farmer" ) PORTTOSEARCH=$FARMERRPCPORT;;
"harvester" ) PORTTOSEARCH=$HARVESTERRPCPORT;;
"wallet" ) PORTTOSEARCH=$WALLETRPCPORT;;
esac
OLDIFS=$IFS
IFS=''
FORKPORTINUSE=$(echo $CHIAPROCS | grep "\"chia_$process" | grep -c ":${PORTTOSEARCH} " )
IFS=$OLDIFS
if [[ $FORKPORTINUSE == 0 ]]; then
PROCESSRUNNING=0
else
USINGCHIAPROCESSNAMES=1
fi
fi
fi
SINGLESERVICE='N'
if [[ $PROCESSRUNNING = 1 ]]; then
SINGLESERVICE='Y'
fi
case "$process" in
"daemon" ) DAEMONRUNNING=$PROCESSRUNNING; SERVICESRUNNING+=$SINGLESERVICE;;
"full_node" ) FULLNODERUNNING=$PROCESSRUNNING; SERVICESRUNNING+=$SINGLESERVICE;;
"farmer" ) FARMERRUNNING=$PROCESSRUNNING; SERVICESRUNNING+=$SINGLESERVICE;;
"harvester" ) HARVESTERRUNNING=$PROCESSRUNNING; SERVICESRUNNING+=$SINGLESERVICE;;
"wallet" ) WALLETRUNNING=$PROCESSRUNNING; SERVICESRUNNING+=$SINGLESERVICE;;
esac
done
# echo $DAEMONRUNNING $FULLNODERUNNING $FARMERRUNNING $HARVESTERRUNNING $WALLETRUNNING