Use a helper to start dump1090-fa so we can read ENABLED from the defaults file, like beast-splitter does

This commit is contained in:
Oliver Jowett 2019-03-11 17:01:16 +00:00
parent 0946d5165d
commit d66a05b019
4 changed files with 42 additions and 8 deletions

View file

@ -1,11 +1,14 @@
# dump1090-fa configuration
# This is read by the systemd service file as an environment file,
# and evaluated by some scripts as a POSIX shell fragment.
# This is sourced by /usr/share/dump1090-fa/start-dump1090-fa as a
# shellscript fragment.
# If you are using a PiAware sdcard image, this config file is regenerated
# on boot based on the contents of piaware-config.txt; any changes made to this
# file will be lost.
# dump1090-fa won't automatically start unless ENABLED=yes
ENABLED=yes
RECEIVER_OPTIONS="--device-index 0 --gain -10 --ppm 0 --net-bo-port 30005"
DECODER_OPTIONS="--max-range 360"
NET_OPTIONS="--net --net-heartbeat 60 --net-ro-size 1000 --net-ro-interval 1 --net-ri-port 0 --net-ro-port 30002 --net-sbs-port 30003 --net-bi-port 30004,30104 --net-bo-port 30005"

View file

@ -1,3 +1,4 @@
public_html/* usr/share/dump1090-fa/html
debian/lighttpd/* etc/lighttpd/conf-available
bladerf/* /usr/share/dump1090-fa/bladerf
bladerf/* usr/share/dump1090-fa/bladerf
debian/start-dump1090-fa usr/share/dump1090-fa/

View file

@ -7,17 +7,14 @@ Wants=network.target
After=network.target
[Service]
EnvironmentFile=/etc/default/dump1090-fa
EnvironmentFile=-/var/cache/piaware/location.env
User=dump1090
RuntimeDirectory=dump1090-fa
RuntimeDirectoryMode=0755
ExecStart=/usr/bin/dump1090-fa \
$RECEIVER_OPTIONS $DECODER_OPTIONS $NET_OPTIONS $JSON_OPTIONS $PIAWARE_DUMP1090_LOCATION_OPTIONS \
--write-json /run/dump1090-fa --quiet
ExecStart=/usr/share/dump1090-fa/start-dump1090-fa --write-json /run/dump1090-fa --quiet
Type=simple
Restart=on-failure
RestartSec=30
RestartPreventExitStatus=64
Nice=-5
[Install]

33
debian/start-dump1090-fa vendored Executable file
View file

@ -0,0 +1,33 @@
#!/bin/sh
# Helper script that reads /etc/default/dump1090-fa
# and either starts dump1090-fa with the configured
# arguments, or exits with status 64 to tell systemd
# not to auto-restart the service.
if [ -f /etc/default/dump1090-fa ]
then
. /etc/default/dump1090-fa
fi
if [ -f /var/cache/piaware/location.env ]
then
. /var/cache/piaware/location.env
fi
if [ "x$ENABLED" != "xyes" ]
then
echo "dump1090-fa not enabled in /etc/default/dump1090-fa" >&2
exit 64
fi
if [ -n "$LAT" -a -n "$LON" ]
then
POSITION="--lat $LAT --lon $LON"
fi
exec /usr/bin/dump1090-fa \
$RECEIVER_OPTIONS $DECODER_OPTIONS $NET_OPTIONS $JSON_OPTIONS $POSITION \
"$@"
# exec failed, do not restart
exit 64