|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Simplified, CLI-only direwolf start-up script |
| 4 | + |
| 5 | +# Run this from crontab periodically to check whether direwolf is running |
| 6 | +# and force it to start up automatically. |
| 7 | + |
| 8 | +# Versioning (this file, not direwolf version) |
| 9 | +#----------- |
| 10 | +# v1.4 - KE5WSG - removed support for the GUI and vastly simplified the script |
| 11 | +# v1.3 - KI6ZHD - added variable support for direwolf binary location |
| 12 | +# v1.2 - KI6ZHD - support different versions of VNC |
| 13 | +# v1.1 - KI6ZHD - expanded version to support running on text-only displays with |
| 14 | +# auto support; log placement change |
| 15 | +# v1.0 - WB2OSZ - original version for Xwindow displays only |
| 16 | + |
| 17 | +# Enable (true) / disable (false) logging everything to the log file. |
| 18 | +DEBUG=false |
| 19 | + |
| 20 | +#Where will be stored. The directory must be writable by non-root users. |
| 21 | +LOGFILE=/var/tmp/dw-start.log |
| 22 | + |
| 23 | +# Location of the direwolf binary. Depends on $PATH as shown. |
| 24 | +# Change this if you want to use some other specific location. |
| 25 | +# e.g. DWPATH="/usr/local/bin/direwolf" |
| 26 | + |
| 27 | +DWPATH="/home/pi/direwolf" |
| 28 | + |
| 29 | +# Location of the direwolf configuration file (direwolf.conf). |
| 30 | +# Change this if you want to customize or protect where your configuration |
| 31 | +# file is stored. |
| 32 | +# e.g. DWCONFIG="/home/pi/direwolf" |
| 33 | + |
| 34 | +DWCONFIG="/home/pi/direwolf" |
| 35 | + |
| 36 | +# Direwolf start up command. Examples for both a simple and SDR config are provided. |
| 37 | +# |
| 38 | +# 1. For normal operation as TNC, digipeater, IGate, etc. |
| 39 | +# Print audio statistics each 100 seconds for troubleshooting. |
| 40 | +# Change this command to however you wish to start Direwolf. |
| 41 | +# Be sure to use variables as necessary when building your command. |
| 42 | + |
| 43 | +DWCMD="$DWPATH/direwolf -a 100 -c $DWCONFIG/direwolf.conf" |
| 44 | + |
| 45 | +#--------------------------------------------------------------- |
| 46 | +# |
| 47 | +# 2. Alternative for running with SDR receiver. |
| 48 | +# Piping one application into another makes it a little more complicated. |
| 49 | +# We need to use bash for the | to be recognized. |
| 50 | + |
| 51 | +#DWCMD="bash -c 'rtl_fm -f 144.39M - | $DWPATH/direwolf -c $DWCONFIG/sdr.conf -r 24000 -D 1 -'" |
| 52 | + |
| 53 | +# When running from cron, we have a very minimal environment |
| 54 | +# including PATH=/usr/bin:/bin. |
| 55 | +export PATH=/usr/local/bin:$PATH |
| 56 | + |
| 57 | +# Error checking before attempting to start direwolf |
| 58 | + |
| 59 | +# Check to see whether screen is installed |
| 60 | +if ! type "screen" > /dev/null; then |
| 61 | + echo -e "ERROR: screen is not installed. Please install using 'sudo apt-get install screen' Aborting." |
| 62 | + echo "-----------------------" >> $LOGFILE |
| 63 | + date >> $LOGFILE |
| 64 | + echo "ERROR: screen is not installed." >> $LOGFILE |
| 65 | + exit 1 |
| 66 | +fi |
| 67 | + |
| 68 | +# Check to see if there's already a screen session named "direwolf" |
| 69 | +if screen -list | grep -q "direwolf"; then |
| 70 | + echo "A screen session named 'direwolf' is already running. Direwolf is likely already running. Exiting." |
| 71 | + if $DEBUG; then |
| 72 | + echo "-----------------------" >> $LOGFILE |
| 73 | + date >> $LOGFILE |
| 74 | + echo "A screen session named 'direwolf' was found. Exiting." >> $LOGFILE |
| 75 | + fi |
| 76 | + exit |
| 77 | +fi |
| 78 | + |
| 79 | +# It looks like we have everything we need to start direwolf, let's try! |
| 80 | + |
| 81 | +# Wait a little while in case we just rebooted and you're using an old RPi. |
| 82 | +# Feel free to adjust this delay as needed. |
| 83 | +sleep 1 |
| 84 | + |
| 85 | +# Print status messages |
| 86 | +echo "Direwolf starting up..." |
| 87 | +echo "-----------------------" >> $LOGFILE |
| 88 | +date >> $LOGFILE |
| 89 | +echo "Direwolf starting up..." >> $LOGFILE |
| 90 | + |
| 91 | +# Start direwolf in a screen session named 'direwolf' |
| 92 | +screen -S direwolf -d -m $DWCMD |
| 93 | + |
| 94 | +# Print direwolf screen information to the screen/log |
| 95 | +screen -list direwolf |
| 96 | +screen -list direwolf >> $LOGFILE |
| 97 | + |
| 98 | +echo "-----------------------" |
| 99 | +echo "-----------------------" >> $LOGFILE |
| 100 | + |
0 commit comments