-
Notifications
You must be signed in to change notification settings - Fork 9
/
.getardoplist-cron
executable file
·181 lines (140 loc) · 4.36 KB
/
.getardoplist-cron
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/bash
#This script will download the ardop list to the path set below
#It is intended to be run by cron daily
#to keep the list current. km4ack 20181214
#Hint: create a cron job that reads
#30 23 * * * /usr/local/bin/getardoplist
#This script is provided AS IS
#Feel free to mod for your use
#Two versions of this script exist. One for manual downloads and
#one for cron downloads. The one for cron has no YAD interface.
#Cron wouldn't run correctly with YAD in the code. The other file
#is .getardoplist-cron
TODAY=$(date)
#path where files are located
#must match path in findardop script
MYPATH=$HOME/patmenu2/ardop-list/
MYVARA=$HOME/patmenu2/vara-list/
#my log file
LOG=$HOME/Documents/mylog.txt
#set config file location for pat version
VERSION=$(pat version | awk '{print $2}' | awk -F "." '{print $2}')
if [ $VERSION -le 11 ]; then
MYCONFIG=$HOME/.wl2k/config.json
else
MYCONFIG=$HOME/.config/pat/config.json
fi
GRIDCK=$(jq .locator $MYCONFIG)
if [ ${#GRIDCK} -lt 3 ]
then
echo "Grid square not set in Pat Configure" | tee -a $LOG
echo "Distances/Bearings will not be accurate"
exit
fi
GRID=$(grep locator $MYCONFIG | sed 's/"locator"://;s/"//g;s/,//;s/ //g')
echo "GRID=$GRID" > $HOME/patmenu2/.grid
#make directory if it doesn't exist
mkdir -p $MYPATH
mkdir -p $MYVARA
#set variables for each ARDOP list
FILE=$MYPATH'ardoplist.txt'
EIGHTY=$MYPATH'80mardoplist.txt'
FORTY=$MYPATH'40mardoplist.txt'
TWENTY=$MYPATH'20mardoplist.txt'
THIRTY=$MYPATH'30mardoplist.txt'
PACKET=$MYPATH'packet.txt'
#set variables for each vara list
VARAFILE=$MYVARA'varalist.txt'
VARAEIGHTY=$MYVARA'80mvaralist.txt'
VARAFORTY=$MYVARA'40mvaralist.txt'
VARATWENTY=$MYVARA'20mvaralist.txt'
VARATHIRTY=$MYVARA'30mvaralist.txt'
VARAFM=$MYVARA'varafm.txt'
#check internet connection
echo "Please wait while we check your internet connection"
echo "This may take up to a minute"
wget -q --tries=5 --timeout=10 --spider http://google.com
if [[ $? -eq 0 ]]; then
echo
echo
echo "Please wait while files are download"
echo "This may take several minutes"
echo "Depending on your internet speed"
else
#check for internet before attempting to download the list
internet=1 #set the test to false
while [ "$internet" = 1 ]; do
echo "check for internet connection"
ping -c 5 8.8.8.8
internet=$?
sleep 60 #wait one minute before trying again
done
echo "Internet connection detected"
fi
#remove old vara files before downloading new ones
if [ -f $VARATHIRTY ]; then
rm $VARATHIRTY
fi
if [ -f $VARAFILE ]; then
rm $VARAFILE
fi
if [ -f $VARAEIGHTY ]; then
rm $VARAEIGHTY
fi
if [ -f $VARAFORTY ]; then
rm $VARAFORTY
fi
if [ -f $VARATWENTY ]; then
rm $VARATWENTY
fi
if [ -f $VARAFM ]; then
rm $VARAFM
fi
#remove old ARDOP files before downloading new ones
if [ -f $THIRTY ]; then
rm $THIRTY
fi
if [ -f $FILE ]; then
rm $FILE
fi
if [ -f $EIGHTY ]; then
rm $EIGHTY
fi
if [ -f $FORTY ]; then
rm $FORTY
fi
if [ -f $TWENTY ]; then
rm $TWENTY
fi
if [ -f $PACKET ]; then
rm $PACKET
fi
#create file that has grid variable used in calculations
touch $HOME/patmenu2/ardop-list/grid.txt
MYGRID=$(grep locator $HOME/.config/pat/config.json | sed 's/.*": //;s/"//g;s/,//')
echo "GRID=$MYGRID" > $HOME/patmenu2/ardop-list/grid.txt
echo "LASTDL=List downloaded `date`" >> $HOME/patmenu2/ardop-list/grid.txt
#download list to individual files.
DL(){
pat rmslist -s --mode ardop --force-download >> $FILE
pat rmslist -s --band 80m --mode ardop --force-download >> $EIGHTY
pat rmslist -s --band 40m --mode ardop --force-download >> $FORTY
pat rmslist -s --band 20m --mode ardop --force-download >> $TWENTY
pat rmslist -s --band 30m --mode ardop --force-download >> $THIRTY
pat rmslist -s --mode packet --force-download >> $PACKET
pat rmslist -s --mode vara --force-download >> $VARAFILE
pat rmslist -s --band 80m --mode vara --force-download >> $VARAEIGHTY
pat rmslist -s --band 40m --mode vara --force-download >> $VARAFORTY
pat rmslist -s --band 20m --mode vara --force-download >> $VARATWENTY
pat rmslist -s --band 30m --mode vara --force-download >> $VARATHIRTY
pat rmslist -s --band 2m --mode varafm --force-download >> $VARAFM
}
DL
if [ -f "$FILE" ]
then
echo $TODAY" RMS Gateway list download Success" >> $LOG
echo;echo "RMS gateway list download success"
else
echo $TODAY" RMS Gateway list download FAIL" >> $LOG
echo;echo "RMS gateway list failed to download"
fi