Direwolf has made it pretty easy to get an APRS digipeater or igate running. Unfortunately the default is that you have to login to the server and remain logged in for it to run. That didn’t work for me so I set about to make things work the way I wanted.

The first thing I did was create a script that starts direwolf and points it to the proper configuration file. It also sets up the output with time and date stamp for troubleshooting. I named the script dw and put it in my personal bin directory.


# Start direwolf and point it to the configuration file of our choice.
# We also time and date stamp the output for troubleshooting.

/usr/local/bin/direwolf -c /etc/direwolf/direwolf.conf -T '%F %T' 

Next I created a script that checks to see if direwolf is running. If it is not then it starts direwolf using the script above. This script I call dwtest and it too is in my personal bin directory.


# Tests to see if Direwolf is alive.

# Run the pgrep command with the -c switch
# to give the count of the number of instances
# of direwolf that are running.  Store that value
# in the $runstatus variable.
runstatus=$(/usr/bin/pgrep -c direwolf)

# Measure the $runstatus variable.  If the variable is 
# zero then we need to start direwolf.  If the variable
# indicates that one or more instances of direwolf are
# already running then we don't need to do anything.
if [ $runstatus = 0 ]; then
        # Run out direwolf start script but redirect
        # the output to the bit bucket because there
        # won't be anyone here to read it.
        /home/repeater/bin/dw > /dev/null 2>&1 &        

Then I simply put an entry in the user cron to run this thing every minute. I might tame that a bit later but I don’t see that it hurts to run it so often as there isn’t a lot of demand on this particular server. Here is the output of crontab -l showing how it’s currently setup.

# Edit this file to introduce tasks to be run by cron.
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# For more information see the manual pages of crontab(5) and cron(8)
# m h  dom mon dow   command

# Checks direwolf status ever 5 minutes and starts if necessary.
* * * * * /home/repeater/bin/dwtest

As with anything in Linux, there are many ways to accomplish a goal. This is how I decided to do it. If you see flaws, please let me know. And I would enjoy knowing how you do it as well.