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

Merge pull request #34 from km4ack/dev

Dev
This commit is contained in:
KM4ACK 2021-10-29 16:07:58 -05:00 committed by GitHub
commit 5aaf333b69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 265 additions and 18 deletions

View File

@ -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"

View File

@ -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="<b>Pat Log In/Out</b> 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\r<b>DO NOT CLOSE THIS WINDOW</b>\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
}

View File

@ -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

13
find2
View File

@ -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="<b>Find Gateways</b> by KM4ACK" --text-align=center --center --title="Find Gateways" --text-align=center \
yad --form --width=480 --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 \
--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 <b>$CURRENT</b>":fbtn 'bash -c "kill -USR1 $YAD_PID; source /home/pi/patmenu2/FA-functions; AUTODOWN"' \
--field="Home $LASTDL":LBL \
--field="Grid List Currently Loaded <b>$GRID</b>":LBL \
--button="Main Menu":1
QUIT=$?

View File

@ -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"

57
manage-form-functions Normal file
View File

@ -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
}

31
manage-forms Executable file
View File

@ -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="<b>Manage Pat</b> by KM4ACK" \
--field="Download Latest Forms":fbtn 'bash -c "kill -USR1 $YAD_PID; source $MYPATH/manage-form-functions; DOWNLOAD"' \
--field="Auto Download Forms <b>$STATUS</b>":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

View File

@ -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="<b>Select Alias to Delete</b>" \
@ -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

View File

@ -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="<b>Quick Stats</b>" \
@ -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

View File

@ -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 \