diff --git a/.getardoplist-cron b/.getardoplist-cron
index b185ca5..ee84704 100755
--- a/.getardoplist-cron
+++ b/.getardoplist-cron
@@ -30,6 +30,9 @@ echo "Distances/Bearings will not be accurate"
exit
fi
+GRID=$(grep locator ~/.wl2k/config.json | sed 's/"locator"://;s/"//g;s/,//;s/ //g')
+echo "GRID=$GRID" > $HOME/patmenu2/.grid
+
#make directory if it doesn't exist
mkdir -p $MYPATH
@@ -41,6 +44,7 @@ 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"
diff --git a/FA-functions b/FA-functions
index cb6f8d0..3ee78f4 100644
--- a/FA-functions
+++ b/FA-functions
@@ -30,7 +30,7 @@ exit
AUTODOWN(){
FILE=/run/user/$UID/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
+HOURS=At-Boot,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 \
@@ -49,16 +49,31 @@ 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"
+ if [ $HOUR = 'At-Boot' ]; then
+ echo "@reboot sleep 10 && $MYPATH/.getardoplist-cron" >> $FILE
+ crontab $FILE
+ 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
+
+ else
+
+ echo "$MIN $HOUR * * * $MYPATH/.getardoplist-cron" >> $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
+ $MAIN &
+ rm $FILE
+ exit
+ fi
elif [[ $rc -eq 1 ]]; then
echo "BYE"
$MAIN &
@@ -272,7 +287,123 @@ MAP=$MYPATH/worldgridmap.pdf
fi
xdg-open $MAP
}
-
+#--------------------------------
+# Alternate Grid Download
+#--------------------------------
+#make new dir in pat menu dir if needed
+mkdir -p $HOME/patmenu2/alt-ardop-list
+
+ALTGRID(){
+#check internet connection
+echo "Please wait while we check your internet connection"
+echo "This may take up to a minute"
+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
+#yad --center --timeout=2 --timeout-indicator=top --no-buttons --text="Connection Detected" &
+ echo "Connection detected"
+else
+yad --center --timeout=3 --timeout-indicator=top --no-buttons --text="You are not connected to the internet"
+ exit
+fi
+
+#Create temp config file to use for downloads
+MAINFILE=$HOME/.wl2k/config.json
+TEMPFILE=/run/user/$UID/config.json
+cp $MAINFILE $TEMPFILE
+
+GRID=$(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="Pat Log In/Out by KM4ACK" \
+--field="Alt Grid" "" \
+--button="Download Gateway List":2 \
+--button="Cancel":1)
+BUT=$?
+if [ $BUT = 252 ]; then
+exit
+elif [ $BUT = 1 ]; then
+$MAIN &
+exit
+fi
+GRID=$(echo $GRID | awk -F "|" '{print $1}')
+
+sed -i "s/\"locator\":.*/\"locator\": \"$GRID\",/" $TEMPFILE
+
+#Download the files
+FOLDER=$HOME/patmenu2/alt-ardop-list/ardop-list-$GRID
+mkdir -p $FOLDER
+echo "downloading....please wait"
+ DL(){
+ pat --config /run/user/1000/config.json rmslist -s --band 80m --mode ardop --force-download > $FOLDER/80mardoplist.txt
+ pat --config /run/user/1000/config.json rmslist -s --band 40m --mode ardop --force-download > $FOLDER/40mardoplist.txt
+ pat --config /run/user/1000/config.json rmslist -s --band 30m --mode ardop --force-download > $FOLDER/30mardoplist.txt
+ pat --config /run/user/1000/config.json rmslist -s --band 20m --mode ardop --force-download > $FOLDER/20mardoplist.txt
+ pat --config /run/user/1000/config.json rmslist -s --mode packet --force-download > $FOLDER/packet.txt
+ 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\rDO NOT CLOSE THIS WINDOW\rDoing so will abort the download."
+rm $TEMPFILE
+$MAIN &
+exit
+}
+#--------------------------------
+# Load Alternate Grid List
+#--------------------------------
+LOADALTGRID(){
+OUTFILE=/run/user/$UID/alt-grid.list
+
+ls $HOME/patmenu2/alt-ardop-list > $OUTFILE
+
+LIST=$(PARSER='OFS="\n" {print $1}'
+
+tail -10 $OUTFILE | awk "$PARSER" | \
+yad --title="Load Packet List" --width=300 --height=500 \
+ --image $LOGO --window-icon=$LOGO --image-on-top \
+ --center --list --text="Choose List to Load" \
+ --column List-to-Load \
+ --button="Cancel":1 \
+ --button="Load List":2 \
+ --button="Delete All Lists":3)
+BUT=$?
+LIST=$(echo $LIST | awk -F "|" '{print $1}')
+echo $LIST
+if [ $BUT = 252 ]; then
+exit
+elif [ $BUT = 1 ]; then
+$MAIN &
+exit
+elif [ $BUT = 3 ]; then
+yad --title="Delete List" --width=100 --height=100 \
+ --image $LOGO --window-icon=$LOGO --image-on-top \
+ --center --text="Are You Sure?" \
+ --button="YES":1 \
+ --button="NO":2
+BUT=$?
+ if [ $BUT = 1 ]; then
+ rm -rf $HOME/patmenu2/alt-ardop-list
+ yad --center --timeout=2 --timeout-indicator=top --no-buttons --text="Alt Lists Deleted"
+ $MAIN &
+ exit
+ fi
+$MAIN &
+exit
+fi
+#backup home grid before loading alt grid
+HOMEGRID=$(grep locator $HOME/.wl2k/config.json | sed 's/"//g;s/locator://;s/,//;s/ //g')
+if [ ! -d $HOME/patmenu2/alt-ardop-list/ardop-list-$HOMEGRID ]; then
+echo "Backing up home grid"
+mkdir -p $HOME/patmenu2/alt-ardop-list/ardop-list-$HOMEGRID
+cp $HOME/patmenu2/ardop-list/* $HOME/patmenu2/alt-ardop-list/ardop-list-$HOMEGRID
+fi
+
+#load alt grid
+cp -r $HOME/patmenu2/alt-ardop-list/$LIST/* $HOME/patmenu2/ardop-list/
+LIST=$(echo $LIST | sed 's/ardop-list-//')
+yad --center --timeout=2 --timeout-indicator=top --no-buttons --text="Grid $LIST Loaded"
+echo "GRID=$LIST" > $HOME/patmenu2/.grid
+$MAIN &
+exit
+}
diff --git a/changelog b/changelog
index d029489..ea8a765 100644
--- a/changelog
+++ b/changelog
@@ -1,7 +1,15 @@
-release=2.3.0
+release=2.4.0
Changelog
+2.4.0 Add pat server status to quick stats https://github.com/km4ack/patmenu2/issues/25
+ Add alternate grid download
+ Add alternate grid selection
+ Add backup home grid ardop list files
+ Add manage forms
+ Add auto forms download - https://github.com/km4ack/patmenu2/issues/30
+ fix issue 26 https://github.com/km4ack/patmenu2/issues/26
+ fix issue 24 https://github.com/km4ack/patmenu2/issues/24
2.3.0 Add new mailbox management section
archive all email
delete archives
diff --git a/find2 b/find2
index 8dba1a0..235d4a0 100755
--- a/find2
+++ b/find2
@@ -14,17 +14,22 @@ MYPATH=$HOME/patmenu2
PATMENU=$MYPATH/patmenu
LOGO=$MYPATH/pmlogo.png
CURRENT=$(crontab -l | grep getardoplist | awk '{print $2":"$1}')
+source $MYPATH/.grid
+GRID=$GRID
source $MYPATH/FA-functions
-yad --form --width=420 --text="Find Gateways by KM4ACK" --text-align=center --center --title="Find Gateways" --text-align=center \
+yad --form --width=480 --text="Find Gateways by KM4ACK" --text-align=center --center --title="Find Gateways" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top \
--text="Find Gateways 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 $CURRENT":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/FA-functions; AUTODOWN"' \
---field="$LASTDL":LBL \
+--field="Download Home Grid Gateway List":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/FA-functions; DOWNLIST"' \
+--field="Download Alternate Grid Gateway List":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/FA-functions; ALTGRID"' \
+--field="Load Alternate Grid Gateway List":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/FA-functions; LOADALTGRID"' \
+--field="Auto Download Home Grid List $CURRENT":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/FA-functions; AUTODOWN"' \
+--field="Home $LASTDL":LBL \
+--field="Grid List Currently Loaded $GRID":LBL \
--button="Main Menu":1
QUIT=$?
diff --git a/getardoplist b/getardoplist
index 9eefe44..f401cb8 100755
--- a/getardoplist
+++ b/getardoplist
@@ -42,6 +42,8 @@ FORTY=$MYPATH'40mardoplist.txt'
TWENTY=$MYPATH'20mardoplist.txt'
THIRTY=$MYPATH'30mardoplist.txt'
PACKET=$MYPATH'packet.txt'
+GRID=$(grep locator ~/.wl2k/config.json | sed 's/"locator"://;s/"//g;s/,//;s/ //g')
+echo "GRID=$GRID" > $HOME/patmenu2/.grid
#check internet connection
echo "Please wait while we check your internet connection"
diff --git a/manage-form-functions b/manage-form-functions
new file mode 100644
index 0000000..84d18d7
--- /dev/null
+++ b/manage-form-functions
@@ -0,0 +1,57 @@
+MYPATH=$HOME/patmenu2
+MAIN=$MYPATH/./manage-forms
+LOGO=$MYPATH/pmlogo.png
+
+DOWNLOAD(){
+#yad --center --timeout=3 --timeout-indicator=top --no-buttons --text="Downloading Forms - Please wait" \
+#--image $LOGO --window-icon=$LOGO --image-on-top &
+lxterminal -e /usr/bin/pat updateforms
+yad --center --timeout=3 --timeout-indicator=top --no-buttons --text="Forms Download Complete" \
+--image $LOGO --window-icon=$LOGO --image-on-top
+exit &
+$MAIN
+}
+
+AUTO-DOWNLOAD(){
+CHOICE="Weekly,At-Boot"
+FREQ=$(yad --center --wrap --width=350 --title="Auto Download" --text-align=center \
+--text="Download Weekly or at boot?" \
+--image $LOGO --window-icon=$LOGO --image-on-top \
+--button="Update:2" \
+--button="Cancel:1" \
+--form --separator="," --item-separator="," \
+--field="Choose":CB $CHOICE \
+)
+BUT=$?
+FREQ=$(echo $FREQ | awk -F "|" '{print $1}' | sed 's/,//')
+if [ $FREQ = 'At-Boot' ]; then
+FREQ=@reboot
+fi
+echo "FREQ = $FREQ"
+if [ $BUT = 1 ]; then
+exit &
+$MAIN
+elif [ $BUT = 252 ]; then
+exit
+elif [ $BUT = 2 ]; then
+echo "updating cron"
+FILE=/run/user/$UID/cron.txt
+crontab -l > $FILE
+sed -i '/updateforms$/d' $FILE
+ if [ $FREQ = '@reboot' ]; then
+ TEXT="@reboot sleep 10 && /usr/bin/pat updateforms"
+ FREQ="At-Boot"
+ else
+ TEXT="0 4 * * 6 /usr/bin/pat updateforms"
+ FREQ="Weekly"
+ fi
+echo "$TEXT" >> $FILE
+crontab $FILE
+rm $FILE
+exit &
+yad --center --timeout=3 --timeout-indicator=top --no-buttons --text="Auto download set to $FREQ" \
+--image $LOGO --window-icon=$LOGO --image-on-top
+$MAIN
+fi
+
+}
\ No newline at end of file
diff --git a/manage-forms b/manage-forms
new file mode 100755
index 0000000..0a3aaa1
--- /dev/null
+++ b/manage-forms
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+export MYPATH=$HOME/patmenu2
+LOGO=$MYPATH/pmlogo.png
+source $MYPATH/manage-pat-functions
+MAIN=$MYPATH/patmenu
+FILE=/run/user/$UID/tempcron.txt
+crontab -l > $FILE
+STATUS=$(grep updateforms $FILE | awk '{print $1}')
+rm $FILE
+
+if [ $STATUS = 0 ]; then
+STATUS=Weekly
+elif [ $STATUS = '@reboot' ]; then
+STATUS="At boot"
+else
+STATUS="Not Set"
+fi
+
+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="Manage Pat by KM4ACK" \
+--field="Download Latest Forms":fbtn 'bash -c "kill -USR1 $YAD_PID; source $MYPATH/manage-form-functions; DOWNLOAD"' \
+--field="Auto Download Forms $STATUS":fbtn 'bash -c "kill -USR1 $YAD_PID; source $MYPATH/manage-form-functions; AUTO-DOWNLOAD"' \
+--button="Main Menu":1
+BUT=$?
+
+if [ $BUT = 1 ]; then
+$MAIN &
+exit
+fi
\ No newline at end of file
diff --git a/manage-pat-functions b/manage-pat-functions
index c84a891..7ca1fe5 100644
--- a/manage-pat-functions
+++ b/manage-pat-functions
@@ -24,7 +24,7 @@ cat $OUTFILE | awk 'OFS="\n" {print $1, $2}'
REMOVE=$(PARSER='OFS="\n" {print $1, $2}'
-tail -10 $OUTFILE | awk "$PARSER" | \
+tail -50 $OUTFILE | awk "$PARSER" | \
yad --title="Current Alias List" --width=1100 --height=500 \
--image $LOGO --window-icon=$LOGO --image-on-top \
--center --list --text="Select Alias to Delete" \
@@ -97,8 +97,7 @@ sed -i "s/\"mycall\": \".*\",/\"mycall\": \"$CALLSIGN\",/" $CONFIG
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
+sudo systemctl restart pat@$WHO
$MAIN &
exit
elif [ $BUT = 3 ]; then
diff --git a/pat-functions b/pat-functions
index 0cbb3f7..1ac39c5 100644
--- a/pat-functions
+++ b/pat-functions
@@ -145,6 +145,7 @@ RIG=$(grep RIGCONTROL $HOME/patmenu2/config | sed 's/RIGCONTROL=//')
TELNET=$(grep telnet, $SMD)
ARDOP=$(grep ardop, $SMD)
AX25=$(grep ax25, $SMD)
+PAT=$(pidof pat)
#Set telnet variable
if [ -n "$TELNET" ]; then
TELNET="telnet,"
@@ -163,6 +164,13 @@ else
LISTEN="$TELNET$ARDOP$AX25"
fi
+#set Pat Variable
+if [ -z $PAT ]; then
+PAT="Not Running"
+else
+PAT="Running"
+fi
+
yad --form --width=320 --text-align=center --center --title="Quick Stats" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="Quick Stats" \
@@ -173,6 +181,7 @@ yad --form --width=320 --text-align=center --center --title="Quick Stats" --text
--field="Listen Modes":RO "$LISTEN" \
--field="Rig Control":RO "$RIG" \
--field="Pat Port":RO "$PORT" \
+--field="Pat Server":RO "$PAT" \
--button=gtk-ok
$MAIN &
exit
diff --git a/patmenu b/patmenu
index b0d2eaa..5edf943 100755
--- a/patmenu
+++ b/patmenu
@@ -31,6 +31,7 @@ yad --form --width=420 --text-align=center --center --title="Pat Menu" --text-al
--field="Pat Catalog":fbtn 'bash -c "kill -USR1 $YAD_PID; $MYPATH/catalog"' \
--field="Manage Inbox":fbtn 'bash -c "kill -USR1 $YAD_PID; $MYPATH/manage-inbox"' \
--field="Manage Pat Winlink":fbtn 'bash -c "kill -USR1 $YAD_PID; $MYPATH/manage-pat"' \
+--field="Manage Winlink Forms":fbtn 'bash -c "kill -USR1 $YAD_PID; $MYPATH/manage-forms"' \
--field="Settings/Config":fbtn 'bash -c "kill -USR1 $YAD_PID; $MYPATH/manage-menu"' \
--field="Quick Stats":fbtn 'bash -c "kill -USR1 $YAD_PID; source $MYPATH/pat-functions; STATS"' \
--field="My Call - $MYCALLSIGN":LBL \