1
0
mirror of https://github.com/km4ack/patmenu2.git synced 2025-05-19 08:10:12 -07:00

clean up code

This commit is contained in:
KM4ACK 2022-11-16 11:40:40 -06:00
parent 1e55185698
commit 3f839a11d1

View File

@ -14,20 +14,18 @@ MAIN=$MYPATH/patmenu
source $MYPATH/config source $MYPATH/config
#verify we have rig control #verify we have rig control
if [ $RIGCONTROL == 'no' ] if [ $RIGCONTROL == 'no' ]; then
then yad --title="NO RIG CONTROL" --width=400 --height=100 \
yad --title="NO RIG CONTROL" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \ --image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \
--center --form --text="\r\r\r\rRig Control is needed for auto pat.\rPlease configure rig control and try again." \ --center --form --text="\r\r\r\rRig Control is needed for auto pat.\rPlease configure rig control and try again." \
--button=gtk-ok --button=gtk-ok
exit exit
fi fi
#Check if FLRIG is running if user has it set in config file #Check if FLRIG is running if user has it set in config file
if [ "$RIGCONTROL" = 'yes' ]; then if [ "$RIGCONTROL" = 'yes' ]; then
FLRIG=$(echo $RIG | grep "\-m 4") FLRIG=$(echo $RIG | grep "\-m 4")
if [ -z "$FLRIG" ]; then if [ -z "$FLRIG" ]; then
echo echo
else else
@ -52,11 +50,10 @@ touch $LOG
DATE=$(date) DATE=$(date)
STARTRIG () { STARTRIG () {
#start rigctld & restart pat #start rigctld & restart pat
PIDCTL=$(pidof rigctld) PIDCTL=$(pidof rigctld)
WHO=$(whoami) WHO=$(whoami)
if [ -z "$PIDCTL" ] if [ -z "$PIDCTL" ]; then
then
CONTROL=$(echo $RIG | sed 's/rigctl/rigctld/') CONTROL=$(echo $RIG | sed 's/rigctl/rigctld/')
$CONTROL & $CONTROL &
sudo -A systemctl restart pat@$WHO sudo -A systemctl restart pat@$WHO
@ -65,14 +62,13 @@ WHO=$(whoami)
STARTRIG STARTRIG
if [ -z "$PIDCTL" ] if [ -z "$PIDCTL" ]; then
then STARTRIG
STARTRIG
fi fi
SETRIG () { SETRIG () {
#Set Mode for rigcontrol #Set Mode for rigcontrol
$RIG M $MODEHF $RIG M $MODEHF
} }
SETRIG SETRIG
@ -90,53 +86,45 @@ exit 0
} }
#check if distance is empty and give direction #check if distance is empty and give direction
if [ -z "$1" ] if [ -z "$1" ]; then
then directions
directions
fi fi
#check if band is empty and give direction #check if band is empty and give direction
if [ -z "$2" ] if [ -z "$2" ]; then
then directions
directions
fi fi
#Check for min distance #Check for min distance
if [ -z "$3" ] if [ -z "$3" ]; then
then MIN=0
MIN=0
else else
MIN=$3 MIN=$3
fi fi
#take $2 as band to use #take $2 as band to use
if [ $2 = "20" ] if [ $2 = "20" ]; then
then FILE=$VARALIST"20mvaralist.txt"
FILE=$VARALIST"20mvaralist.txt" elif [ $2 = "30" ]; then
elif [ $2 = "30" ] FILE=$VARALIST"30mvaralist.txt"
then elif [ $2 = "40" ]; then
FILE=$VARALIST"30mvaralist.txt" FILE=$VARALIST"40mvaralist.txt"
elif [ $2 = "40" ] elif [ $2 = "80" ]; then
then FILE=$VARALIST"80mvaralist.txt"
FILE=$VARALIST"40mvaralist.txt"
elif [ $2 = "80" ]
then
FILE=$VARALIST"80mvaralist.txt"
fi fi
#Verify we have a list to work with #Verify we have a list to work with
test -f $FILE test -f $FILE
FILERESULT=$(echo $?) FILERESULT=$(echo $?)
if [ $FILERESULT = "1" ] if [ $FILERESULT = "1" ]; then
then echo "FILE DOESN'T EXIST."
echo "FILE DOESN'T EXIST." yad --title="NO LIST" --width=400 --height=100 \
yad --title="NO LIST" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \ --image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \
--center --form --text="\r\r\rNo list has been downloaded. Auto Pat has no data to work with. Please download the gateway list \ --center --form --text="\r\r\rNo list has been downloaded. Auto Pat has no data to work with. Please download the gateway list \
and try again" \ and try again" \
--button="Download List":2 \ --button="Download List":2 \
--button="Cancel":1 --button="Cancel":1
BUT=$? BUT=$?
if [ $BUT = 1 ]; then if [ $BUT = 1 ]; then
exit exit
elif [ $BUT = 2 ]; then elif [ $BUT = 2 ]; then
@ -146,13 +134,17 @@ BUT=$?
fi fi
fi fi
if [ $AMRRON = "no" ] if [ $AMRRON = "no" ]; then
then #start varaHF modem
#start varaHF modem echo "Starting VARA-HF modem"
echo "Starting VARA-HF modem" /usr/bin/wine $HOME/.wine/drive_c/VARA/VARA.exe > /dev/null 2>&1 &
/usr/local/bin/wine $HOME/.wine/drive_c/VARA/VARA.exe > /dev/null 2>&1 & echo "standby while the modem starts....."
echo "standby while the modem starts....." sleep 10 #give vara time to start
sleep 10 #give vara time to start else
echo "Starting VARA-HF modem"
/usr/bin/wine $HOME/.wine/drive_c/VARA/VARA.exe > /dev/null 2>&1 &
echo "standby while the modem starts....."
sleep 10 #give vara time to start
fi fi
#Pat Connection Function #Pat Connection Function
@ -160,26 +152,24 @@ connect () {
pat connect $CALL pat connect $CALL
#Check if connection was successful #Check if connection was successful
RESULTS=$(echo $?) RESULTS=$(echo $?)
if [ $RESULTS = "0" ] if [ $RESULTS = "0" ]; then
then echo "A connection was made"
echo "A connection was made" echo $DATE" "$CALL" Success with autopat" >> $LOG
echo $DATE" "$CALL" Success with autopat" >> $LOG CALL=$(echo "$CALL" | sed 's/&/ /')
CALL=$(echo "$CALL" | sed 's/&/ /')
yad --title="SUCCESS" --width=300 --height=100 \ yad --title="SUCCESS" --width=300 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top \ --image $LOGO --window-icon=$LOGO --image-on-top \
--center --form --text="<b>Successfully connected!</b>\r$CALL\r\rSee mylog in documents\rdirectory for more details." \ --center --form --text="<b>Successfully connected!</b>\r$CALL\r\rSee mylog in documents\rdirectory for more details." \
--button=gtk-ok --button=gtk-ok
if [ $AMRRON = "no" ] if [ $AMRRON = "no" ]; then
then sudo -A killall direwolf piardopc kissattach piARDOP_GUI rigctld > /dev/null 2>&1
sudo -A killall direwolf piardopc kissattach piARDOP_GUI rigctld > /dev/null 2>&1 VARA=$(ps aux | grep wine | grep VARA | head -1 | awk '{print $2}')
VARA=$(ps aux | grep wine | grep VARA | head -1 | awk '{print $2}') kill -9 $VARA > /dev/null 2>&1
kill -9 $VARA > /dev/null 2>&1 VARA=$(ps aux | grep wine | grep VARA | head -1 | awk '{print $2}')
VARA=$(ps aux | grep wine | grep VARA | head -1 | awk '{print $2}') kill -9 $VARA > /dev/null 2>&1
kill -9 $VARA > /dev/null 2>&1 fi
fi exit 0
exit 0
fi fi
} }
@ -192,12 +182,12 @@ cat $FILE | tail -n +5 | grep '[^[:blank:]]' > $HOME/tempardop/tempardop.txt
#otherwise the URL is wrong #otherwise the URL is wrong
while read -r line while read -r line
do do
CHECK=$(echo $line | awk '{print $6}') CHECK=$(echo $line | awk '{print $6}')
if [ "$CHECK" = 500 ] || [ "$CHECK" = 2750 ]; then if [ "$CHECK" = 500 ] || [ "$CHECK" = 2750 ]; then
echo $line >> $HOME/tempardop/temp.txt echo $line >> $HOME/tempardop/temp.txt
else else
echo $line | sed 's/VARA/VARA 500/' >> $HOME/tempardop/temp.txt echo $line | sed 's/VARA/VARA 500/' >> $HOME/tempardop/temp.txt
fi fi
done < $HOME/tempardop/tempardop.txt done < $HOME/tempardop/tempardop.txt
cp $HOME/tempardop/temp.txt $HOME/tempardop/tempardop.txt cp $HOME/tempardop/temp.txt $HOME/tempardop/tempardop.txt
@ -215,8 +205,7 @@ echo "Will Attempt to Connect to This Station"
while read LINE while read LINE
do DISTANCE=$(echo $LINE | awk '{ print $1 }') do DISTANCE=$(echo $LINE | awk '{ print $1 }')
CALL=$(echo $LINE | awk '{ print $2 }') CALL=$(echo $LINE | awk '{ print $2 }')
if [ $DISTANCE -lt "$1" ] && [ $DISTANCE -gt "$MIN" ] if [ $DISTANCE -lt "$1" ] && [ $DISTANCE -gt "$MIN" ]; then
then
echo "Distance="$DISTANCE " Call="$CALL echo "Distance="$DISTANCE " Call="$CALL
#call the connect funtion #call the connect funtion
connect connect
@ -227,14 +216,13 @@ done < $HOME/tempardop/sorted.txt
#remove temp directory & files #remove temp directory & files
rm -rf $HOME/tempardop rm -rf $HOME/tempardop
if [ $AMRRON = "no" ] if [ $AMRRON = "no" ]; then
then sudo -A killall direwolf piardopc kissattach piARDOP_GUI rigctld > /dev/null 2>&1
sudo -A killall direwolf piardopc kissattach piARDOP_GUI rigctld > /dev/null 2>&1 sudo -A rfcomm release /dev/rfcomm0 > /dev/null 2>&1
sudo -A rfcomm release /dev/rfcomm0 > /dev/null 2>&1 VARA=$(ps aux | grep wine | grep VARA | head -1 | awk '{print $2}')
VARA=$(ps aux | grep wine | grep VARA | head -1 | awk '{print $2}') kill -9 $VARA > /dev/null 2>&1
kill -9 $VARA > /dev/null 2>&1 VARA=$(ps aux | grep wine | grep VARA | head -1 | awk '{print $2}')
VARA=$(ps aux | grep wine | grep VARA | head -1 | awk '{print $2}') kill -9 $VARA > /dev/null 2>&1
kill -9 $VARA > /dev/null 2>&1
fi fi