1
0
mirror of https://github.com/km4ack/patmenu2.git synced 2025-05-15 22:30:11 -07:00

initial commit

This commit is contained in:
KM4ACK 2020-05-14 07:16:56 -05:00
parent ce33391300
commit bd35496d99
28 changed files with 7599 additions and 0 deletions

16
891.km4ack.config Normal file
View File

@ -0,0 +1,16 @@
#Config file for Pat Menu
#20200429 KM4ACK
MYCALLSIGN=KM4ACK
MAP=usa
RIGCONTROL=yes
ARDOP="/home/pi/ardop/./piardopc 8515 plughw:1,0 plughw:1,0"
ARDOPGUI="/home/pi/ardop/./piARDOP_GUI"
DIREWOLF="direwolf -p"
KISS="sudo /usr/sbin/kissattach /tmp/kisstnc"
AXP=wl2k
RIG="/usr/local/bin/rigctl -m 4"
MODEHF=PKTUSB
MODE2M=FM
PORT=5050
LOG=/home/pi/Documents/mylog.txt
AMRRON=no

273
FA-functions Normal file
View File

@ -0,0 +1,273 @@
#functions file for find ardop
#20200425 km4ack
MYPATH=$HOME/patmenu2
MAIN=$MYPATH/./find2
CONFIG=$HOME/.wl2k/config.json
TEMP=$HOME/patmenu2/tempconfig.txt
TODAY=$(date +%Y%m%d-%R)
WHO=$(whoami)
LASTDL=$(cat $MYPATH/ardop-list/ardoplist.txt | head -1)
LOGO=$MYPATH/pmlogo.png
source $MYPATH/config
#--------------------------------
# MANUAL Download List
#--------------------------------
DOWNLIST(){
$MYPATH/getardoplist
$MAIN &
exit
}
#--------------------------------
# AUTO Download List
#--------------------------------
AUTODOWN(){
FILE=/run/user/1000/cronbkup.txt
crontab -l > $FILE
HOURS=00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23
MINS=00,15,30,45
TEST=$(yad --center --wrap --width=350 --title="Auto Download" --text-align=center \
--text="Please choose the time you would like to download the gateway list everyday" \
--image $LOGO --window-icon=$LOGO --image-on-top \
--button="Update:2" \
--button="Cancel:1" \
--form --separator="," --item-separator="," \
--field="Choose the hour":CB $HOURS \
--field="Choose the minutes":CB $MINS \
)
rc=$?
if [[ $rc -eq 2 ]]; then
echo "Updating Cron"
HOUR=$(echo $TEST | awk -F ',' '{print $1}')
MIN=$(echo $TEST | awk -F ',' '{print $2}')
sed -i '/getardoplist/d' $FILE
echo $MIN" "$HOUR" * * * $MYPATH/.getardoplist-cron" >> $FILE
crontab $FILE
echo
echo "Your crontab has been updated. The gateway list"
echo "will be downloaded daily at "$HOUR":"$MIN" hours"
yad --center --timeout=3 --timeout-indicator=top --no-buttons --text="Auto Download set for $HOUR:$MIN daily" \
--image $LOGO --window-icon=$LOGO --image-on-top
$MAIN &
rm $FILE
exit
elif [[ $rc -eq 1 ]]; then
echo "BYE"
$MAIN &
exit
fi
}
#--------------------------------
# GRID SEARCH
#--------------------------------
GRIDSEARCH(){
OUTFILE=/run/user/1000/tempardoplist.txt
CONFIG=$HOME/.wl2k/config.json
TEMP=/run/user/1000/tempconfig.txt
ARDOPLIST=$MYPATH/ardop-list
WHO=$(whoami)
source $MYPATH/config #patmenu config file
#check to make sure user has downloaded
if [ ! -d "$MYPATH/ardop-list/" ]; then
yad --title="No List" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \
--center --form --text="\r\rGateway list has NOT been downloaded.\rPlease download now\rRecommend setting auto download time" \
--button="Download":2
BUT=$?
if [ $BUT = 2 ]; then
$MYPATH/getardoplist
$MAIN &
exit
elif [ $BUT = 252 ]; then
exit
fi
fi
SEARCHMENU(){
#MENU
BANDS="20|30|40|80|2M-70CM"
SEARCH=$(yad --form --width=400 --text="<b>Find ARDOP</b> by KM4ACK" --text-align=center --center --title="Find ARDOP" --text-align=center \
--separator="|" --item-separator="|" \
--image=$LOGO --window-icon=$LOGO --image-on-top \
--field="Grid to Search" "EM" \
--field="Band to Search":CB "$BANDS" \
--button="Search Packet":3 \
--button="Search ARDOP":2 \
--button="Cancel":1)
QUIT=$?
GRID=$(echo $SEARCH | awk -F "|" '{print $1}')
GRID=$(echo "${GRID^^}")
BAND=$(echo $SEARCH | awk -F "|" '{print $2}')
if [ $QUIT = 1 ]; then
$MAIN &
exit
elif [ $QUIT = 252 ]; then
exit
fi
##############PACKET SEARCH######################
if [ $QUIT = 3 ]; then
FILE=$MYPATH/ardop-list/packet.txt
TEMP=/run/user/1000/temppacket.txt
TEMP1=/run/user/1000/templist.txt
TEMP2=/run/user/1000/tempalias.txt
cat $FILE | tail -n +5 | grep '[^[:blank:]]' > $TEMP
MAX=200
rm $TEMP1
echo "Search Packet"
while read LINE
do DISTANCE=$(echo $LINE | awk '{ print $3 }')
CALL=$(echo $LINE | awk '{ print $1 }')
#echo $DISTANCE
if [ $DISTANCE -lt "$MAX" ]
then
echo $LINE | sed 's/packet:/ax25:/' >> $TEMP1
fi
done < $TEMP | yad --center --progress --pulsate --auto-close --no-buttons --text-align=center \
--text="Please wait while the list is searched.\rThis takes about 30 seconds.\r<b>DON'T CLOSE THIS WINDOW</b>"
INFO=$(PARSER='OFS="\n" {print $1, $2, $3, $4, $5, $6, $7, $9, $11}'
tail -50 $TEMP1 | awk "$PARSER" | \
yad --title="Search Results" --width=1100 --height=500 \
--image $LOGO --window-icon=$LOGO --image-on-top \
--center --list --text="Search Results" \
--column Call --column Grid --column Dist \
--column Azm --column Mode --column Speed \
--column Dial-Freq \
--column Center-Freq --column Shortcut \
--button=gtk-close \
--button="Add Alias":2)
BUT=$?
if [ $BUT = 0 ]; then
$MAIN &
exit
elif [ "$BUT" = 2 ];then
CALL=$(echo $INFO | awk -F "|" '{print $1}')
SC=$(echo $INFO | awk -F "|" '{print $9}')
FREQ=$(echo $SC | sed 's/.*=//')
if [ $RIGCONTROL = 'no' ]; then
SC=$(echo $SC | sed 's/[?].*$//')
fi
#check something was selected
if [ -z "$CALL" ]; then
yad --title="No Selection" --width=300 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top \
--center --form --text="No station was selected\r Please try again" \
--button=gtk-ok
$MAIN &
exit
fi
jq '.connect_aliases += {'\""$CALL-$FREQ"\"' : '\"$SC\"'}' $CONFIG > $TEMP
cp $TEMP $CONFIG
rm $TEMP
sudo killall pat
sudo systemctl start pat@$WHO
yad --title="ADDED" --width=300 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top \
--center --form --text="$CALL-$FREQ added to Pat Winlink\rRefresh Pat Mailbox Window\rto view changes" \
--button=gtk-ok
SEARCHMENU
fi
exit
fi
#############ARDOP SEARCH####################
OUTFILE2=/run/user/1000/tempardop2.txt
if [ $BAND = 20 ];then
FILE=$ARDOPLIST/20mardoplist.txt
cat $FILE | egrep -i $GRID[[:digit:]]{2} | tee "$OUTFILE" > /dev/null 2>&1
#cat $OUTFILE | tr -s '[:space:]' | sed 's/ /|/g'| sed 's/[A-Za-z]*$/|/g' > $OUTFILE2
elif [ $BAND = 30 ];then
FILE=$ARDOPLIST/30mardoplist.txt
cat $FILE | egrep -i $GRID[[:digit:]]{2} | tee "$OUTFILE" > /dev/null 2>&1
elif [ $BAND = 40 ];then
FILE=$ARDOPLIST/40mardoplist.txt
cat $FILE | egrep -i $GRID[[:digit:]]{2} | tee "$OUTFILE" > /dev/null 2>&1
elif [ $BAND = 80 ];then
FILE=$ARDOPLIST/80mardoplist.txt
cat $FILE | egrep -i $GRID[[:digit:]]{2} | tee "$OUTFILE" > /dev/null 2>&1
echo "80 done"
fi
INFO=$(PARSER='OFS="\n" {print $1, $2, $3, $4, $5, $6, $7, $9, $11}'
tail -50 $OUTFILE | awk "$PARSER" | \
yad --title="Search Results" --width=1100 --height=500 \
--image $LOGO --window-icon=$LOGO --image-on-top \
--center --list --text="Search Results" \
--column Call --column Grid --column Dist \
--column Azm --column Mode --column Speed \
--column Dial-Freq \
--column Center-Freq --column Shortcut \
--button=gtk-close \
--button="Add Alias":2)
BUT=$?
if [ "$BUT" = 2 ];then
CALL=$(echo $INFO | awk -F "|" '{print $1}')
SC=$(echo $INFO | awk -F "|" '{print $9}')
FREQ=$(echo $SC | sed 's/.*=//')
if [ $RIGCONTROL = 'no' ]; then
SC=$(echo $SC | sed 's/[?].*$//')
fi
#check something was selected
if [ -z "$CALL" ]; then
yad --title="No Selection" --width=300 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top \
--center --form --text="No station was selected\r Please try again" \
--button=gtk-ok
$MAIN &
exit
fi
jq '.connect_aliases += {'\""$CALL-$BAND"M"-$FREQ"\"' : '\"$SC\"'}' $CONFIG > $TEMP
cp $TEMP $CONFIG
rm $TEMP
sudo killall pat
sudo systemctl start pat@$WHO
yad --title="ADDED" --width=300 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top \
--center --form --text="Alias added to Pat Winlink\rRefresh Pat Mailbox Window\rto view changes" \
--button=gtk-ok
SEARCHMENU
fi
SEARCHMENU
}
SEARCHMENU
}
#--------------------------------
# Open Map
#--------------------------------
MAP(){
if [ "$MAP" = "usa" ]; then
MAP=$MYPATH/grid-map.pdf
elif [ "$MAP" = "world" ]; then
MAP=$MYPATH/worldgridmap.pdf
fi
xdg-open $MAP
}

42
auto-download Executable file
View File

@ -0,0 +1,42 @@
#!/bin/bash
#update cron to download ardop list
#20191126 km4ack
MYPATH=$HOME/patmenu2
FILE=/run/user/1000/cronbkup.txt
crontab -l > $FILE
HOURS=00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23
MINS=00,15,30,45
TEST=$(yad --center --wrap --width=250 --title="ARDOP Auto Download Setup" \
--text="Please choose the time you would like to download the gateway list everyday" \
--button="UPDATE:2" \
--button="Exit:1" \
--form --separator="," --item-separator="," \
--field="Choose the hour":CB $HOURS \
--field="Choose the minutes":CB $MINS \
)
rc=$?
if [[ $rc -eq 2 ]]; then
echo "Updating Cron"
HOUR=$(echo $TEST | awk -F ',' '{print $1}')
MIN=$(echo $TEST | awk -F ',' '{print $2}')
sed -i '/getardoplist/d' $FILE
echo $MIN" "$HOUR" * * * $MYPATH/getardoplist" >> $FILE
crontab $FILE
echo
echo "Your crontab has been updated. The gateway list"
echo "will be downloaded daily at "$HOUR":"$MIN" hours"
sleep 5
rm $FILE
elif [[ $rc -eq 1 ]]; then
echo "BYE"
exit 0
fi

262
autopat Executable file
View File

@ -0,0 +1,262 @@
#!/bin/bash
#script to perform auto connects to gateways
#using pat winlink
#20191015 KM4ACK
MYPATH=$HOME/patmenu2
LOGO=$MYPATH/pmlogo.png
MAIN=$MYPATH/patmenu
source $MYPATH/config
if [ $RIGCONTROL == 'no' ]
then
yad --title="NO RIG CONTROL" --width=400 --height=100 \
--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." \
--button=gtk-ok
exit
fi
#Check if FLRIG is running if user has it set in config file
if [ "$RIGCONTROL" = 'yes' ]; then
echo "rig control is on"
FLRIG=$(echo $RIG | grep "\-m 4")
if [ -z "$FLRIG" ]; then
echo
else
FLRIG=$(pidof flrig)
if [ -z "$FLRIG" ]; then
yad --title="FAILED" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \
--center --form --text="Please start FLRIG and try again" \
--button=gtk-ok
exit
fi
fi
fi
if [ $AMRRON = "no" ]
then
DIRE=$(pidof direwolf)
if [ -z "$DIRE" ]
then
echo
else
sudo killall direwolf kissattach
fi
PIARDOPC=$(pidof piardopc)
if [ -z "$PIARDOPC" ]
then
echo
else
sudo killall piardopc ardop-GUI
fi
fi
#clear any temp files from previous runs that might exist
rm -rf $HOME/tempardop > /dev/null
ARDOPLIST=$MYPATH/ardop-list/
touch $LOG
DATE=$(date)
STARTRIG () {
#start rigctld if not already
PIDCTL=$(pidof rigctld)
WHO=$(whoami)
if [ -z "$PIDCTL" ]
then
CONTROL=$(echo $RIG | sed 's/rigctl/rigctld/')
$CONTROL &
sudo systemctl restart pat@$WHO
fi
}
STARTRIG
if [ -z "$PIDCTL" ]
then
STARTRIG
fi
SETRIG () {
#Set USB Mode
RIGUSB=$RIG" M $MODEHF 0"
#check rig is in USB
MODE=$($RIG m | grep $MODEHF)
sleep 1
MODECHECK() {
#check rig is in correct mode
MODE=$($RIG m | grep $MODEHF)
}
sleep 1
if [ -z $MODE ]
then
$RIGUSB
MODECHECK
fi
}
SETRIG
#Directions Function
directions () {
echo "The script needs two arguments to run."
echo "It needs the distance that you want to try to connect"
echo "and it needs the band you wish to use"
echo "Bands available are 20, 30, 40, & 80"
echo "The first argument is the distance"
echo "and the second is the band. So to try all 40M"
echo "stations in a 300km radius, you would enter"
echo "autopat 300 40"
exit 0
}
#check if distance is empty and give direction
if [ -z "$1" ]
then
directions
fi
#check if band is empty and give direction
if [ -z "$2" ]
then
directions
fi
#Check for min distance
if [ -z "$3" ]
then
MIN=0
else
MIN=$3
fi
#take $2 as band to use
if [ $2 = "20" ]
then
FILE=$ARDOPLIST"20mardoplist.txt"
elif [ $2 = "30" ]
then
FILE=$ARDOPLIST"30mardoplist.txt"
elif [ $2 = "40" ]
then
FILE=$ARDOPLIST"40mardoplist.txt"
elif [ $2 = "80" ]
then
FILE=$ARDOPLIST"80mardoplist.txt"
fi
#Verify we have a list to work with
test -f $FILE
FILERESULT=$(echo $?)
if [ $FILERESULT = "1" ]
then
echo "FILE DOESN'T EXIST."
yad --title="NO LIST" --width=400 --height=100 \
--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 \
and try again" \
--button="Download List":2 \
--button="Cancel":1
BUT=$?
if [ $BUT = 1 ]; then
exit
elif [ $BUT = 2 ]; then
$MYPATH/getardoplist
$MAIN &
exit
fi
fi
if [ $AMRRON = "no" ]
then
#start ardop-gui & piardopc
$ARDOPGUI &
$ARDOP &
sleep 10
fi
#Pat Connection Function
connect () {
pat connect $CALL
#Check if connection was successful
RESULTS=$(echo $?)
if [ $RESULTS = "0" ]
then
echo "A connection was made"
echo $DATE" "$CALL" Success with autopat" >> $LOG
yad --title="SUCCESS" --width=300 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top \
--center --form --text="Successfully connected with $CALL" \
--button=gtk-ok
if [ $AMRRON = "no" ]
then
sudo killall piardopc piARDOP_GUI
fi
exit 0
fi
}
#create temp dir & manipulate file
mkdir -p $HOME/tempardop/
#cat file, remove first few lines, remove blanks > NEWFILE NAME
cat $FILE | tail -n +5 | grep '[^[:blank:]]' > $HOME/tempardop/tempardop.txt
#pad with zeros
while read LINE
do DISTANCE=$(echo $LINE | awk '{ print $3 }' | sed -e :a -e 's/^.\{1,4\}$/0&/;ta')
CALL=$(echo $LINE | awk '{ print $11 }')
echo $DISTANCE" "$CALL >> $HOME/tempardop/tempardop1.txt
done < $HOME/tempardop/tempardop.txt
cat $HOME/tempardop/tempardop1.txt | sort >> $HOME/tempardop/sorted.txt
echo "Will Attempt to Connect to This Station"
#loop through file and find needed station info
while read LINE
do DISTANCE=$(echo $LINE | awk '{ print $1 }')
CALL=$(echo $LINE | awk '{ print $2 }')
if [ $DISTANCE -lt "$1" ] && [ $DISTANCE -gt "$MIN" ]
then
echo "Distance="$DISTANCE " Call="$CALL
#call the connect funtion
connect
fi
done < $HOME/tempardop/sorted.txt
#remove temp directory & files
rm -rf $HOME/tempardop
if [ $AMRRON = "no" ]
then
#Stop ARDOP modem and gui
sudo killall piardopc piARDOP_GUI
fi
yad --title="NO Connection" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \
--center --form --text="\r\r\r\rNo Winlink connection was made using the criteria you entered." \
--button=gtk-ok

389
cat-functions Normal file
View File

@ -0,0 +1,389 @@
#function file for patmenu 2 catalog
#20200430 km4ack
MYPATH=$HOME/patmenu2
LOGO=$MYPATH/pmlogo.png
MAIN=$MYPATH/./catalog
#get callsign from pat config file
CALLSIGN=$(cat $HOME/.wl2k/config.json | grep -m 1 mycall | sed 's/\"mycall\": \"//' | sed 's/\",//' | sed -e 's/^\s*//' | tr '[:lower:]' '[:upper:]')
#COMPOSE EMAIL Function
COMPOSE () {
#Count body characters
BODYCOUNT=${#BODY}
NEWCOUNT=$(expr $BODYCOUNT + 1)
#set date
TODAY=$(date '+%Y/%m/%d %H:%M')
TODAY1=$(date)
#generate 12 random number
NEW_UUID=$(cat /dev/urandom | tr -dc 'A-Z0-9' | fold -w 12 | head -n 1)
#add .b2f to end of random number for new file name
NEW_FILE=$HOME/.wl2k/mailbox/$CALLSIGN/out/$NEW_UUID".b2f"
#create new file
touch $NEW_FILE
#add file contents
echo "Mid: "$NEW_UUID >> $NEW_FILE
echo "Body: "$NEWCOUNT >> $NEW_FILE
echo "Content-Transfer-Encoding: 8bit" >> $NEW_FILE
echo "Content-Type: text/plain; charset=ISO-8859-1" >> $NEW_FILE
echo "Date: "$TODAY >> $NEW_FILE
echo "From: "$CALLSIGN >> $NEW_FILE
echo "Mbo: "$CALLSIGN >> $NEW_FILE
echo "Subject: "$SUBJECT >> $NEW_FILE
echo "To: "$TO >> $NEW_FILE
echo "Type: Private" >> $NEW_FILE
echo "" >> $NEW_FILE
echo $BODY >> $NEW_FILE
#give user some feedback
echo "Your request has been posted to the outbox of Pat Winlink"
echo "Please go to Pat and initiate a connection to send the request"
yad --no-buttons --timeout=5 --center --timeout-indicator=top --title="POSTED" --text-align=center --width="300" height="300" \
--text="Message Posted\rTo Outbox\r\rPlease go to Winlink and\rmake a connection\rto complete the\rrequest."
$MAIN
exit
}
GATEWAY(){
GATE=$(yad --form --width=420 --text-align=center --center --title="Pat Catalog" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Catalog</b> by KM4ACK" \
--field="Gateway List":CB "ARDOP|PACKET")
BUT=$?
if [ $BUT = 252 ]; then
exit
fi
GATE=$(echo $GATE | awk -F "|" '{print $1}')
if [ -z $GATE ]; then
$MAIN &
exit
fi
if [ "$GATE" = ARDOP ]; then
echo ARDOP
TO="INQUIRY"
SUBJECT="REQUEST"
BODY="PUB_ARDOP"
COMPOSE
elif [ "$GATE" = PACKET ]; then
echo PACKET
TO="INQUIRY"
SUBJECT="REQUEST"
BODY="PUB_PACKET"
COMPOSE
fi
}
WEATHER(){
WEATHER=$(yad --form --width=420 --text-align=center --center --title="Pat Catalog" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Catalog</b> by KM4ACK" \
--field="Weather Report":CB "GPS Weather|City Weather|GRIB Files")
BUT=$?
if [ $BUT = 252 ]; then
exit
fi
WEATHER=$(echo $WEATHER | awk -F "|" '{print $1}')
if [ -z "$WEATHER" ]; then
$MAIN &
exit
fi
if [ "$WEATHER" = 'GPS Weather' ]; then
echo "Need GPS weather"
GPSDATA=$(gpspipe -r -n 10 | grep G\.GGA) #Thanks K4KDR!
LAT=$(echo $GPSDATA | awk -F"," '{ print $3 }'| sed 's/\.//' | sed 's/./&./2')
LON=$(echo $GPSDATA | awk -F"," '{ print $5 }'| sed 's/\.//' | sed 's/./&./3')
TO="SMTP:query@saildocs.com"
SUBJECT="<No Subject>"
BODY="https://forecast.weather.gov/MapClick.php?lat="$LAT"&lon=-"$LON"&unit=0&lg=english&FcstType=text&TextType=1"
COMPOSE
elif [ "$WEATHER" = 'City Weather' ]; then
FILE=$MYPATH/weather.txt
PARSER='OFS="\n" {print $1, $2, $3}'
CITY=$(tail -76 $FILE | awk "$PARSER" | \
yad --title="Search Results" --width=500 --height=500 \
--image $LOGO --window-icon=$LOGO --image-on-top \
--center --checklist --list \
--column Pick --column ID --column Area \
--button="Choose":2)
CITY=$(echo $CITY | awk -F "|" '{print $2}')
if [ -z "$CITY" ]
then
$MAIN &
exit
fi
TO="INQUIRY"
SUBJECT="REQUEST"
BODY=$CITY
COMPOSE
elif [ "$WEATHER" = 'GRIB Files' ]; then
echo "Need GRIB Files"
FILE=/run/user/1000
QUESTION () {
DEGREE=$(yad --center --wrap --width=350 --title="Auto Download" --text-align=center \
--text="How many degrees would you like" \
--form --separator="|" --item-separator="|" \
--image $LOGO --window-icon=$LOGO --image-on-top \
--field="Degrees":CB "2|6|10" \
--button="Cancel:1" \
--button="Continue:2")
BUT=$?
if [ $BUT = 1 ] || [ -z "$BUT" ]; then
$MAIN &
exit
elif [ $BUT = 252 ]; then
exit
fi
ANS=$(echo $DEGREE | awk -F "|" '{print $1}')
echo $ANS
if [ $ANS = "10" ]
then
AREA=5
echo "aree=5"
elif [ $ANS = "6" ]
then
AREA=3
elif [ $ANS = "2" ]
then
AREA=1
fi
GPS=$(gpspipe -r -n 10 | grep G\.GGA)
LAT=$(echo $GPS | awk -F "," '{printf "%.0f \n", $3 }' | cut -c1-2)
LATD=$(echo $GPS | awk -F "," '{print $4}')
LON=$(echo $GPS | awk -F "," '{printf "%.0f \n", $5 }' | cut -c1-2)
LOND=$(echo $GPS | awk -F "," '{print $6}')
#do some math
let NEWLATADD=$LAT+$AREA
let NEWLONADD=$LON+$AREA
let NEWLATSUB=$LAT-$AREA
let NEWLONSUB=$LON-$AREA
GRIBFILE=$FILE/gribtemp
GRIBDATA () {
yad --height=600 --width=400 --center --list --checklist --column=Request --column=Product --separator="," \
--text "Select the data to request." --title="GRIB DATA REQUEST" \
--button="Exit:1" --button="Request Selected:2" < $MYPATH/griblist > $GRIBFILE
BUTTON=$?
if [ $BUTTON = "252" ]
then
exit
elif [ $BUTTON = "1" ]
then
$MAIN &
exit
fi
#echo "button = "$BUTTON
};export -f GRIBDATA
GRIBDATA
sed -i 's/TRUE,//' $GRIBFILE
var=$(cat $GRIBFILE)
var1=$(echo $var | sed 's/ //g' | sed 's/,*$//')
rm $GRIBFILE
#example of correct format
# send gfs:40N,60N,140W,120W|2,2|24,48,72|PRESS,WIND
TO=query@saildocs.com
SUBJECT=REQUEST
BODY=$(echo "send gfs:"$NEWLATSUB$LATD","$NEWLATADD$LATD","$NEWLONADD$LOND","$NEWLONSUB$LOND"|2,2|24,48,72|"$var1)
COMPOSE
}
QUESTION
exit
fi
exit
}
POSITION(){
POST=$(yad --form --width=420 --text-align=center --center --title="Position" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Position Reports</b> by KM4ACK" \
--field="Choose":CB "Post Position|Single Station Request|All Nearby Stations" \
--field="Enter Call Below <b>ONLY</b> for Single Station Requests":LBL \
--field="Call Sign-SSID" \
--field="Comment for Post Position" \
--button="Main Menu":1 \
--button="Continue":2)
QUIT=$?
if [ $QUIT = 1 ]; then
$MAIN &
exit
elif [ $QUIT = 252 ]; then
exit
fi
REPORT=$(echo $POST | awk -F "|" '{print $1}')
if [ "$REPORT" = "Post Position" ]; then
echo "posting position"
COMMENT=$(echo $POST | awk -F "|" '{print $4}')
pat position -c "$COMMENT" | yad --center --pulsate --progress --auto-close --text="Getting GPS Data" --no-buttons &
yad --center --timeout=3 --timeout-indicator=top --no-buttons \
--text="Position posted to\rPat Winlink Outbox"
$MAIN &
exit
elif [ "$REPORT" = "Single Station Request" ]; then
CALL=$(echo $POST | awk -F "|" '{print $3}')
TO="QTH"
SUBJECT="POSITION REQUEST"
BODY=$CALL
COMPOSE
elif [ "$REPORT" = "All Nearby Stations" ]; then
TO="INQUIRY"
SUBJECT="REQUEST"
BODY="WL2K_NEARBY"
COMPOSE
fi
}
PROPAGATION(){
PROP=$(yad --form --width=420 --text-align=center --center --title="Propagation" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Propagation Reports</b> by KM4ACK" \
--field="Choose Report":CB "3 Day Propagation Report|Daily WWV Report" \
--button="Main Menu":1 \
--button="Continue":2)
QUIT=$?
REPORT=$(echo $PROP | awk -F "|" '{print $1}')
if [ $QUIT = 1 ]; then
$MAIN &
exit
elif [ $QUIT = 252 ]; then
exit
fi
if [ "$REPORT" = "3 Day Propagation Report" ]; then
TO="INQUIRY"
SUBJECT="REQUEST"
BODY="PROP_3DAY"
COMPOSE
elif [ "$REPORT" = "Daily WWV Report" ]; then
TO="INQUIRY"
SUBJECT="REQUEST"
BODY="PROP_WWV"
COMPOSE
fi
}
NEWS(){
NEWS=$(yad --form --width=420 --text-align=center --center --title="News Reports" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>News Reports</b> by KM4ACK\r\rNews reports provided by Reuters" \
--field="Choose News Report":CB "Daily|Market|Money|US News" \
--button="Main Menu":1 \
--button="Continue":2)
QUIT=$?
NEWS=$(echo $NEWS | awk -F "|" '{print $1}')
if [ $QUIT = 1 ]; then
$MAIN &
exit
elif [ $QUIT = 252 ]; then
exit
fi
if [ "$NEWS" = "Daily" ]; then
TO="SMTP:query@saildocs.com"
SUBJECT="subject"
BODY="send Reuters-Daily-News"
COMPOSE
elif [ "$NEWS" = "Market" ]; then
TO="SMTP:query@saildocs.com"
SUBJECT="subject"
BODY="send Reuters-Market"
COMPOSE
elif [ "$NEWS" = "Money" ]; then
TO="SMTP:query@saildocs.com"
SUBJECT="subject"
BODY="send Reuters-Money"
COMPOSE
elif [ "$NEWS" = "US News" ]; then
TO="SMTP:query@saildocs.com"
SUBJECT="subject"
BODY="send Reuters-US-News"
COMPOSE
fi
}

35
catalog Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
#Pat Catalog
#20200427 KM4ACK
#side note: written during covid-19 outbreak of 2020
#######DEV NOTES#############
#############################
#############################
MYPATH=$HOME/patmenu2
LOGO=$MYPATH/pmlogo.png
MAIN=$MYPATH/./patmenu
yad --form --width=420 --text-align=center --center --title="Pat Catalog" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Catalog</b> by KM4ACK" \
--field="Gateway List":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/cat-functions; GATEWAY"' \
--field="Weather Reports":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/cat-functions; WEATHER"' \
--field="Position Reports":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/cat-functions; POSITION"' \
--field="Propagation Reports":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/cat-functions; PROPAGATION"' \
--field="News Reports":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/cat-functions; NEWS"' \
--button="Main Menu":1
QUIT=$?
if [ $QUIT = 1 ]; then
$MAIN &
exit
elif [ $QUIT = 252 ]; then
exit
fi

188
changelog Normal file
View File

@ -0,0 +1,188 @@
release=0.74
Changelog
add FLRIG check to auto pat
0.74 add option to install ruby if needed
add gps grid update to manage pat winlink section
bump version #
0.73 attempt to fix success notice for auto pat
update path in main menu for new changelog file name
rename release to changelog
add alert if auto pat has no data to work with
disallow starting modems multiple times
check if FLRIG is running when starting modems
bump version #
0.72 kill all modems on exit from main menu
add notice to auto connect if no connections were successful
bump version number
0.71 COMPLETE RE WRITE TO INCLUDE YAD INTERFACE
bump version #
0.70 add version number to main menu
create backup of start-pat2m
fix issue 24 https://github.com/km4ack/patmenu/issues/24
bum version #
0.69 fix issue 33 https://github.com/km4ack/patmenu/issues/33
bump version #
0.68 remove bug warning from README.md
reorder release file so latest revs at top
fix release display in update script
update config.default to match config
fix typo in auto pat (Thanks Drudge!)
bump version #
0.67 write email backup/restore scripts
add email backup/restore to pat manage
fix issue 25 https://github.com/km4ack/patmenu/issues/25
move GRIB files to weather section https://github.com/km4ack/patmenu/issues/26
add email-bkup & email-restore +x to setup file
bump version #
0.66 stop modem starts from puking errors if var not found
add extra check before trimode is run
add pulseaudio/pavucontrol install check to trimode
bump version #
0.65 add grib request to catalog
bump version #
0.64 add amrron/trimode check to both modem start scripts
bump version #
0.63 fix catalog typo that caused crash
bump version #
0.62 add post position to catalog
prevent stopping modems in autopat for amrron ops
add trimode script for amrron operators
revise trimode in config
bump version #
0.61 update FLRIG rigctl in config (existing users will not see this)
add trimode variable to config (existing users will not see this)
bump version #
0.60 revert start-pat2m due to critical flaw
bump version number
0.59 improve how direwolf starts on buster
add slight delay after starting ardop mode
bump version #
0.58 add callsign to config file (existing users will not see this)
add config check when menu starts. exit if config not modded
rig control set to no by default in config file
bump version #
0.57 fix bug in add packet script
bump version #
0.56 add min < max check in auto pat
add answer check at beginning of auto pat
rewrite patauto function in patmenu-new
check running modems & stop if needed when running autopat
add grid square check to getardoplist and warn if not set
fix symlink in setup script
add exit to restore config script
convert callsign to upper case in catalog script
bump version #
0.55 add exit option to changeconf script
add symlink to setup for patmenu in /usr/local/bin
open pat inbox in browser when starting packet or ardop modems
change map viewer in findardop to variable
fix map viewer error from showing in pat menu
update main menu with new manage pat menu feature
check autopat to make sure 20,30,40,80 is entered
provide exit from autopat
bump version #
0.54 update gpsdata var in catalog. Thanks K4KDR!
create changeconf script to deal with multiple config files
add menu-mange script for pat menu management
update setup script to +x changeconf & menu-manage
bump version #
0.53 add buster check to start-pat2m
bump version #
0.52 Fix missing file in alias-add-packet
revert to old style symlink until issue is resolved with new style
move kissattach to variable in config file
update restore-config file
bump version #
0.51 Fix variable in autopat
add packet list download to getardoplist
add script alias-add-packet
add script restore-config
update pat-manage menu
update setup script
bump version #
0.50 add way to exit alias-del
make desktop shortcut executable
add rigcontrol check to alias-add for right shortcut
complete re write of findardop that includes add alias shortcuts
bump version #
0.49 fix bug and add alias-del
update pat-manage
add band/freq to new alias when added from pat manage
bump version #
0.48 remove alias-del until major bug can be resolved
bump version #
0.47 add alias-add script
add alias-del script
add check/install jq to setup script (needed for new alias scripts)
add new pat manage menu script
update main menu to include pat manage script
bump version #
0.46 add last DL to findardop
add log file entry to getardoplist
update readme file
bump version #
0.45 sort getardoplist by distance
new style desktop link to setup script
bump version #
0.44 add set-auto-update to findardop script
add new script auto-download called from findardop
add YAD install to setup script
0.43 start modems in backgound
verify other modem not running before starting a new modem
stop ardop_gui when stopping modems
fix issue #17-choose correct text editor based on version
0.42 give user info on change log before update
add rig control check to auto-pat
0.41 add start ARDOP-GUI to start ardop
add start ARDOP-GUI to autopat
remove temp files at start of autopat
0.40 change rigctld start in autopat
add backup for config
0.39 add rigctld check & start to autopat
0.38 close if/then statement in start-pat2m
0.37 add rigctld check & start if needed to start-pat2m
0.36 add rigctld check & start if needed to start-pat-ardop
0.35 move log file variable to config file
0.34 update uninstall
0.33 add mode to config file

16
config Normal file
View File

@ -0,0 +1,16 @@
#Config file for Pat Menu
#20200429 KM4ACK
MYCALLSIGN=KM4ACK
MAP=usa
RIGCONTROL=yes
ARDOP="/home/pi/ardop/./piardopc 8515 plughw:1,0 plughw:1,0"
ARDOPGUI="/home/pi/ardop/./piARDOP_GUI"
DIREWOLF="direwolf -p"
KISS="sudo /usr/sbin/kissattach /tmp/kisstnc"
AXP=wl2k
RIG="/usr/local/bin/rigctl -m 4"
MODEHF=PKTUSB
MODE2M=FM
PORT=5050
LOG=/home/pi/Documents/mylog.txt
AMRRON=no

80
default.config Normal file
View File

@ -0,0 +1,80 @@
#20191230 KM4ACK
#This setup is designed to work with a VOX soundcard (ie Signalink)
#If using a VOX soundcard or radio with a VOX soundcard built in
#simply edit the call sign below to yours and change
#RIGCONTROL=no to RIGCONTROL=yes below.
#Now test the setup. Be sure you have FLRIG open
#and configured for your radio.
#AMRRON operators see bottom of this file for trimode.
#change next line to your call sign
MYCALLSIGN=N0CALL
#enter your piardopc command on the line below
#Be sure to not delete the quotation marks.
ARDOP="$HOME/ardop/./piardopc 8515 plughw:1,0 plughw:1,0"
#Path to ardop-gui if installed
ARDOPGUI=$HOME/ardop/./piARDOP_GUI
#command to start direwolf
DIREWOLF="direwolf -p"
#Kiss attach command
KISS="sudo /usr/sbin/kissattach /tmp/kisstnc"
#axport name for kissattach
AXP=wl2k
#Set map to use with findardop
MAP=usa
#MAP=world
#Use rig control? yes or no
#NOTE: autopat will not work without rig control
RIGCONTROL=no
#enter your rig control command below. DO NOT enter mode
#or frequency commands as these are handled by the script
#Be sure to not delete the quotation marks. DO NOT use
#"rigctld" here. Use "rigctl"
#example for Yaesu 857D
#RIG="/usr/local/bin/rigctl -m 122 -r /dev/ttyUSB0 -s 4800"
#Pass rig control commands through FLRIG (default)
RIG="/usr/local/bin/rigctl -m 4"
#Mode used for HF digital comms on your radio
MODEHF=USB
#Mode used for packet digital comms on your radio
MODE2M=FM
#port number used by pat html service
#pat default is 8080. I prefer 5000
PORT=8080
#Path to log file
LOG=$HOME/Documents/mylog.txt
#Below this line is only useful to AMRRON operators. Others shouldn't edit below this line.
#NOTE:The amrron portion of this script is still experimental.
#set next line to yes for tri-mode setup
AMRRON=no
#amrron operaters should save/exit this config file after setting above to yes and then run
# bash ~/patmenu/trimode
#to enable trimode ops

37
find2 Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
#FIND-ARDOP
#20200425 KM4ACK
#side note: written during covid-19 outbreak of 2020
#######DEV NOTES#############
#############################
#############################
MYPATH=$HOME/patmenu2
PATMENU=$MYPATH/patmenu
LOGO=$MYPATH/pmlogo.png
CURRENT=$(crontab -l | grep getardoplist | awk '{print $2":"$1}')
source $MYPATH/FA-functions
yad --form --width=420 --text="<b>Find Gateways</b> by KM4ACK" --text-align=center --center --title="Find Gateways" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top \
--text="<b>Find Gateways</b> by KM4ACK" \
--field="Search for Gateway":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/FA-functions; GRIDSEARCH"' \
--field="View Grid Map":fbtn 'bash -c "source /home/pi/patmenu2/FA-functions; MAP"' \
--field="Download Gateway List":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/FA-functions; DOWNLIST"' \
--field="Auto List Download <b>$CURRENT</b>":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/FA-functions; AUTODOWN"' \
--field="$LASTDL":LBL \
--button="Main Menu":1
QUIT=$?
if [ $QUIT = 1 ]; then
$PATMENU &
exit
elif [ $QUIT = 252 ]; then
exit
fi

125
getardoplist Executable file
View File

@ -0,0 +1,125 @@
#!/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/
#my log file
LOG=$HOME/Documents/mylog.txt
GRIDCK=$(jq .locator $HOME/.wl2k/config.json)
if [ ${#GRIDCK} -lt 3 ]
then
echo "Grid square not set in Pat Configure" | tee -a $LOG
echo "Distances/Bearings will not be accurate"
yad --center \
--text="Grid square not set in Pat Configure File.\r Run \'pat configure\' to fix"
exit
fi
#make directory if it doesn't exist
mkdir -p $MYPATH
#set variables for each 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'
#check internet connection
echo "Please wait while we check your internet connection"
echo "This may take up to a minute"
#yad --center --timeout=3 --timeout-indicator=top --no-buttons \
#--text="Please wait while we check your connection \rThis can take up to 30 seconds" &
wget -q --tries=5 --timeout=10 --spider http://google.com | yad --center --progress --pulsate --timeout-indicator=top --auto-close --no-buttons --text="Checking internet connection"
if [[ $? -eq 0 ]]; then
echo
#yad --center --timeout=2 --timeout-indicator=top --no-buttons --text="Connection Detected" &
echo
echo "Please wait while files are download"
echo "This may take several minutes"
echo "Depending on your internet speed"
else
yad --center --timeout=2 --timeout-indicator=top --no-buttons --text="You are not connected to the internet" &
exit
fi
#remove old 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
#put date on top line of each file
echo "List Last Downloaded $(date)" >> $FILE
echo "List Last Downloaded $(date)" >> $FORTY
echo "List Last Downloaded $(date)" >> $EIGHTY
echo "List Last Downloaded $(date)" >> $TWENTY
echo "List Last Downloaded $(date)" >> $THIRTY
echo "List Last Downloaded $(date)" >> $PACKET
#yad --center --progress --pulsate --timeout-indicator=top --auto-close --no-buttons --text="Start Download"
#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
yad --center --timeout=2 --timeout-indicator=top --no-buttons --text="Downloads Done" &
}
DL | yad --center --progress --pulsate --auto-close --no-buttons --text-align=center \
--text="Downloading....This takes ~30 seconds\r<b>DO NOT CLOSE THIS WINDOW</b>\rDoing so will abort the download."
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

25
getgrid Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env ruby
require 'gpsd_client'
require 'maidenhead'
require 'socket'
require 'json'
ft8call_port = 2237
gpsd = GpsdClient::Gpsd.new()
gpsd.start()
apicmd = {}
#print come info to the scree
#puts "Your location is being update"
# get maidenhead if gps is ready
if gpsd.started?
pos = gpsd.get_position
maid = Maidenhead.to_maidenhead(pos[:lat], pos[:lon], precision = 5)
# puts "lat = #{pos[:lat]}, lon = #{pos[:lon]}, grid = #{maid}"
puts "#{maid}"
apicmd = {:type => "STATION.SET_GRID", :value => maid}
end

22
griblist Normal file
View File

@ -0,0 +1,22 @@
false
WIND
false
PRESS
false
WAVES
false
APCP
false
PRMSL
false
HGT500
false
SFCTMP
false
TMP500
false
LFTX
false
CAPE

4785
grid-map.pdf Normal file

File diff suppressed because one or more lines are too long

23
manage-menu Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
MYPATH=$HOME/patmenu2
LOGO=$MYPATH/pmlogo.png
source $MYPATH/manage-menu-functions
MAIN=$MYPATH/patmenu
yad --form --width=420 --text-align=center --center --title="Settings" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Menu Settings/Config</b> by KM4ACK" \
--field="Current Config Settings":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/manage-menu-functions; CURRENTCONFIG"' \
--field="Create New Config File":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/manage-menu-functions; NEWCONFIG"' \
--field="Load Config File":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/manage-menu-functions; LOADCONFIG"' \
--button="Main Menu":1
BUT=$?
if [ $BUT = 1 ]; then
$MAIN &
exit
fi
echo $?

249
manage-menu-functions Normal file
View File

@ -0,0 +1,249 @@
MYPATH=$HOME/patmenu2
MAIN=$MYPATH/./manage-menu
LOGO=$MYPATH/pmlogo.png
NEWCONFIG(){
source $MYPATH/config
CONFIGTMP=$MYPATH/config.temp
SETTINGS=$(yad --form --width=600 --text-align=center --center --title="Pat Menu Settings" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Menu Settings</b> by KM4ACK" \
--field="Call Sign" "$MYCALLSIGN" \
--field="MAP":CB "usa|world" \
--field="Rig Control":CB "no|yes" \
--field="ARDOP Command" "$ARDOP" \
--field="ARDOP GUI Command" "$ARDOPGUI" \
--field="Direwolf Command" "$DIREWOLF" \
--field="KISS Command" "$KISS" \
--field="AX25 Port" "$AXP" \
--field="Rig Control Command" "$RIG" \
--field="HF Mode for Radio" "$MODEHF" \
--field="2M Mode for Radio" "$MODE2M" \
--field="Pat Port" "$PORT" \
--field="Log File Location" "$LOG" \
--field="AmRRON":CB "no|yes" \
--button="Create":2 \
--button="Cancel":1)
BUT=$?
if [ $BUT = 1 ]; then
$MAIN
elif [ $BUT = 252 ]; then
exit
elif [ $BUT = 2 ]; then
MYCALLSIGN=$(echo $SETTINGS | awk -F "|" '{print $1}')
MAP=$(echo $SETTINGS | awk -F "|" '{print $2}')
RIGCONTROL=$(echo $SETTINGS | awk -F "|" '{print $3}')
ARDOP=$(echo $SETTINGS | awk -F "|" '{print $4}')
ARDOPGUI=$(echo $SETTINGS | awk -F "|" '{print $5}')
DIREWOLF=$(echo $SETTINGS | awk -F "|" '{print $6}')
KISS=$(echo $SETTINGS | awk -F "|" '{print $7}')
AXP=$(echo $SETTINGS | awk -F "|" '{print $8}')
RIG=$(echo $SETTINGS | awk -F "|" '{print $9}')
MODEHF=$(echo $SETTINGS | awk -F "|" '{print $10}')
MODE2M=$(echo $SETTINGS | awk -F "|" '{print $11}')
PORT=$(echo $SETTINGS | awk -F "|" '{print $12}')
LOG=$(echo $SETTINGS | awk -F "|" '{print $13}')
AMRRON=$(echo $SETTINGS | awk -F "|" '{print $14}')
NAME=$(yad --form --width=600 --text-align=center --center --title="Name?" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Menu Settings</b> by KM4ACK" \
--field="New Config Name")
BUT=$?
if [ $BUT = 1 ]; then
$MAIN &
exit
else
NEWCONFIG=$(echo $NAME | awk -F "|" '{print $1}')
fi
#NEWCONFIG=$(echo $SETTINGS | awk -F "|" '{print $15}')
#NEWCONFIG=$(echo $NEWCONFIG | tr -d "[:blank:]")
NEWCONFIG=$(echo $NEWCONFIG | sed 's/ /./g')
NEWCONFIG=$NEWCONFIG.config
echo "#Config file for Pat Menu" > $CONFIGTMP
echo "#20200429 KM4ACK" >> $CONFIGTMP
echo "MYCALLSIGN=$MYCALLSIGN" >> $CONFIGTMP
echo "MAP=$MAP" >> $CONFIGTMP
echo "RIGCONTROL=$RIGCONTROL" >> $CONFIGTMP
echo "ARDOP=\"$ARDOP\"" >> $CONFIGTMP
echo "ARDOPGUI=\"$ARDOPGUI\"" >> $CONFIGTMP
echo "DIREWOLF=\"$DIREWOLF\"" >> $CONFIGTMP
echo "KISS=\"$KISS\"" >> $CONFIGTMP
echo "AXP=$AXP" >> $CONFIGTMP
echo "RIG=\"$RIG\"" >> $CONFIGTMP
echo "MODEHF=$MODEHF" >> $CONFIGTMP
echo "MODE2M=$MODE2M" >> $CONFIGTMP
echo "PORT=$PORT" >> $CONFIGTMP
echo "LOG=$LOG" >> $CONFIGTMP
echo "AMRRON=$AMRRON" >> $CONFIGTMP
CHECKFILE=$(ls $MYPATH | grep $NEWCONFIG)
if [ -z "$CHECKFILE" ];then
cp $CONFIGTMP $MYPATH/$NEWCONFIG
rm $CONFIGTMP
else
echo "FILE ALREADY EXISTS" ######################
yad --form --width=600 --text-align=center --center --title="Pat Menu Settings" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="\r\rFile already exist!\rOverwrite existing config file?" \
--button="Yes":2 \
--button="No":1
BUT=$?
if [ $BUT = 1 ]; then
$MAIN &
exit
elif [ $BUT = 2 ]; then
cp $CONFIGTMP $MYPATH/$NEWCONFIG
rm $CONFIGTMP
fi
fi
yad --title="Config Created" --width=400 --height=200 \
--image $LOGO --window-icon=$LOGO --image-on-top \
--center --text="$NEWCONFIG created\r\r<b>Don't forget to load the new config file</b>" \
--button=gtk-ok
$MAIN &
exit
fi
}
LOADCONFIG(){
OUTFILE=/run/user/1000/configlist.tmp
ls $MYPATH/ | grep .config > $OUTFILE
INFO=$(PARSER='OFS="\n" {print $1}'
tail -10 $OUTFILE | awk "$PARSER" | \
yad --title="Load Config" --width=400 --height=500 \
--image $LOGO --window-icon=$LOGO --image-on-top \
--center --list --text="Choose Config File to load" \
--column Config-files \
--button="Cancel":1 \
--button="Load Config File":2)
BUT=$?
NEWCONFIG=$(echo $INFO | awk -F "|" '{print $1}')
echo $NEWCONFIG
echo $BUT
if [ $BUT = 252 ]; then
exit
elif [ $BUT = 1 ]; then
$MAIN
exit
elif [ $BUT = 2 ]; then
if [ -z $NEWCONFIG ]; then
$MAIN &
exit
else
cp $MYPATH/$NEWCONFIG $MYPATH/config
rm $OUTFILE
yad --title="Config Loaded" --width=400 --height=200 \
--image $LOGO --window-icon=$LOGO --image-on-top \
--center --text="$NEWCONFIG loaded" \
--button=gtk-ok
$MAIN &
exit
fi
fi
}
CURRENTCONFIG(){
source $MYPATH/config
CONFIGTMP=$MYPATH/config.temp
CONFIG=$MYPATH/config
if [ "$MAP" = 'usa' ]; then
MAP="usa|world"
else
MAP="world|usa"
fi
if [ "$RIGCONTROL" = 'yes' ]; then
RIGCONTROL="yes|no"
else
RIGCONTROL="no|yes"
fi
if [ "$AMRRON" = 'yes' ]; then
AMRRON="yes|no"
else
AMRRON="no|yes"
fi
SETTINGS=$(yad --form --width=600 --text-align=center --center --title="Pat Menu Settings" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Menu Settings</b> by KM4ACK" \
--field="Call Sign" "$MYCALLSIGN" \
--field="MAP":CB "$MAP" \
--field="Rig Control":CB "$RIGCONTROL" \
--field="ARDOP Command" "$ARDOP" \
--field="ARDOP GUI Command" "$ARDOPGUI" \
--field="Direwolf Command" "$DIREWOLF" \
--field="KISS Command" "$KISS" \
--field="AX25 Port" "$AXP" \
--field="Rig Control Command" "$RIG" \
--field="HF Mode for Radio" "$MODEHF" \
--field="2M Mode for Radio" "$MODE2M" \
--field="Pat Port" "$PORT" \
--field="Log File Location" "$LOG" \
--field="AmRRON":CB "$AMRRON" \
--button="Update":2 \
--button="Cancel":1)
BUT=$?
if [ $BUT = 1 ]; then
$MAIN
elif [ $BUT = 252 ]; then
exit
elif [ $BUT = 2 ]; then
MYCALLSIGN=$(echo $SETTINGS | awk -F "|" '{print $1}')
MAP=$(echo $SETTINGS | awk -F "|" '{print $2}')
RIGCONTROL=$(echo $SETTINGS | awk -F "|" '{print $3}')
ARDOP=$(echo $SETTINGS | awk -F "|" '{print $4}')
ARDOPGUI=$(echo $SETTINGS | awk -F "|" '{print $5}')
DIREWOLF=$(echo $SETTINGS | awk -F "|" '{print $6}')
KISS=$(echo $SETTINGS | awk -F "|" '{print $7}')
AXP=$(echo $SETTINGS | awk -F "|" '{print $8}')
RIG=$(echo $SETTINGS | awk -F "|" '{print $9}')
MODEHF=$(echo $SETTINGS | awk -F "|" '{print $10}')
MODE2M=$(echo $SETTINGS | awk -F "|" '{print $11}')
PORT=$(echo $SETTINGS | awk -F "|" '{print $12}')
LOG=$(echo $SETTINGS | awk -F "|" '{print $13}')
AMRRON=$(echo $SETTINGS | awk -F "|" '{print $14}')
echo "#Config file for Pat Menu" > $CONFIGTMP
echo "#20200429 KM4ACK" >> $CONFIGTMP
echo "MYCALLSIGN=$MYCALLSIGN" >> $CONFIGTMP
echo "MAP=$MAP" >> $CONFIGTMP
echo "RIGCONTROL=$RIGCONTROL" >> $CONFIGTMP
echo "ARDOP=\"$ARDOP\"" >> $CONFIGTMP
echo "ARDOPGUI=\"$ARDOPGUI\"" >> $CONFIGTMP
echo "DIREWOLF=\"$DIREWOLF\"" >> $CONFIGTMP
echo "KISS=\"$KISS\"" >> $CONFIGTMP
echo "AXP=$AXP" >> $CONFIGTMP
echo "RIG=\"$RIG\"" >> $CONFIGTMP
echo "MODEHF=$MODEHF" >> $CONFIGTMP
echo "MODE2M=$MODE2M" >> $CONFIGTMP
echo "PORT=$PORT" >> $CONFIGTMP
echo "LOG=$LOG" >> $CONFIGTMP
echo "AMRRON=$AMRRON" >> $CONFIGTMP
cp $CONFIGTMP $CONFIG
rm $CONFIGTMP
$MAIN &
exit
fi
}

28
manage-pat Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
MYPATH=$HOME/patmenu2
LOGO=$MYPATH/pmlogo.png
source $MYPATH/manage-pat-functions
MAIN=$MYPATH/patmenu
yad --form --width=420 --text-align=center --center --title="Manage Pat" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Manage Pat</b> by KM4ACK" \
--field="Pat Login-Logout":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/manage-pat-functions; LOGIN"' \
--field="GPS Grid Update":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/manage-pat-functions; GPSGRID"' \
--field="Set ARDOP Speed":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/manage-pat-functions; SPEED"' \
--field="Delete Alias":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/manage-pat-functions; DELETEALIAS"' \
--field="Backup Emails":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/manage-pat-functions; EMAILBKUP"' \
--field="Restore Emails":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/manage-pat-functions; EMAILRESTORE"' \
--field="Backup Pat Config":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/manage-pat-functions; BKUPCONFIG"' \
--field="Restore Pat Config":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/manage-pat-functions; RESTORECONFIG"' \
--button="Main Menu":1
BUT=$?
if [ $BUT = 1 ]; then
$MAIN &
exit
fi
echo $?

357
manage-pat-functions Normal file
View File

@ -0,0 +1,357 @@
MYPATH=$HOME/patmenu2
MAIN=$MYPATH/./manage-pat
LOGO=$MYPATH/pmlogo.png
DELETEALIAS(){
PATCONFIG=$HOME/.wl2k/config.json
OUTFILE=/run/user/1000/currentlist.txt
TEMP=/run/user/1000/patconfig.txt
WHO=$(whoami)
jq .connect_aliases $PATCONFIG | sed '/^}/d' | sed '/^{/d' | sed 's/^ *//g' > $OUTFILE
cat $OUTFILE
sed -i 's/"//g' $OUTFILE
sed -i 's/,//g' $OUTFILE
sed -i 's/://' $OUTFILE
echo;echo
cat $OUTFILE | awk 'OFS="\n" {print $1, $2}'
REMOVE=$(PARSER='OFS="\n" {print $1, $2}'
tail -10 $OUTFILE | awk "$PARSER" | \
yad --title="Current Alias List" --width=1100 --height=500 \
--image $LOGO --window-icon=$LOGO --image-on-top \
--center --list --text="<b>Select Alias to Delete</b>" \
--column Call --column INFO \
--button="Delete Alias":2 \
--button="Cancel":1)
BUT=$?
if [ $BUT = 1 ]; then
$MAIN &
exit
elif [ $BUT = 252 ]; then
exit
fi
RCALL=$(echo $REMOVE | awk -F "|" '{print $1}')
RCALL1=$(echo "\"$RCALL\"")
#check something was selected
if [ -z "$RCALL" ]; then
yad --title="No Selection" --width=300 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top \
--center --form --text="No station was selected\r Please try again" \
--button=gtk-ok
$MAIN &
exit
fi
jq 'del(.connect_aliases.'$RCALL1')' $PATCONFIG > $TEMP
cp $TEMP $PATCONFIG
rm $TEMP $OUTFILE
sudo killall pat
sudo systemctl start pat@$WHO
yad --title="Alias Deleted" --width=400 --height=200 \
--image $LOGO --window-icon=$LOGO --image-on-top \
--center --text="$RCALL1 Alias DELETED" \
--button=gtk-ok
$MAIN &
exit
}
LOGIN(){
CONFIG=$HOME/.wl2k/config.json
WHO=$(whoami)
USER=$(yad --form --width=420 --text-align=center --center --title="Pat Log In/Out" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Log In/Out</b> by KM4ACK" \
--field="Call Sign" "" \
--field="Winlink Password" "" \
--field="Six Character Grid Square" "EM65TV" \
--button="Log In":2 \
--button="Log Out":3 \
--button="Cancel":1)
BUT=$?
if [ $BUT = 252 ]; then
echo "true exit"
exit
elif [ $BUT = 1 ]; then
echo "cancel"
elif [ $BUT = 2 ]; then
echo "Log IN"
CALLSIGN=$(echo $USER | awk -F "|" '{print $1}')
CALLSIGN=$(echo "${CALLSIGN^^}")
PASS=$(echo $USER | awk -F "|" '{print $2}')
GRID=$(echo $USER | awk -F "|" '{print $3}')
GRID=$(echo "${GRID^^}")
echo "$CALLSIGN $PASS $GRID"
#set callsign
sed -i "s/\"mycall\": \".*\",/\"mycall\": \"$CALLSIGN\",/" $CONFIG
#set password
sed -i "s/\"secure_login_password\": \".*\",/\"secure_login_password\": \"$PASS\",/" $CONFIG
#set locator
sed -i "s/\"locator\": \".*\",/\"locator\": \"$GRID\",/" $CONFIG
sudo killall pat
sudo systemctl start pat@$WHO
elif [ $BUT = 3 ]; then
echo "Log OUT"
CALLSIGN=N0CALL
PASS=""
GRID=""
#set callsign
sed -i "s/\"mycall\": \".*\",/\"mycall\": \"$CALLSIGN\",/" $CONFIG
#set password
sed -i "s/\"secure_login_password\": \".*\",/\"secure_login_password\": \"$PASS\",/" $CONFIG
#set locator
sed -i "s/\"locator\": \".*\",/\"locator\": \"$GRID\",/" $CONFIG
sudo killall pat
sudo systemctl start pat@$WHO
fi
}
GPSGRID(){
CONFIG=$HOME/.wl2k/config.json
if ! hash ruby2.3 2>/dev/null; then
echo "Ruby Not found on system"
yad --form --width=300 --text-align=center --center --title="Ruby not Found" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="Ruby is needed to read GPS data but not found installed on your system. Would you like to install it now?" \
--button="Install Ruby":2 \
--button="Cancel":1
BUT=$?
if [ $BUT = 1 ]; then
$MAIN &
exit
elif [ $BUT = 2 ]; then
INSTALLRUBY(){
sudo apt-get update
sudo apt-get install -y ruby2.3
sudo gem install gpsd_client
sudo gem install maidenhead
}
INSTALLRUBY | yad --center --progress --pulsate --auto-close --no-buttons --text-align=center \
--text="Installing Ruby. This will take several minutes\r<b>DO NOT CLOSE THIS WINDOW</b>\rDoing so will abort the install."
fi
fi
yad --center --timeout=5 --timeout-indicator=top \
--auto-close --no-buttons --text="Getting grid from GPS" &
NEWGRID=$($MYPATH/getgrid | cut -b 1-6)
if [ "$NEWGRID" = 'JJ00aa' ]; then
NEWGRID="GPS READ ERROR or NO LOCK"
yad --form --width=400 --text-align=center --center --title="GPS ERROR" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Update Pat Grid</b> by KM4ACK\r\rGPS ERROR" \
--field="Grid read from GPS":RO "$NEWGRID" \
--button=gtk-quit
$MAIN &
exit
fi
yad --form --width=200 --text-align=center --center --title="Update Grid" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Update Pat Grid</b> by KM4ACK" \
--field="Grid read from GPS":RO "$NEWGRID" \
--button="Update Pat":2 \
--button="Cancel":1
BUT=$?
if [ $BUT = 1 ]; then
$MAIN &
exit
elif [ $BUT = 2 ]; then
sed -i "s/\"locator\": \".*\",/\"locator\": \"$NEWGRID\",/" $CONFIG
yad --center --timeout=2 --timeout-indicator=top \
--auto-close --no-buttons --text="Grid Square Updated"
$MAIN &
exit
fi
}
EMAILBKUP(){
CONFIG=$HOME/.wl2k/config.json
WHO=$(whoami)
CALL=$(cat $HOME/.wl2k/config.json | grep -m 1 mycall | sed 's/\"mycall\": \"//' | sed 's/\",//' | sed -e 's/^\s*//' | tr '[:lower:]' '[:upper:]')
BKUPTIME=$(date +%Y%d%m-%H%M)
BACKUP=$(yad --form --width=420 --text-align=center --center --title="Email Backup" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Email Backup</b> by KM4ACK" \
--field="Backup Directory":DIR \
--button="Backup Emails":2 \
--button="Cancel":1)
BUT=$?
if [ $BUT = 252 ]; then
exit
elif [ $BUT = 1 ]; then
$MAIN
exit
fi
DIR=$(echo $BACKUP | awk -F "|" '{print $1}')
cp -r $HOME/.wl2k/mailbox/$CALL $DIR/email.bkup.$BKUPTIME
if [ -d $DIR/email.bkup.$BKUPTIME ]; then
yad --center --text="Backup Complete" \
--button=gtk-ok
$MAIN &
exit
fi
}
EMAILRESTORE(){
MYPATH=$HOME/dev/patmenu2
CONFIG=$HOME/.wl2k/config.json
WHO=$(whoami)
CALL=$(cat $HOME/.wl2k/config.json | grep -m 1 mycall | sed 's/\"mycall\": \"//' | sed 's/\",//' | sed -e 's/^\s*//' | tr '[:lower:]' '[:upper:]')
RESTORE=$(yad --form --width=420 --text-align=center --center --title="Email Restore" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Email Restore</b> by KM4ACK" \
--field="Restore Directory":DIR \
--button="Restore Emails":2 \
--button="Cancel":1)
BUT=$?
if [ $BUT = 252 ]; then
exit
elif [ $BUT = 1 ]; then
$MAIN
exit
fi
DIR=$(echo $RESTORE | awk -F "|" '{print $1}')
DIRCHECK=$(ls $DIR)
COUNT=${#DIRCHECK}
if [ "$COUNT" = 19 ]; then
cp $DIR/archive/* $HOME/.wl2k/mailbox/$CALL/archive/
cp $DIR/in/* $HOME/.wl2k/mailbox/$CALL/in/
cp $DIR/out/* $HOME/.wl2k/mailbox/$CALL/out/
cp $DIR/sent/* $HOME/.wl2k/mailbox/$CALL/sent/
yad --form --width=420 --text-align=center --center --title="Email Restore" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Email Restore</b> by KM4ACK\r\r<b>RESTORE COMPLETE</b>" \
--button=gtk-ok
else
yad --form --width=420 --text-align=center --center --title="Email Restore" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Email Restore</b> by KM4ACK\r\r<b>Not a valid restore directory</b>" \
--button=gtk-ok
fi
exit
}
RESTORECONFIG(){
CONFIG=$HOME/.wl2k/config.json
OUTFILE=/run/user/1000/config.list
WHO=$(whoami)
ls $HOME/.wl2k/ | grep .bkup > $OUTFILE
INFO=$(PARSER='OFS="\n" {print $1}'
tail -10 $OUTFILE | awk "$PARSER" | \
yad --title="Restore Config" --width=1100 --height=500 \
--image $LOGO --window-icon=$LOGO --image-on-top \
--center --list --text="Choose File to Restore" \
--column File-to-Restore \
--button="Cancel":1 \
--button="Restore File":2)
BUT=$?
if [ $BUT = 252 ]; then
exit
elif [ $BUT = 1 ]; then
$MAIN
exit
fi
FILE=$(echo $INFO | awk -F "|" '{print $1}')
cp $HOME/.wl2k/$FILE $CONFIG
sudo killall pat
sudo systemctl start pat@$WHO
yad --form --width=420 --text-align=center --center --title="Config Restore" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Config Restore</b> by KM4ACK\r\r<b>RESTROE COMPLETE</b>" \
--button=gtk-ok
$MAIN
}
BKUPCONFIG(){
CONFIG=$HOME/.wl2k/config.json
WHO=$(whoami)
DATE=$(date +%d%b%Y-%H%M)
yad --form --width=420 --text-align=center --center --title="Backup Config" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Backup Pat Config</b> by KM4ACK" \
--button="Backup Config":2 \
--button="Main Menu":1
BUT=$?
if [ $BUT = 1 ]; then
$MAIN &
exit
elif [ $BUT = 252 ]; then
exit
elif [ $BUT = 2 ]; then
echo "Backing up file"
BKUPCONFIG=config.$DATE.bkup
cp $CONFIG $HOME/.wl2k/$BKUPCONFIG
yad --form --width=420 --text-align=center --center --title="Config Backup" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Config File Backup</b> by KM4ACK\r\r<b>Backup COMPLETE</b>" \
--button=gtk-ok
fi
$MAIN
}
SPEED(){
CONFIG=$HOME/.wl2k/config.json
CURRENT=$(cat $CONFIG | grep -i max | sed 's/"Max":\ //' | tr -d "[:blank:]")
WHO=$(whoami)
NEW=$(yad --form --width=320 --text-align=center --center --title="Speed" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Current ARDOP Speed is $CURRENT</b>" \
--field="Set ARDOP Speed to":CB "200|500|1000|2000" \
--button="Cancel":1 \
--button="Set Speed":2)
BUT=$?
if [ $BUT = 1 ]; then
$MAIN &
exit
elif [ $BUT = 252 ]; then
exit
fi
NEW=$(echo $NEW | awk -F "|" '{print $1}')
sed -i "s/\"Max\":.*/ \"Max\": $NEW/" $CONFIG
sudo killall pat
sudo systemctl start pat@$WHO
yad --form --width=320 --text-align=center --center --title="Speed" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>ARDOP Speed set to $NEW</b>" \
--button=gtk-ok
$MAIN &
exit
}

146
pat-functions Normal file
View File

@ -0,0 +1,146 @@
MYPATH=$HOME/patmenu2
LOGO=$MYPATH/pmlogo.png
MAIN=$MYPATH/./patmenu
AUTOPAT(){
source $MYPATH/config
if [ $RIGCONTROL == 'no' ]
then
yad --title="NO RIG CONTROL" --width=400 --height=100 \
--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. \
\rRig control can be configured using\r<b>Manage Pat Menu</b>"
--button=gtk-ok
$MAIN &
exit
fi
MIN="50|100|150|200|250|300|350|400|450|500|550|600|650|700|750|800|850|900|950|1000"
MAX="500|550|600|650|700|750|800|850|900|950|1000|1500|2000|2500|3000"
INFO=$(yad --form --width=420 --text-align=center --center --title="Pat Auto" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Auto Connect</b> by KM4ACK" \
--field="Band":CB "20|30|40|80" \
--field="Minimum Distance":CBE "$MIN" \
--field="Maximum Distance":CBE "$MAX" \
--button="Start Connection":2 \
--button="Cancel":1)
BUT=$?
if [ "$BUT" = 1 ]; then
$MAIN
exit
fi
BAND=$(echo $INFO | awk -F "|" '{print $1}')
MIN=$(echo $INFO | awk -F "|" '{print $2}')
MAX=$(echo $INFO | awk -F "|" '{print $3}')
if [ -z "$MIN" ]; then
MIN=0
fi
if [ -z "$MAX" ]; then
MAX=0
fi
if [ "$MIN" -gt "$MAX" ]; then
yad --form --width=420 --text-align=center --center --title="Pat Auto" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Auto Connect</b> by KM4ACK \r\rMinimum distance can't be greater\rthan maximum distance.\rTry again" \
--button=gtk-ok
AUTOPAT
fi
echo "Band = $BAND"
echo "MIN = $MIN"
echo "MAX = $MAX"
lxterminal -e $MYPATH/autopat $MAX $BAND $MIN
$MAIN
}
SETTINGS(){
source $MYPATH/config
CONFIGTMP=$MYPATH/config.temp
CONFIG=$MYPATH/config
SETTINGS=$(yad --form --width=600 --text-align=center --center --title="Pat Menu Settings" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Menu Settings</b> by KM4ACK" \
--field="Call Sign" "$MYCALLSIGN" \
--field="MAP":CB "usa|world" \
--field="Rig Control":CB "no|yes" \
--field="ARDOP Command" "$ARDOP" \
--field="ARDOP GUI Command" "$ARDOPGUI" \
--field="Direwolf Command" "$DIREWOLF" \
--field="KISS Command" "$KISS" \
--field="AX25 Port" "$AXP" \
--field="Rig Control Command" "$RIG" \
--field="HF Mode for Radio" "$MODEHF" \
--field="2M Mode for Radio" "$MODE2M" \
--field="Pat Port" "$PORT" \
--field="Log File Location" "$LOG" \
--field="AmRRON":CB "no|yes" \
--button="Update":2 \
--button="Cancel":1)
BUT=$?
if [ $BUT = 1 ]; then
$MAIN
elif [ $BUT = 252 ]; then
exit
elif [ $BUT = 2 ]; then
MYCALLSIGN=$(echo $SETTINGS | awk -F "|" '{print $1}')
MAP=$(echo $SETTINGS | awk -F "|" '{print $2}')
RIGCONTROL=$(echo $SETTINGS | awk -F "|" '{print $3}')
ARDOP=$(echo $SETTINGS | awk -F "|" '{print $4}')
ARDOPGUI=$(echo $SETTINGS | awk -F "|" '{print $5}')
DIREWOLF=$(echo $SETTINGS | awk -F "|" '{print $6}')
KISS=$(echo $SETTINGS | awk -F "|" '{print $7}')
AXP=$(echo $SETTINGS | awk -F "|" '{print $8}')
RIG=$(echo $SETTINGS | awk -F "|" '{print $9}')
MODEHF=$(echo $SETTINGS | awk -F "|" '{print $10}')
MODE2M=$(echo $SETTINGS | awk -F "|" '{print $11}')
PORT=$(echo $SETTINGS | awk -F "|" '{print $12}')
LOG=$(echo $SETTINGS | awk -F "|" '{print $13}')
AMRRON=$(echo $SETTINGS | awk -F "|" '{print $14}')
echo "#Config file for Pat Menu" > $CONFIGTMP
echo "#20200429 KM4ACK" >> $CONFIGTMP
echo "MYCALLSIGN=$MYCALLSIGN" >> $CONFIGTMP
echo "MAP=$MAP" >> $CONFIGTMP
echo "RIGCONTROL=$RIGCONTROL" >> $CONFIGTMP
echo "ARDOP=\"$ARDOP\"" >> $CONFIGTMP
echo "ARDOPGUI=\"$ARDOPGUI\"" >> $CONFIGTMP
echo "DIREWOLF=\"$DIREWOLF\"" >> $CONFIGTMP
echo "KISS=\"$KISS\"" >> $CONFIGTMP
echo "AXP=$AXP" >> $CONFIGTMP
echo "RIG=\"$RIG\"" >> $CONFIGTMP
echo "MODEHF=$MODEHF" >> $CONFIGTMP
echo "MODE2M=$MODE2M" >> $CONFIGTMP
echo "PORT=$PORT" >> $CONFIGTMP
echo "LOG=$LOG" >> $CONFIGTMP
echo "AMRRON=$AMRRON" >> $CONFIGTMP
cp $CONFIGTMP $CONFIG
rm $CONFIGTMP
$MAIN &
exit
fi
}

43
patmenu Executable file
View File

@ -0,0 +1,43 @@
#!/bin/bash
#Pat Catalog
#20200427 KM4ACK
#side note: written during covid-19 outbreak of 2020
#######DEV NOTES#############
#############################
#############################
MYPATH=$HOME/patmenu2
LOGO=$MYPATH/pmlogo.png
MAIN=$MYPATH/./patmenu
VERSION=$(cat $MYPATH/changelog | grep release | head -1 | sed 's/release=//')
source $MYPATH/config
if [ "$MYCALLSIGN" = "N0CALL" ]; then
yad --title="N0CALL" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \
--center --form --text="\r\r\r\rCall sign not set! \rGo to <b>Settings</b>, then <b>Current Config Settings</b>\rand update your call sign" \
--button=gtk-ok
fi
yad --form --width=420 --text-align=center --center --title="Pat Menu" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Pat Menu</b> by KM4ACK\rv$VERSION" \
--field="Start ARDOP Modem":fbtn 'bash -c "/home/pi/patmenu2/start-pat-ardop"' \
--field="Start Packet Modem":fbtn 'bash -c "/home/pi/patmenu2/start-pat2m"' \
--field="Stop Modems":fbtn 'bash -c "/home/pi/patmenu2/stop-modems"' \
--field="Find Winlink Gateways":fbtn 'bash -c "kill -USR1 $YAD_PID; /home/pi/patmenu2/find2"' \
--field="Pat Auto Connect":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/pat-functions; AUTOPAT"' \
--field="Pat Catalog":fbtn 'bash -c "kill -USR1 $YAD_PID; /home/pi/patmenu2/catalog"' \
--field="Manage Pat Winlink":fbtn 'bash -c "kill -USR1 $YAD_PID; /home/pi/patmenu2/manage-pat"' \
--field="Settings/Config":fbtn 'bash -c "kill -USR1 $YAD_PID; /home/pi/patmenu2/manage-menu"' \
--field="My Call - $MYCALLSIGN":LBL \
--button=gtk-quit
BUT=$?
if [ $BUT = 0 ] && [ "$AMRRON" = 'no' ]; then
sudo killall piardopc direwolf kissattach rigctld piARDOP_GUI > /dev/null 2>&1
fi

9
patmenu2.desktop Normal file
View File

@ -0,0 +1,9 @@
[Desktop Entry]
Name=Pat Menu
GenericName=Amateur Radio Digital Modem
Comment=Amateur Radio Sound Card Communications
Exec=/home/pi/patmenu2/patmenu
Icon=/home/pi/patmenu2/pmlogo.png
Terminal=false
Type=Application
Categories=Network;HamRadio;

BIN
pmlogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

51
setup Normal file
View File

@ -0,0 +1,51 @@
#!/bin/bash
#install script patmenu2
#20200511 km4ack
MYPATH=$HOME/patmenu2
BKDIR=$HOME/Desktop/pat-bkups
NEWCONFIG=$HOME/Desktop/test.txt
if [ -f $HOME/patmenu/config ]; then
#get patmenu config file and copy to patmenu2
source $HOME/patmenu/config
cat << EOF > $NEWCONFIG
MYCALLSIGN=$MYCALLSIGN
MAP=$MAP
RIGCONTROL=$RIGCONTROL
ARDOP=$ARDOP
ARDOPGUI=$ARDOPGUI
DIREWOLF=DIREWOLF
KISS=$KISS
AXP=$AXP
RIG=$RIG
MODEHF=$MODEHF
MODE2M=$MODE2M
PORT=$PORT
LOG=$LOG
AMRRON=$AMRRON
EOF
#create backup folder and copy any user config files
mkdir -p $BKDIR
cp $HOME/patmenu/*config* $BKDIR
#remove restore script that gets copied with above command
rm $BKDIR/restore-config
#remove old patmenu
rm -rf $HOME/patmenu
fi
#copy new desktop link
sudo cp $MYPATH/patmenu2.desktop /usr/share/applications/patmenu.desktop
#download RMS List
$MYPATH/getardoplist
#remove this script
rm $MYPATH/setup

137
start-pat-ardop Executable file
View File

@ -0,0 +1,137 @@
#!/bin/bash
#start ardop modem
#20191118 km4ack
source $HOME/patmenu2/config
MYPATH=$HOME/patmenu2
LOGO=$MYPATH/pmlogo.png
#Check if FLRIG is running if user has it set in config file
if [ "$RIGCONTROL" = 'yes' ]; then
echo "rig control is on"
FLRIG=$(echo $RIG | grep "\-m 4")
if [ -z "$FLRIG" ]; then
echo
else
FLRIG=$(pidof flrig)
if [ -z "$FLRIG" ]; then
yad --title="FAILED" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \
--center --form --text="Please start FLRIG and try again" \
--button=gtk-ok
exit
fi
fi
fi
#Check if modem is already running
MODEMCHECK=$(pidof piardopc)
if [ -z "$MODEMCHECK" ]; then
echo
else
yad --title="FAILED" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \
--center --form --text="ARDOP Modem is already running" \
--button=gtk-ok
exit
fi
if [ $AMRRON = "no" ] > /dev/null 2>&1
then
#check if direwolf is running
PIDDW=$(pidof direwolf)
if [ -z "$PIDDW" ]
then
echo
else
yad --title="FAILED" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \
--center --form --text="It looks like the 2M/440 modem is running.\rStop all modems and try again" \
--button=gtk-ok
exit
fi
fi
yad --width=350 --height=75 --title="Start Modem" --timeout=2 --timeout-indicator=top --no-buttons --center \
--text="Modem Starting....standby" &
SETRIG () {
#Set USB Mode
RIGUSB=$RIG" M $MODEHF 0"
#check rig is in USB
MODE=$($RIG m | grep $MODEHF)
sleep 1
MODECHECK() {
#check rig is in correct mode
MODE=$($RIG m | grep $MODEHF)
}
sleep 1
if [ -z $MODE ]
then
$RIGUSB
MODECHECK
fi
}
#see if rig control is used
if [ $RIGCONTROL == 'yes' ]
then
PIDCTL=$(pidof rigctld)
WHO=$(whoami)
if [ -z "$PIDCTL" ]
then
CONTROL=$(cat $MYPATH/config | grep '^RIG="' | sed 's/RIG="//' | sed 's/"//' | sed 's/rigctl/rigctld/')
$CONTROL &
sudo systemctl restart pat@$WHO
fi
SETRIG
fi
#Start ARDOP_GUI
$ARDOPGUI </dev/null &>/dev/null &
#start modem
lxterminal --geometry=55x10 -e $ARDOP </dev/null &>/dev/null &
sleep 2
#verify that piardopc is running
PIDPIC=$(pidof piardopc)
if [ -z "$PIDPIC" ]
then
yad --title="FAILED" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \
--center --form --text="The ARDOP Modem FAILED to Start" \
--button=gtk-ok
else
yad --title="ARDOP MODEM" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center --on-top \
--center --form --text="\r\r\r\rThe ARDOP Modem has Started" \
--button=gtk-ok &
fi
#open pat inbox in browser
export DISPLAY=:0 && chromium-browser --app=http://127.0.0.1:$PORT > /dev/null 2>&1 &

166
start-pat2m Executable file
View File

@ -0,0 +1,166 @@
#!/bin/bash
#script to start Pat for 2m packet work
#20191116 km4ack
clear
TEMP=$HOME/patmenu2/temp
MYPATH=$HOME/patmenu2
LOGO=$MYPATH/pmlogo.png
source $MYPATH/config
#Check if FLRIG is running if user has it set in config file
if [ "$RIGCONTROL" = 'yes' ]; then
echo "rig control is on"
FLRIG=$(echo $RIG | grep "\-m 4")
if [ -z "$FLRIG" ]; then
echo
else
FLRIG=$(pidof flrig)
if [ -z "$FLRIG" ]; then
yad --title="FAILED" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \
--center --form --text="Please start FLRIG and try again" \
--button=gtk-ok
exit
fi
fi
fi
#Check if modem is already running
MODEMCHECK=$(pidof direwolf)
if [ -z "$MODEMCHECK" ]; then
echo
else
yad --title="FAILED" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \
--center --form --text="Packet Modem is already running" \
--button=gtk-ok
exit
fi
if [ $AMRRON = "no" ] > /dev/null 2>&1
then
#check if piardopc is running
PIDDW=$(pidof piardopc)
if [ -z "$PIDDW" ]
then
echo
else
yad --title="FAILED" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \
--center --form --text="It looks like the ARDOP modem is running.\rStop all modems and try again" \
--button=gtk-ok
exit 0
fi
fi
yad --width=350 --height=75 --title="Start Modem" --timeout=3 --timeout-indicator=top --no-buttons --center \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center --text="Modem Starting....standby" &
if [ $AMRRON = "no" ] > /dev/null 2>&1
then
sudo killall direwolf kissattach > /dev/null 2>&1
fi
sleep 1
#Set Mode
RIGFM=$RIG" M $MODE2M 0"
#set the long date
TODAY=$(date)
#set path to my log
MYLOG=$HOME/Documents/mylog.txt
SETRIG () {
#set radio frequency & mode
$RIGFM
sleep 1
#check rig is in correct mode
MODE=$($RIG m | grep $MODE2M)
sleep 1
MODECHECK() {
#check rig is in correct mode
MODE=$($RIG m | grep $MODE2M)
}
sleep 1
if [ -z $MODE ]
then
$RIGFM
MODECHECK
fi
}
#see if rig control is used
if [ $RIGCONTROL == 'yes' ]
then
PIDCTL=$(pidof rigctld)
WHO=$(whoami)
if [ -z "$PIDCTL" ]
then
CONTROL=$(cat $MYPATH/config | grep '^RIG="' | sed 's/RIG="//' | sed 's/"//' | sed 's/rigctl/rigctld/')
$CONTROL &
sudo systemctl restart pat@$WHO
fi
SETRIG
fi
#added to resolve issue 24. km4ack 20200307
/usr/local/bin/$DIREWOLF </dev/null &>/dev/null &
echo "Almost Done"
sleep 5 | yad --width=350 --height=75 --auto-close --title="Direwolf" --progress --pulsate --no-buttons --center \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center --text="Starting Direwolf....standby"
#find what pt direwolf created (/dev/pts/X)
LINK=$(ls -l /tmp/kisstnc | awk '{print $NF}')
#end edit. km4ack 20200307
sudo /usr/sbin/kissattach $LINK $AXP
sudo kissparms -c 1 -p wl2k
echo;echo;echo
#verify direwolf has started
PIDDW=$(pidof direwolf)
if [ -z "$PIDDW" ]
then
yad --title="FAILED" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \
--center --form --text="The PACKET Modem FAILED to Start" \
--button=gtk-ok
else
yad --title="PACKET MODEM" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center --on-top \
--center --form --text="\r\r\r\rThe PACKET Modem has Started" \
--button=gtk-ok &
fi
#open pat inbox in browser
export DISPLAY=:0 && chromium-browser --app=http://127.0.0.1:$PORT > /dev/null 2>&1 &
#exit 0

19
stop-modems Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
#20191117 km4ack
MYPATH=$HOME/patmenu2
LOGO=$MYPATH/pmlogo.png
#stop all modems that might be running
sudo killall direwolf piardopc kissattach piARDOP_GUI > /dev/null 2>&1
yad --title="Modem Stopped" --width=400 --height=100 \
--image $LOGO --window-icon=$LOGO --image-on-top --text-align=center \
--center --form --text="\r\r\rModem has been stopped" \
--button=gtk-ok
sleep 2
exit 0

76
weather.txt Normal file
View File

@ -0,0 +1,76 @@
FALSE FPAK61.PAFC SOUTHCENTRAL-AK
FALSE FPAK62.PAFC SW AK-&-ALEUTIAN ISLANDS
FALSE FPCA62.TJSJ PR
FALSE FPHW60.PHFO HI
FALSE FPUS54.KHUN ZONE-FORECAST-TN-VALLEY
FALSE FPUS61.KAKQ VA
FALSE FPUS61.KBOX CT-MA-RI
FALSE FPUS61.KBTV VT
FALSE FPUS61.KBUF NY
FALSE FPUS61.KCAR ME
FALSE FPUS61.KCLE OH
FALSE FPUS61.KCTP PA
FALSE FPUS61.KGYX ME-NH
FALSE FPUS61.KLWX MD PANHANDLE-WV
FALSE FPUS61.KOKX NE-NJ-SE-NY-S-CT
FALSE FPUS61.KPHI DE-NJ
FALSE FPUS61.KRLX WV-KY-SE-OH-SE-VA
FALSE FPUS62.KCAE SC
FALSE FPUS62.KFFC GA
FALSE FPUS62.KJAX NE-FL-SE-GA
FALSE FPUS62.KKEY FL-KEYS
FALSE FPUS62.KMFL FL
FALSE FPUS62.KRAH NC
FALSE FPUS62.KTAE TALLAHASSEE-FL-AREA
FALSE FPUS63.KBIS ND
FALSE FPUS63.KDMX IA
FALSE FPUS63.KFSD SD
FALSE FPUS63.KGRR MI
FALSE FPUS63.KICT KS
FALSE FPUS63.KILX IL
FALSE FPUS63.KIND IN
FALSE FPUS63.KLMK KY
FALSE FPUS63.KLSX MO
FALSE FPUS63.KMKX WI
FALSE FPUS63.KMPX MN
FALSE FPUS64.KBMX AL
FALSE FPUS64.KBRO DEEP-SOUTH-TEXAS
FALSE FPUS64.KCRP SOUTH-TEXAS
FALSE FPUS64.KEPZ SW-SCENTRAL-NM-FAR-WEST-TEXAS
FALSE FPUS64.KEWX SW-SCENTRAL-NM-FAR-WEST-TEXAS
FALSE FPUS64.KFWD TX-FORT-WORTH-NWS
FALSE FPUS64.KHGX SE-TX
FALSE FPUS64.KHUN TAB-ST-TN-VALLEY-AND-N-AL
FALSE FPUS64.KJAN MS
FALSE FPUS64.KLIX LA
FALSE FPUS64.KLZK AR
FALSE FPUS64.KMAF TX-MIDLAND-NWS
FALSE FPUS64.KOHX MIDDLE-TN
FALSE FPUS64.KSJT TX-SAN-ANGELO-NWS
FALSE FPUS64.KTSA E-OK-&-NW-AR
FALSE FPUS65.KABQ N-&-CENTRAL-NM
FALSE FPUS65.KBOI SW-ID-&-SE-OR
FALSE FPUS65.KBOU CO
FALSE FPUS65.KBYZ S-CENTRAL-&-SOUTHEASTERN-MT
FALSE FPUS65.KCYS WY
FALSE FPUS65.KFGZ AZ
FALSE FPUS65.KGGW NE-MT
FALSE FPUS65.KLKN NORTHEN-AND-CENTRAL-NV
FALSE FPUS65.KPIH SE-ID
FALSE FPUS65.KPSR SW-AZ-&-SE-CA
FALSE FPUS65.KREV NV
FALSE FPUS65.KSLC UT
FALSE FPUS65.KVEF GREAT-BASIN-&-MOJAVE
FALSE FPUS65.SFT N-AZ
FALSE FPUS66.KEKA N-CA
FALSE FPUS66.KLOX SOUTHERN-CA
FALSE FPUS66.KMFR S-OR-&-N-CA
FALSE FPUS66.KMTR SAN-FRANCISCO-BAY-AREA
FALSE FPUS66.KOTX E-WA-&-N-ID
FALSE FPUS66.KPDT NE-OR-&-SE-WA
FALSE FPUS66.KPQR OREGON-TEXT-FORCAST
FALSE FPUS66.KSEW NW-WA
FALSE FPUS66.KSGX EXTREME-SW-CA
FALSE FPUS66.KSTO N-&-CENTRAL CA
FALSE FPUS66.KSTOA CA
FALSE FPUS65.KVEF LAS-VEGAS-REGION-NV

BIN
worldgridmap.pdf Normal file

Binary file not shown.