initscripts for 360Radar’s ADS-B uploader

360Radar.co.uk is a browser-based ADS-B and MLAT aircraft tracking system.

I knocked together an initscript for Linux users which should work with most Debian-based Linux distros (inc. Raspbian on the Raspberry Pi).

This assumes you are running as a user with root-level permissions (if not, sudo is your friend), a level of familiarity with the Linux command line, permissions, etc.

Install mono

Follow the Install Mono instructions in the official 360Radar installation instructions:

http://radar.lowflyingwales.co.uk/360radar-adsb-uploader-instructions-raspberry-pi/

Create a new user to run the ADS-B uploader

Rather than run the uploader as an existing user (e.g. pi), we’ll create a new user to run it away from our normal login user.

I’m creating a new user called (rather unimaginatively) adsbfilter, with a home directory of /opt/adsbfilter.

useradd -m -g nogroup -d /opt/adsbfilter adsbfilter

Change to the new user and download the uploader

su - adsbfilter

Now we’re in the new user environment, we need to download the uploader. Back to the official installation instructions:

wget http://radar.lowflyingwales.co.uk/files/adsb/rpi/AdsbFilter-1.0.17.tgz

Extract the compressed tarball you download:

tar xzf AdsbFilter-1.0.17.tgz

This’ll create a new directory AdsbFilter containing the ADS-B uploader.

Create a wrapper script

We’ll use a wrapper script to restart the ADS-B uploader unless it’s stopped cleanly and deliberately. This will automatically restart it in the event of a segfault, which seems to happen from time to time with the nightly mono builds.

Create adsbfilter.sh in /opt/adsbfilter/AdsbFilter (or modify with your chosen path):

nano -w /opt/adsbfilter/AdsbFilter/adsbfilter.sh

Set the executable bit on the wrapper and the program itself:

cd /opt/adsbfilter/AdsbFilter

chmod +x adsbfilter.sh AdsbFilter.exe

Now come out of our adsbfilter user environment:

exit

Create the initscript

We’ll create a standard Debian initscript in /etc/init.d/adsbfilter:

If you decided to use a different username or path, change the following line accordingly:

DAEMON=/opt/adsbfilter/AdsbFilter/adsbfilter.sh

Make it executable:

chmod +x /etc/init.d/adsbfilter

Create the settings file

Create the following in /etc/default/adsbfilter:

Modify the various parameters as required. At the very least, you’ll need latitude, longitude and email.

Finalising the install

We now need to tell the system about the new script:

systemctl daemon-reload

And add it to the autostart runlevels:

update-rc.d adsbfilter defaults

And finally, start it manually for the first time:

service adsbfilter start

Check to make sure things started properly by viewing /var/log/adsbfilter.log

Optional: add a logrotate snippet

The ADS-B uploader logs its activity every second, so the adsbfilter.log file can quickly become large. We can use logrotate to trim it periodically and archive off a few days of historical data.

Create /etc/logrotate.d/adsbfilter:

And that’s it!

About Chris

IT Consultant, Network Engineer, Photographer, Audiophile.