pi-build/diagnostic

344 wiersze
9.2 KiB
Plaintext
Czysty Zwykły widok Historia

2020-06-16 16:56:18 +00:00
#! /bin/bash
#script to gather some system information
#to help diagnose issues
#20200616 km4ack
2020-06-16 17:07:31 +00:00
clear;echo;echo
2020-06-16 16:56:18 +00:00
read -p "What is your call sign? " CALL
DIR=$HOME/Desktop/$CALL-diagnostic-report
#create temp dir
mkdir -p $DIR
2020-06-16 19:13:10 +00:00
#check to see which apps are installed
CHECK(){
#----------------------------------------------------#
# Hotspot
#----------------------------------------------------#
HOTSPOT=$(ls /usr/bin/ | grep autohotspotN)
if [ -z "$HOTSPOT" ]; then
HOTSPOT="Not Installed"
else
HOTSPOT="Installed"
fi
#----------------------------------------------------#
# Hotspot tools
#----------------------------------------------------#
if [ ! -d $HOME/hotspot-tools2 ]; then
HSTOOLS="Not Installed"
else
HSTOOLS="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/
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
2020-06-16 16:56:18 +00:00
#get system info
2020-06-30 14:36:37 +00:00
WHO=$(whoami)
2020-07-31 13:13:06 +00:00
KERNAL=$(uname -r)
2020-06-30 14:36:37 +00:00
echo "User Name is $WHO" > $DIR/systeminfo.txt
echo "" >> $DIR/systeminfo.txt
2020-07-31 13:13:06 +00:00
echo "Kernal version is $KERNAL" >> $DIR/systeminfo.txt
echo "" >> $DIR/systeminfo.txt
2020-06-30 14:36:37 +00:00
cat /etc/os-release >> $DIR/systeminfo.txt
2020-06-16 19:13:10 +00:00
echo;echo;echo "#####uname######" >> $DIR/systeminfo.txt
uname -a >> $DIR/systeminfo.txt
2020-06-16 16:56:18 +00:00
#get direwolf.conf file
cat $HOME/direwolf.conf > $DIR/direwolf.conf
#get pat config file
cat $HOME/.wl2k/config.json > $DIR/patconfig.txt
#remove winlink password
2020-06-16 19:13:10 +00:00
sed -i 's/"secure_login_password":.*$/PASSWORD-REMOVED-FOR-YOUR-SECURITY/' $DIR/patconfig.txt
2020-06-16 16:56:18 +00:00
#get pat menu config file
cat $HOME/patmenu2/config > $DIR/patmenu.conf
2020-06-30 14:36:37 +00:00
#Get wpa_supplicant
sudo cat /etc/wpa_supplicant/wpa_supplicant.conf > $DIR/wpa.txt
sed -i 's/psk=.*$/PASSWORD-REMOVED/' $DIR/wpa.txt
2020-06-16 16:56:18 +00:00
#get sound info
2020-06-16 21:33:20 +00:00
echo "" >> $DIR/sound.info
2020-06-16 16:56:18 +00:00
echo "ARECORD INFO" > $DIR/sound.info
arecord -l >> $DIR/sound.info
2020-06-16 21:33:20 +00:00
echo "" >> $DIR/sound.info
echo "" >> $DIR/sound.info
echo "APLAY INFO" >> $DIR/sound.info
2020-06-16 16:56:18 +00:00
aplay -l >> $DIR/sound.info
2020-06-16 21:33:20 +00:00
echo "" >> $DIR/sound.info
echo "" >> $DIR/sound.info
echo "Using sound card" >> $DIR/sound.info
sudo lsof /dev/snd/* >> $DIR/sound.info
2020-06-16 16:56:18 +00:00
#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 " ")
2020-06-16 20:44:00 +00:00
WIREIP=$(ifconfig | grep -A 1 eth0 | grep inet | awk '{ print $2 }')
2020-06-16 16:56:18 +00:00
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
2020-06-16 20:47:48 +00:00
if [ $HSS = $CIP ]
then
HSS=ACTIVE
else
HSS=INACTIVE
fi
2020-06-16 16:56:18 +00:00
FILE=$DIR/hotspot.info
2020-06-16 20:51:14 +00:00
echo "Hotspot status $HS" > $FILE
echo "Hotspot state $HSS" >> $FILE
2020-06-16 16:56:18 +00:00
echo "Hotspot Name is $CURRENTNAME" >> $FILE
echo "Hotspot IP = $HSIP" >> $FILE
2020-06-16 20:32:17 +00:00
echo "Wireless IP = $CIP" >> $FILE
echo "CAT5 IP = $WIREIP" >> $FILE
2020-06-16 16:56:18 +00:00
echo "$FORCE" >> $FILE
echo "crontab set to auto run ever $AUTORUN minutes" >> $FILE
2020-06-16 20:32:17 +00:00
#get cron contents
crontab -l > $DIR/cron.txt
2020-06-16 17:07:31 +00:00
#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
2020-06-16 19:13:10 +00:00
#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
2020-06-16 16:56:18 +00:00
cd $HOME/Desktop
zip -r $CALL-diagnostic.zip $DIR > /dev/null 2>&1
rm -rf $DIR > /dev/null 2>&1
2020-06-16 17:07:31 +00:00
clear;echo;echo
2020-06-16 19:13:10 +00:00
cat <<EOF
DONE!!
Email the diagnostic.zip file located on your desktop
to km4ack@arrl.net 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
2020-06-16 16:56:18 +00:00