From b76533dbf9693af3354414f15f3d929e382e67aa Mon Sep 17 00:00:00 2001 From: Steve Magnuson Date: Sun, 22 Sep 2019 16:34:30 -0700 Subject: [PATCH] Added nameradios.desktop adn watchdog-tnc.sh --- hampi-utilities.version | 2 +- nameradios.desktop | 10 ++++ watchdog-tnc.sh | 130 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 nameradios.desktop create mode 100755 watchdog-tnc.sh diff --git a/hampi-utilities.version b/hampi-utilities.version index a56028d..a672426 100644 --- a/hampi-utilities.version +++ b/hampi-utilities.version @@ -1 +1 @@ -VERSION="1.0.0" \ No newline at end of file +VERSION="1.0.1" \ No newline at end of file diff --git a/nameradios.desktop b/nameradios.desktop new file mode 100644 index 0000000..4c4d128 --- /dev/null +++ b/nameradios.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=Name Your Radios +GenericName=Name Your Radios +Comment=Change the title bars of certain apps to something other then Left Radio and Right Radio +Exec=lxterminal --geometry=90x30 -t "Update Apps/OS" -e "/usr/local/bin/name-radios.sh" +Icon=/usr/share/raspberrypi-artwork/raspitr.png +Terminal=false +Type=Application +Categories=HamRadio; +Comment[en_US]=Name Your Radios Something diff --git a/watchdog-tnc.sh b/watchdog-tnc.sh new file mode 100755 index 0000000..62f9b79 --- /dev/null +++ b/watchdog-tnc.sh @@ -0,0 +1,130 @@ +#!/bin/bash + +#How are you running Direwolf : within a GUI (Xwindows / VNC) or CLI mode +# +# AUTO mode is design to try starting direwolf with GUI support and then +# if no GUI environment is available, it reverts to CLI support with screen +# +# GUI mode is suited for users with the machine running LXDE/Gnome/KDE or VNC +# which auto-logs on (sitting at a login prompt won't work) +# +# CLI mode is suited for say a Raspberry Pi running the Jessie LITE version +# where it will run from the CLI w/o requiring Xwindows - uses screen + +VERSION="2.1" + +RUNMODE=AUTO + +#Where will logs go - needs to be writable by non-root users +LOGFILE=/tmp/tnc.log +TNC_SCRIPT="$(command -v tnc.sh)" + +#------------------------------------- +# Main functions of the script +#------------------------------------- + +#Status variables +SUCCESS=0 + +function GUI { + # In this case + # In my case, the Raspberry Pi is not connected to a monitor. + # I access it remotely using VNC as described here: + # http://learn.adafruit.com/adafruit-raspberry-pi-lesson-7-remote-control-with-vnc + # + # If VNC server is running, use its display number. + # Otherwise default to :0 (the Xwindows on the HDMI display) + # + export DISPLAY=":0" + + # Checking for RealVNC sessions (stock in Raspbian Pixel) + if [ -n "`ps -ef | grep vncserver-x11-serviced | grep -v grep`" ]; then + sleep 0.1 + echo -e "\nRealVNC found - defaults to connecting to the :0 root window" + elif [ -n "`ps -ef | grep Xtightvnc | grep -v grep`" ]; then + # Checking for TightVNC sessions + echo -e "\nTightVNC found - defaults to connecting to the :1 root window" + v=`ps -ef | grep Xtightvnc | grep -v grep` + d=`echo "$v" | sed 's/.*tightvnc *\(:[0-9]\).*/\1/'` + export DISPLAY="$d" + fi + + ##echo "Direwolf in GUI mode start up" + #echo "$(date): Direwolf in GUI mode start up" >> $LOGFILE + ##echo "DISPLAY=$DISPLAY" + #echo "$(date): DISPLAY=$DISPLAY" >> $LOGFILE + + # + # Auto adjust the startup for your particular environment: gnome-terminal, xterm, etc. + # + + if [ -x /usr/bin/lxterminal ]; then + /usr/bin/lxterminal -t "$1" --command="$1" & + SUCCESS=1 + elif [ -x /usr/bin/xterm ]; then + /usr/bin/xterm -bg white -fg black -e "$1" & + SUCCESS=1 + elif [ -x /usr/bin/x-terminal-emulator ]; then + /usr/bin/x-terminal-emulator -e "$1" & + SUCCESS=1 + else + echo "Did not find an X terminal emulator. Reverting to CLI mode" + SUCCESS=0 + fi + #echo "-----------------------" + #echo "$(date): -----------------------" >> $LOGFILE +} + +# ----------------------------------------------------------- +# Main Script start +# ----------------------------------------------------------- + +# When running from cron, we have a very minimal environment +# including PATH=/usr/bin:/bin. +# +export PATH=/usr/local/bin:$PATH + +# Check log file size. Delete it if it's too big +find /tmp -type f -name tnc.log -size +100k -delete + +#Log the start of the script run and re-run +#date >> $LOGFILE + +# First wait a little while in case we just rebooted +# and the desktop hasn't started up yet. +# +#sleep 30 + +SCREEN="$(which screen)" + +case "${1,,}" in + digi*|igate) + SCR="$($SCREEN -list | grep direwolf | tr -d ' \t' | cut -d'(' -f1 | tr -d '\n')" + if [[ $SCR != "" ]] + then + pgrep direwolf 2>&1 >/dev/null && exit 0 # Direwolf already running + fi + $TNC_SCRIPT stop 2>&1 >/dev/null + CMD="$TNC_SCRIPT start ${1,,}" + pkill -f "(terminal|x-term).*$TNC_SCRIPT" + if [ $RUNMODE == "AUTO" ] + then + GUI "$CMD" + if [ $SUCCESS -eq 0 ]; then + $CMD + fi + elif [ $RUNMODE == "GUI" ] + then + GUI "$CMD" + elif [ $RUNMODE == "CLI" ] + then + $CMD + else + echo -e "ERROR: illegal run mode given. Giving up" + exit 1 + fi + ;; + *) + ;; +esac +