diff --git a/manage-pat-functions b/manage-pat-functions index edf2589..c84a891 100644 --- a/manage-pat-functions +++ b/manage-pat-functions @@ -358,7 +358,102 @@ yad --form --width=400 --text-align=center --center --title="Grid Update" --text $MAIN } - +LISTEN(){ +#This funtion sets the listen modes for Pat Winlink +WHO=$(whoami) +TEMP=/run/user/$UID/listen.txt +NOW=$(grep ExecStart /lib/systemd/system/pat@.service | sed 's|ExecStart=/usr/bin/pat -l||;s/http//') +if [ $NOW = 'ExecStart=/usr/bin/pat' ]; then +NOW="Not listening for incoming connections" +fi + +LISTEN=$(yad --center --list --checklist --width=600 --height=300 --separator="|" \ +--image $LOGO --column=Check --column=Mode --column=Description \ +--print-column=2 --window-icon=$LOGO --image-on-top --text-align=center \ +--text="Pat Listen Modes\rCurrently Listening on:\r$NOW" --title="Pat Menu" \ +false "TELNET" "Connection over Internet or Mesh" \ +false "AX25" "Packet Connections 2M-440" \ +false "ARDOP" "HF Connections using ARDOP Modem" \ +--button="Main Menu":1 \ +--button="Set Listen Mode":2 \ +--button="Stop Listening":3) +BUT=$? +if [ $BUT = 252 ]; then +exit +elif [ $BUT = 1 ]; then +$MAIN & +exit +elif [ $BUT = 2 ]; then +#Send results to temp file. +echo $LISTEN > $TEMP +#check temp file for what's there +TELNET=$(grep TELNET $TEMP) +ARDOP=$(grep ARDOP $TEMP) +AX25=$(grep AX25 $TEMP) +#Set telnet variable + if [ -n "$TELNET" ]; then + TELNET="telnet," + fi +#set ardop variable + if [ -n "$ARDOP" ]; then + ARDOP="ardop," + fi +#set ax25 variable + if [ -n "$AX25" ]; then + AX25="ax25," + fi +cat < $TEMP +[Unit] +Description=pat - Winlink client for %I +Documentation=https://github.com/la5nta/pat/wiki +After=ax25.service network.target + +[Service] +User=%i +ExecStart=/usr/bin/pat http +Restart=on-failure + +[Install] +WantedBy=multi-user.target +EOF +#add listen modes set by user +sed -i "s|Exec.*|ExecStart=/usr/bin/pat -l $TELNET$ARDOP$AX25 http|" $TEMP +sudo cp $TEMP /lib/systemd/system/pat@.service +sudo systemctl daemon-reload +sudo systemctl restart pat@$WHO +yad --form --width=320 --text-align=center --center --title="Listening" --text-align=center \ +--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \ +--text="Listen mode set to $TELNET$ARDOP$AX25" \ +--button=gtk-ok +$MAIN & +exit + +elif [ $BUT = 3 ]; then +cat < $TEMP +[Unit] +Description=pat - Winlink client for %I +Documentation=https://github.com/la5nta/pat/wiki +After=ax25.service network.target + +[Service] +User=%i +ExecStart=/usr/bin/pat http +Restart=on-failure + +[Install] +WantedBy=multi-user.target +EOF +sudo cp $TEMP /lib/systemd/system/pat@.service +sudo systemctl daemon-reload +sudo systemctl restart pat@$WHO +fi +yad --form --width=320 --text-align=center --center --title="Listening" --text-align=center \ +--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \ +--text="No longer listening for incoming connections" \ +--button=gtk-ok +$MAIN & +exit +}