forked from EA7KDO/NX4832K035
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetlastgw.sh
executable file
·55 lines (41 loc) · 1.25 KB
/
getlastgw.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
#!/bin/bash
#################################################
# Get Last Heard Network from DMRGateway #
# #
# #
# VE3RD 2020-11-29 #
#################################################
set -o errexit
set -o pipefail
function getstring
{
# Step 1 - Get newest dmrgateway log file
f1=$(ls -art /var/log/pi-star/DMRG* | tail -n1)
# echo "File: $f1"
# Sterp 2 - Get the last line that contains 'Name='
line=$(grep Name= $f1 | tail -n 1)
# echo "1:$line"
# Step 3 - Get Param 4 to Determine RF or Network
type=$(echo "$line" | cut -d' ' -f4)
# echo "type=$type"
# Step 4 Get Network Name and Number
if [ "$type" = "RF" ]; then
tt1=$(echo "$line" | cut -d' ' -f6 | cut -d'=' -f2) # Net Name
tt2=$(echo "$line" | cut -d' ' -f7 | cut -d'=' -f2) # Net Number
echo "GW R Net $tt2 $tt1"
fi
if [ "$type" = "Network" ]; then
t1=$(echo "$line" | cut -d' ' -f8 | cut -d'=' -f2) #Net Name
t2=$(echo "$line" | cut -d' ' -f5) #Net Number
echo "GW N Net $t2 $t1"
fi
}
Addr=$(sed -nr "/^\[DMR Network\]/ { :l /^Address[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" /etc/mmdvmhost)
#Check to see if we are running the DMRGatewy
if [ $Addr = "127.0.0.1" ]; then
GW="ON"
getstring
else
# We are not Running the Gateway - Do Nothing
GW="OFF"
fi