-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathpacketsearch
More file actions
288 lines (262 loc) · 6.44 KB
/
packetsearch
File metadata and controls
288 lines (262 loc) · 6.44 KB
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
#!/bin/bash
#script for quick Winlink packet station search
#16FEB2021 KM4ACK
#06MARCH2022 last edit KM4ACK
VERSION=2
CHANGELOG(){
clear;echo;echo;HEADER
cat <<EOF
Version 2 06MARCH2022:
Update config variable to accomadate new config file location in Pat 12
Add pause if dependencies are missing to allow operator time to read
improve distance search output
improve grid search output
add changelog
EOF
read -n 1 -s -r -p "Press any key to continue"
}
#Default is to use USA grid map
MAP=/home/pi/patmenu2/grid-map.pdf
#Uncomment line below to use world grid map
#MAP=/home/pi/patmenu2/worldgridmap.pdf
VERSION=$(pat version | awk -F "." '{print $2}')
if [ "$VERSION" -ge '12' ]; then
CONFIG="$HOME/.config/pat/config.json"
else
CONFIG=$HOME/.wl2k/config.json
fi
UPDATEGRID(){
#CONFIG=$HOME/.wl2k/config.json
WHO=$(whoami)
clear;echo;echo
HEADER
cat <<EOF
Distances are calculated based on the grid square in your Pat
configure file at the time of download. Normally this is your
home grid square. If travelling, you may wish to update your
grid based on the location you will be travelling to and download
a new list which will reflect the actual grid from which you will
be operating.
EOF
echo;echo
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "DO NOT USE THIS FEATURE WITHOUT AN INTERNET CONNECTION"
echo "Doing so may result in loss of your current list"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++"
read -p "Would you like to update your grid & download a new list? y/n " ANS
if [ "$ANS" = 'Y' ] || [ $ANS = 'y' ]; then
read -p "Six digit grid to use? " GRID
sed -i "s/\"locator\": \".*\",/\"locator\": \"$GRID\",/" $CONFIG
sudo killall pat
sudo systemctl start pat@$WHO
$HOME/patmenu2/getardoplist
fi
}
VERIFY(){
#This section used to verify dependancies installed
if [ ! -f $HOME/bin/grid-calc ]; then
GRIDCALC="Grid-Calc not installed"
fi
if [ ! -d $HOME/patmenu2 ]; then
PATMENU="Pat Menu not installed"
fi
if ! hash pat 2>/dev/null; then
PAT="Pat Winlink not installed"
fi
if [ ! -z "$GRIDCALC" ] || [ ! -z "$PATMENU" ] || [ ! -z "$PAT" ]; then
echo "===================="
echo "Dependancies Missing"
echo "===================="
echo "$GRIDCALC"
echo "$PATMENU"
echo "$PAT"
echo "Please use Build a Pi to install missing dependancies."
read -n 1 -s -r -p "Press any key to continue"
exit
fi
}
VERIFY
MENUITEM(){
cat > /run/user/$UID/packetsearch.desktop <<EOF
[Desktop Entry]
Name=PacketSearch
GenericName=Search for Winlink Packet Gateways
Comment=Search for Winlink Packet Gateways
Exec=$HOME/bin/packetsearch
Icon=/usr/share/icons/gnome/32x32/apps/openterm.png
Terminal=true
Type=Application
Categories=Utility;HamRadio
EOF
sudo mv /run/user/$UID/packetsearch.desktop /usr/share/applications/
}
if [ ! -f /usr/share/applications/packetsearch.desktop ]; then
MENUITEM
echo "Menu shortcut created for PacketSearch"
echo "Start PacketSearch from the pi menu"
read -n 1 -s -r -p "Press any key to continue"
exit 0
fi
PACKETFILE=$HOME/patmenu2/ardop-list/packet.txt
DATE=$(date +%m%d%Y)
HEADER(){
echo "===========PACKET SEARCH by KM4ACK=============="
}
if [ $1 = 'changelog' ]; then
CHANGELOG
fi
PKTSEARCH(){
clear;echo;echo
HEADER
read -p "Call sign to search for? " CALL
clear;echo;echo
HEADER
echo "Call Grid Dist Speed Frequency"
echo "================================================"
RESULT=$(grep -i $CALL $PACKETFILE | awk '{print $1" "$2" "$3" "$5"-"$6" "$7}')
if [ -z "$RESULT" ]; then
echo "Nothing Found"
fi
echo $RESULT
read -p "New Search? y/n " ANS
case $ANS in
y | Y)
PKTSEARCH
;;
*)
break
;;
esac
}
DISTSEARCH(){
clear;echo;echo
HEADER
read -p "What is the distance to be searched? " DISTANCE
clear;echo;echo
FILE=$HOME/patmenu2/ardop-list/packet.txt
NEWFILE=/run/user/$UID/temppacket.txt
OUTFILE=/run/user/$UID/packetout.txt
touch $NEWFILE
cp $FILE $NEWFILE
sed -i '/^$/d' $NEWFILE
sed -i '1d' $NEWFILE
sed -i '1d' $NEWFILE
sed -i '1d' $NEWFILE
sed -i '1d' $NEWFILE
HEADER
echo "Call Grid Dist Speed Frequency"
echo "================================================"
while read LINE; do
DIST=$(echo $LINE | awk '{print $3}')
if [ "$DIST" -le "$DISTANCE" ]; then
echo $LINE | awk '{print $1" "$2" "$3" "$5"-"$6" "$7}' >> $OUTFILE
echo $LINE | awk '{print $1" "$2" "$3" "$5"-"$6" "$7}'
else
break
fi
done < $NEWFILE
echo "End of search"
read -p "Save list to desktop? y/n " ANS
if [ $ANS = 'y' ] || [ $ANS = 'Y' ]; then
cp $OUTFILE $HOME/Desktop/packet-list-distance-$DATE
fi
rm $NEWFILE
rm $OUTFILE
#read -n 1 -s -r -p "Press any key to continue"
}
GRIDSEARCH(){
OUTFILE=/run/user/$UID/packetout.txt
clear;echo;echo
read -p "Four Character Grid to search? " GRID
if [ -z $GRID ]; then
GRID=EM65
fi
clear;echo;echo
HEADER
echo "Call Grid Dist Speed Frequency"
echo "================================================"
grep -i $GRID $PACKETFILE | awk '{print $1" "$2" "$3" "$5"-"$6" "$7}'
grep -i $GRID $PACKETFILE | awk '{print $1" "$2" "$3" "$5"-"$6" "$7}' > $OUTFILE
read -p "Save list to desktop? y/n " ANS
if [ $ANS = 'y' ] || [ $ANS = 'Y' ]; then
cp $OUTFILE $HOME/Desktop/packet-list-grid-$DATE
fi
rm $OUTFILE
#read -n 1 -s -r -p "Press any key to continue"
}
GRIDCALC(){
if [ ! -f $HOME/bin/grid-calc ]; then
clear;echo;echo
echo "Grid calc not installed"
read -p "Install now? y/n " ANS
if [ $ANS = 'y' ] || [ $ANS = 'Y' ]; then
echo "installing....standby"
cd $HOME/bin
wget https://raw.githubusercontent.com/km4ack/pi-scripts/master/grid-calc
chmod +x grid-calc
$HOME/bin/grid-calc
clear;echo;echo
echo "grid calc installed"
sleep 2
fi
fi
}
MAINMENU(){
clear;echo;echo
HEADER
cat <<EOF
This script will help you find a Winlink packet
station. You can search for a specific station
by call, search by distance, or by grid. Enjoy!
================================================
EOF
PS3="Please choose a number "
SEARCH=("Call Search" "Distance Search" "Grid Search" "Download List" "Open Grid Map" "Open Grid Calc" "Update Grid Square" "Quit")
select ITEM in "${SEARCH[@]}"; do
case $ITEM in
"Distance Search")
DISTSEARCH
MAINMENU
;;
"Call Search")
PKTSEARCH
MAINMENU
;;
"Grid Search")
GRIDSEARCH
MAINMENU
;;
"Download List")
$HOME/patmenu2/getardoplist
MAINMENU
;;
"Open Grid Map")
xdg-open $MAP
echo "opening...standby"
sleep 2
MAINMENU
;;
"Open Grid Calc")
GRIDCALC
echo "opening grid calc"
$HOME/bin/grid-calc &
sleep 2
MAINMENU
;;
"Update Grid Square")
UPDATEGRID
MAINMENU
;;
"Quit")
echo "Goodbye"
exit 0
;;
*)
echo "Invalid Choice"
sleep 1
MAINMENU
;;
esac
done
}
MAINMENU