-
Notifications
You must be signed in to change notification settings - Fork 71
/
diagnostic
334 lines (296 loc) · 9.55 KB
/
diagnostic
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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
#! /bin/bash
#script to gather some system information
#to help diagnose issues
#20200616 km4ack
#11FEB2021 review km4ack
clear
echo
echo
read -rp "What is your call sign? " CALL
DIR=${HOME}/Desktop/${CALL}-diagnostic-report
#create temp dir
mkdir -p ${DIR}
#check to see which apps are installed
CHECK() {
#----------------------------------------------------#
# Hotspot
#----------------------------------------------------#
HOTSPOT="/usr/bin/autohotspotN"
if [ ! -f "${HOTSPOT}" ]; then
HOTSPOT="Not Installed"
else
HOTSPOT="Installed"
fi
#----------------------------------------------------#
# AX25
#----------------------------------------------------#
if [ ! -d /etc/ax25 ]; then
AX25="Not Installed"
else
AX25="Installed"
fi
#----------------------------------------------------#
# GPS
#----------------------------------------------------#
if ! hash gpsd 2>/dev/null; then
GPS="Not Installed"
else
GPS="Installed"
fi
#----------------------------------------------------#
# PULSE
#----------------------------------------------------#
if ! hash pulseaudio 2>/dev/null; then
PULSE="Not Installed"
else
PULSE="Installed"
fi
#----------------------------------------------------#
# ARDOP
#----------------------------------------------------#
if [ -f ${HOME}/ardop/piardopc ]; then
ARDOP="Installed"
else
ARDOP="Not Installed"
fi
#----------------------------------------------------#
# ARDOP GUI
#----------------------------------------------------#
if [ -f ${HOME}/ardop/piARDOP_GUI ]; then
ARDOPGUI="Installed"
else
ARDOPGUI="Not Installed"
fi
#----------------------------------------------------#
# RIG CONTROL - HAMLIB
#----------------------------------------------------#
if ! hash rigctl 2>/dev/null; then
RIG="Not_Installed"
else
echo "Checking Rig Control"
RIG=$(rigctl --version | grep Hamlib | sed s/"rigctl(d),\ Hamlib\ "//)
NEWRIG=$(curl -s https://sourceforge.net/projects/hamlib/files/latest/download |
grep -o https://downloads.sourceforge.net/project/hamlib/hamlib/[0-9].[0-9] |
head -n 1 | awk -F "/" '{print $7}')
if (($(echo "${NEWRIG} ${RIG}" | awk '{print ($1 > $2)}'))); then
RIG=NEEDS-UPDATE
else
RIG="is_latest_version"
fi
fi
#----------------------------------------------------#
# FLRIG
#----------------------------------------------------#
echo "Checking FLRIG"
if ! hash flrig 2>/dev/null; then
FLRIG="Not_Installed"
else
FLRIG=$(flrig --version | awk 'FNR == 1 {print $2}')
NEWFLRIG=$(curl -s https://sourceforge.net/projects/fldigi/files/flrig/ |
grep .tar.gz | head -1 | awk -F "-" '{print $2}' | awk -F ".tar.gz" '{print $1}')
if (($(echo "${NEWFLRIG} ${FLRIG}" | awk '{print ($1 > $2)}'))); then
FLRIG=NEEDS-UPDATE
else
FLRIG="is_latest_version"
fi
fi
#----------------------------------------------------#
# Pat Winlink
#----------------------------------------------------#
echo "Checking Pat Winlink"
if ! hash pat 2>/dev/null; then
PAT="Not_Installed"
else
PAT=$(pat version | awk -F 'v' '{print $2}' | head -c 5)
NEWPAT=$(curl -s https://github.com/la5nta/pat/releases | grep -m 1 "amd64.deb" |
awk -F '_' '{print $2}')
if (($(echo "${NEWPAT} ${PAT}" | awk '{print ($1 > $2)}'))); then
PAT=NEEDS-UPDATE
else
PAT="is_latest_version"
fi
fi
#----------------------------------------------------#
# DIREWOLF
#----------------------------------------------------#
echo "Checking Direwolf"
if ! hash direwolf 2>/dev/null; then
DIRE="Not_Installed"
else
DIRE=$(direwolf -S -t 0 | head -1 | sed 's/Dire\ Wolf\ version\ //')
wget -P /tmp/ https://raw.githubusercontent.com/wb2osz/direwolf/master/CHANGES.md >/dev/null 2>&1
NEWDIRE=$(cat /tmp/CHANGES.md | head -5 | tail -1 | awk '{ print $3 }')
if (($(echo "${NEWDIRE} ${DIRE}" | awk '{print ($1 > $2)}'))); then
DIRE=NEEDS-UPDATE
else
DIRE="is_latest_version"
fi
fi
#----------------------------------------------------#
# Pat Menu
#----------------------------------------------------#
echo "Checking Pat Menu"
if [ ! -d ${HOME}/patmenu2 ]; then
PATMENU="Not_Installed"
else
cd ${HOME}/patmenu2/ || ! echo "Failure"
wget -O ${HOME}/patmenu2/latest https://raw.githubusercontent.com/km4ack/patmenu2/master/changelog >/dev/null 2>&1
LATEST=$(cat ${HOME}/patmenu2/latest | grep '^release' | sed 's/release=//')
CURRENT=$(cat ${HOME}/patmenu2/changelog | grep '^release' | sed 's/release=//')
rm ${HOME}/patmenu2/latest >/dev/null 2>&1
if (($(echo "${LATEST} ${CURRENT}" | awk '{print ($1 > $2)}'))); then
PATMENU="NEEDS-UPDATE"
else
PATMENU="is_latest_version"
fi
fi
#----------------------------------------------------#
# Hot Spot Tools
#----------------------------------------------------#
if [ ! -d ${HOME}/hotspot-tools2 ]; then
HSTOOLS="Not_Installed"
else
CURRENT=$(cat ${HOME}/hotspot-tools2/changelog | grep version= | sed 's/version=//')
LATEST=$(curl -s https://raw.githubusercontent.com/km4ack/hotspot-tools2/master/changelog | grep version= | sed 's/version=//')
if (($(echo "${LATEST} ${CURRENT}" | awk '{print ($1 > $2)}'))); then
HSTOOLS="NEEDS-UPDATE"
else
HSTOOLS="is_latest_version"
fi
fi
#----------------------------------------------------#
# EES
#----------------------------------------------------#
if [ -f /var/www/html/email.php ]; then
EES="Installed"
else
EES="Not Installed"
fi
#----------------------------------------------------#
# CONKY
#----------------------------------------------------#
if [ -f ${HOME}/.conkyrc ]; then
CONKY=Installed
else
CONKY="Not Installed"
fi
}
CHECK
#get system info
WHO=$(whoami)
KERNAL=$(uname -r)
echo "User Name is ${WHO}" >${DIR}/systeminfo.txt
echo "" >>${DIR}/systeminfo.txt
echo "Kernal version is ${KERNAL}" >>${DIR}/systeminfo.txt
echo "" >>${DIR}/systeminfo.txt
cat /etc/os-release >>${DIR}/systeminfo.txt
echo
echo
echo "#####uname######" >>${DIR}/systeminfo.txt
uname -a >>${DIR}/systeminfo.txt
#get direwolf.conf file
cat ${HOME}/direwolf.conf >${DIR}/direwolf.conf
#get pat config file
PAT_VERSION=$(pat version | awk '{print $2}' | sed 's/v0.//;s/.0//')
if [ "$PAT_VERSION" -le 11 ]; then
PAT_CONFIG=${HOME}/.wl2k/config.json
else
PAT_CONFIG=$XDG_CONFIG_HOME/pat/config.json
fi
cat $PAT_CONFIG >${DIR}/patconfig.txt
#remove winlink password
sed -i 's/"secure_login_password":.*$/PASSWORD-REMOVED-FOR-YOUR-SECURITY/' ${DIR}/patconfig.txt
#get pat menu config file
cat ${HOME}/patmenu2/config >${DIR}/patmenu.conf
#Get wpa_supplicant
sudo cat /etc/wpa_supplicant/wpa_supplicant.conf >${DIR}/wpa.txt
sed -i 's/psk=.*$/PASSWORD-REMOVED/' ${DIR}/wpa.txt
#get sound info
echo "" >>${DIR}/sound.info
echo "ARECORD INFO" >${DIR}/sound.info
arecord -l >>${DIR}/sound.info
echo "" >>${DIR}/sound.info
echo "" >>${DIR}/sound.info
echo "APLAY INFO" >>${DIR}/sound.info
aplay -l >>${DIR}/sound.info
echo "" >>${DIR}/sound.info
echo "" >>${DIR}/sound.info
echo "Using sound card" >>${DIR}/sound.info
sudo lsof /dev/snd/* >>${DIR}/sound.info
#Get hotspot info
HS=$(systemctl is-active autohotspot)
CURRENTNAME=$(sudo cat /etc/hostapd/hostapd.conf | grep ssid= | head -1 | sed 's/ssid=//')
CURRENTPASS=$(sudo cat /etc/hostapd/hostapd.conf | grep wpa_passphrase= | sed 's/wpa_passphrase=//')
HSIP=$(sudo cat /usr/bin/autohotspotN | grep "ip a add" | sed 's/ip\ a\ add\ //' | sed 's/\/24.*$//' | tr -d " ")
WIREIP=$(ifconfig | grep -A 1 eth0 | grep inet | awk '{ print $2 }')
HSS=$(sudo cat /usr/bin/autohotspotN | grep "ip a add" | awk '{ print $4 }' | sed 's/\/24//')
CIP=$(ifconfig | grep -A 1 wlan0 | grep inet | awk '{ print $2 }')
CHECK=$(ls /etc/wpa_supplicant/ | grep FORCE)
AUTORUN=$(crontab -l | grep autohotspotN | awk '{print $1}' | sed 's/*\///')
if [ -z "$CHECK" ]; then
FORCE="Hotspot Not in force mode"
else
FORCE="Hotspot IS in force mode"
fi
if [ ${HSS} = ${CIP} ]; then
HSS=ACTIVE
else
HSS=INACTIVE
fi
FILE=${DIR}/hotspot.info
echo "Hotspot status ${HS}" >${FILE}
echo "Hotspot state ${HSS}" >>${FILE}
echo "Hotspot Name is ${CURRENTNAME}" >>${FILE}
echo "Hotspot IP = ${HSIP}" >>${FILE}
echo "Wireless IP = ${CIP}" >>${FILE}
echo "CAT5 IP = ${WIREIP}" >>${FILE}
echo "${FORCE}" >>${FILE}
echo "crontab set to auto run ever ${AUTORUN} minutes" >>${FILE}
#get cron contents
crontab -l >${DIR}/cron.txt
#get gps info
GPSD=$(systemctl is-active gpsd)
CHRONY=$(systemctl is-active chronyd)
echo "/etc/default/gpsd file contents" >${DIR}/gps.info
echo
echo >>${DIR}/gps.info
cat /etc/default/gpsd >>${DIR}/gps.info
echo
echo
echo >>${DIR}/gps.info
echo "GPSD is $GPSD" >>${DIR}/gps.info
echo "Chrony is $CHRONY" >>${DIR}/gps.info
echo
echo
echo "#####TIME SOURCES#####" >>${DIR}/gps.info
chronyc sources -v >>${DIR}/gps.info
#Check installed apps
echo "Hotspot $HOTSPOT" >${DIR}/apps.info
echo "HS Tools $HSTOOLS" >>${DIR}/apps.info
echo "AX25 $AX25" >>${DIR}/apps.info
echo "GPS $GPS" >>${DIR}/apps.info
echo "Pulse $PULSE" >>${DIR}/apps.info
echo "ARDOP GUI $ARDOPGUI" >>${DIR}/apps.info
echo "CONKY $CONKY" >>${DIR}/apps.info
echo "HAMLIB $RIG" >>${DIR}/apps.info
echo "FLRIG $FLRIG" >>${DIR}/apps.info
echo "PAT $PAT" >>${DIR}/apps.info
echo "DIREWOLF $DIRE" >>${DIR}/apps.info
echo "Pat Menu $PATMENU" >>${DIR}/apps.info
echo "EES $EES" >>${DIR}/apps.info
cd ${HOME}/Desktop || ! echo "Failure"
zip -r ${CALL}-diagnostic.zip ${DIR} >/dev/null 2>&1
rm -rf ${DIR} >/dev/null 2>&1
clear
echo
echo
cat <<EOF
DONE!!
Email the diagnostic.zip file located on your desktop
to [email protected] along with a description of your issue
and a link to the original forum post.
All discussion/help is provided on the forum to
benefit the community at large.
https://groups.io/g/KM4ACK-Pi/topics
73, de KM4ACK
EOF