-
Notifications
You must be signed in to change notification settings - Fork 8
/
ftparseports.sh
78 lines (75 loc) · 3.38 KB
/
ftparseports.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
OLDIFS=$IFS
IFS=''
# Get all ports. Uses c1grep function instead of grep so as to not trigger ERROR trap code 1 (no line found) which is intended
MEMORYCONFIG=$(cat $CURRENTCONFIG | c1grep -e '^harvester:' -e '^farmer:' -e '^full_node:' -e '^timelord:' -e '^timelord_launcher:' -e '^ui:' -e '^introducer:' -e '^wallet:' -e '^logging:' -e 'port: ' -e '_peer:' -e 'vdf_server:' )
SECTION=''
TESTSECTION=''
while read line; do
WORKLINE=$(sed 's/#.*//' <<< "$line" ) # This removes any comments from consideration for alteration
if [[ $WORKLINE == *default_full_node_port* || $WORKLINE == *log_syslog_port* ]]; then
continue
fi
TESTSECTION=$(c1grep -e '^harvester:' -e '^farmer:' -e '^full_node:' -e '^timelord:' -e '^timelord_launcher:' -e '^ui:' -e '^introducer:' -e '^wallet:' -e '^logging:' <<< "$WORKLINE" )
if [[ $TESTSECTION != '' && $TESTSECTION != $SECTION ]]; then
SECTION=$TESTSECTION
fi
if [[ $LASTLINE == *_peer:* || $LASTLINE == *vdf_server:* ]]; then
LASTLINE=$WORKLINE
continue
fi
LASTLINE=$WORKLINE
if [[ $SECTION == *full_node:* && $WORKLINE == *rpc_port:* ]]; then
FULLNODERPCPORT=$(sed 's/rpc_port: //' <<< "$WORKLINE" | awk '{$1=$1};1')
continue
fi
if [[ $SECTION == *full_node:* && $WORKLINE == *port:* ]]; then
FULLNODEPORT=$(sed 's/port: //' <<< "$WORKLINE" | awk '{$1=$1};1')
continue
fi
if [[ $SECTION == *farmer:* && $WORKLINE == *rpc_port:* ]]; then
FARMERRPCPORT=$(sed 's/rpc_port: //' <<< "$WORKLINE" | awk '{$1=$1};1')
continue
fi
if [[ $SECTION == *farmer:* && $WORKLINE == *port:* ]]; then
FARMERPORT=$(sed 's/port: //' <<< "$WORKLINE" | awk '{$1=$1};1')
continue
fi
if [[ $SECTION == *harvester:* && $WORKLINE == *rpc_port:* ]]; then
HARVESTERRPCPORT=$(sed 's/rpc_port: //' <<< "$WORKLINE" | awk '{$1=$1};1')
continue
fi
if [[ $SECTION == *harvester:* && $WORKLINE == *port:* ]]; then
HARVESTERPORT=$(sed 's/port: //' <<< "$WORKLINE" | awk '{$1=$1};1')
continue
fi
if [[ $SECTION == *wallet:* && $WORKLINE == *rpc_port:* ]]; then
WALLETRPCPORT=$(sed 's/rpc_port: //' <<< "$WORKLINE" | awk '{$1=$1};1')
continue
fi
if [[ $SECTION == *wallet:* && $WORKLINE == *port:* ]]; then
WALLETPORT=$(sed 's/port: //' <<< "$WORKLINE" | awk '{$1=$1};1')
continue
fi
if [[ $SECTION == *ui:* && $WORKLINE == *rpc_port:* ]]; then
UIRPCPORT=$(sed 's/rpc_port: //' <<< "$WORKLINE" | awk '{$1=$1};1')
continue
fi
if [[ $SECTION == *ui:* && $WORKLINE == *port:* && $WORKLINE != *daemon_port:* ]]; then
UIPORT=$(sed 's/port: //' <<< "$WORKLINE" | awk '{$1=$1};1')
continue
fi
if [[ $SECTION == *timelord_launcher:* && $WORKLINE == *port:* ]]; then
TIMELORDLAUNCHERPORT=$(sed 's/port: //' <<< "$WORKLINE" | awk '{$1=$1};1')
continue
fi
if [[ $SECTION == *timelord:* && $WORKLINE == *port:* ]]; then
TIMELORDPORT=$(sed 's/port: //' <<< "$WORKLINE" | awk '{$1=$1};1')
continue
fi
if [[ $SECTION != *ui:* && $WORKLINE == *daemon_port:* ]]; then
DAEMONPORT=$(sed 's/daemon_port: //' <<< "$WORKLINE" | awk '{$1=$1};1')
continue
fi
done < <(printf '%s\n' "$MEMORYCONFIG")
IFS=$OLDIFS
PORTPARSINGDONE=1