#!/bin/bash
#scirpt to convert WL2K_NEARBY to POS file
#that can be imported into YAAC
#KM4ACK 01AUGUST2022
MYPATH=$HOME/patmenu2
LOGO=$MYPATH/pmlogo.png
MAIN=$MYPATH/./catalog
CONFIG=$HOME/.config/pat/config.json
PATCALL=$(grep mycall $HOME/.config/pat/config.json | head -1 | sed 's/"mycall": "//;s/",//;s/ //g')
LIST=$HOME/.local/share/pat/mailbox/$PATCALL/in
MAILBOX=$HOME/.local/share/pat/mailbox/$PATCALL/in
yad --form --width=500 --text-align=center --center --title="WL2K to ARPS Object" --text-align=center \
--image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \
--text="CAUTION\rBe sure only one WL2K_NEARBY report\ris in your inbox. Multiples will cause erroneous data."
BUT=$?
if [ $BUT = 1 ]; then
$MAIN &
exit
elif [ $BUT = 252 ]; then
exit
fi
if [ -f $HOME/Desktop/gateways.pos ]; then
rm $HOME/Desktop/gateways.pos
fi
yad --center --timeout=2 --timeout-indicator=top --no-buttons \
--text="Processing File" &
for file in $MAILBOX/*
do
NEARBY_LIST=$(grep WL2K_NEARBY $file)
if [ -n "$NEARBY_LIST" ]; then
FILE=$file
fi
done
cp $FILE /run/user/$UID/tempgatelist
if [ $? = 1 ]; then
yad --form --width=500 --text-align=center --center --title="WL2K to ARPS Object" --text-align=center \
--image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \
--text="FAILED\rNo Nearby (WL2K_NEARBY) File Found in Inbox"
$MAIN &
exit
fi
sed -i '1,17d' /run/user/$UID/tempgatelist
while read -r line; do
CALL=$(echo $line | awk '{print $1}')
CALL=$CALL-WL
CALL=`printf "%-9s" $CALL`
LAT=$(echo $line | awk '{print $5}' | sed 's/-//')
LONG=$(echo $line | awk '{print $6}' | sed 's/-//')
COMMENT=$(echo $line | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//')
TIME=$(date -u +%H%M%S)
echo ";$CALL*$TIME""h""$LAT/$LONG-$COMMENT" >> ~/Desktop/gateways.pos
done < /run/user/$UID/tempgatelist
yad --form --width=500 --text-align=center --center --title="WL2K to ARPS Object" --text-align=center \
--image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \
--text="Processing done.\rA gateways.pos file has been created and\r is on your desktop ready to import into YAAC."
#rm /run/user/$UID/tempgatelist
$MAIN &
exit
echo "$CALL*$TIME""z""$LAT/$LONG-$COMMENT" > ~/Desktop/gateways.pos