From 19eed4cf18b2007e5ec6b5d09a4944e940c24864 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Fri, 5 Dec 2014 19:33:46 +0000 Subject: [PATCH 01/14] Allow external specification of CFLAGS / CPPFLAGS. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6bfe9ee..61ab749 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ SHAREDIR=$(PREFIX)/share/$(PROGNAME) EXTRACFLAGS=-DHTMLPATH=\"$(SHAREDIR)\" endif -CFLAGS=-O2 -g -Wall -W `pkg-config --cflags librtlsdr` +CFLAGS+=-O2 -g -Wall -W `pkg-config --cflags librtlsdr` LIBS=`pkg-config --libs librtlsdr` -lpthread -lm CC=gcc @@ -18,7 +18,7 @@ CC=gcc all: dump1090 view1090 %.o: %.c - $(CC) $(CFLAGS) $(EXTRACFLAGS) -c $< + $(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRACFLAGS) -c $< dump1090: dump1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o $(CC) -g -o dump1090 dump1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o $(LIBS) $(LDFLAGS) From 83c80b6d672da952e1da60a6813402b318e62956 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Fri, 5 Dec 2014 19:34:40 +0000 Subject: [PATCH 02/14] Don't link view1090 with librtlsdr, it doesn't need it. --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 61ab749..dd73487 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,8 @@ EXTRACFLAGS=-DHTMLPATH=\"$(SHAREDIR)\" endif CFLAGS+=-O2 -g -Wall -W `pkg-config --cflags librtlsdr` -LIBS=`pkg-config --libs librtlsdr` -lpthread -lm +LIBS=-lpthread -lm +LIBS_RTL=`pkg-config --libs librtlsdr` CC=gcc @@ -21,7 +22,7 @@ all: dump1090 view1090 $(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRACFLAGS) -c $< dump1090: dump1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o - $(CC) -g -o dump1090 dump1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o $(LIBS) $(LDFLAGS) + $(CC) -g -o dump1090 dump1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o $(LIBS) $(LIBS_RTL) $(LDFLAGS) view1090: view1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o $(CC) -g -o view1090 view1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o $(LIBS) $(LDFLAGS) From 0ae1d72e83afcd099494c34c24848e9e56a2bb1f Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Fri, 5 Dec 2014 20:18:57 +0000 Subject: [PATCH 03/14] Initial work on raspbian packaging. --- debian/changelog | 5 +++++ debian/compat | 1 + debian/control | 20 ++++++++++++++++++++ debian/copyright | 37 +++++++++++++++++++++++++++++++++++++ debian/dump1090-mr.install | 3 +++ debian/rules | 18 ++++++++++++++++++ debian/source/format | 1 + 7 files changed, 85 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/dump1090-mr.install create mode 100755 debian/rules create mode 100644 debian/source/format diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..f18cab6 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +dump1090-mr (1.08.2302.14+1-1) UNRELEASED; urgency=medium + + * Initial package release. + + -- Oliver Jowett Fri, 05 Dec 2014 20:12:40 +0000 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +8 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..012b733 --- /dev/null +++ b/debian/control @@ -0,0 +1,20 @@ +Source: dump1090-mr +Section: embedded +Priority: extra +Maintainer: Oliver Jowett +Build-Depends: debhelper(>=8), net-tools, librtlsdr-dev +Standards-Version: 3.9.3 +Homepage: https://github.com/MalcolmRobb/dump1090 +Vcs-Git: https://github.com/mutability/dump1090.git -b mr-pi-package + +Package: dump1090-mr +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, net-tools, adduser +Description: ADS-B Ground Station System for RTL-SDR + Networked Aviation Mode S / ADS-B decoder/translator with RTL-SDR software + defined radio USB device support. + . + Includes a mini-webserver that you can access to see aircraft in the vicinity + of your receiver. + . + This is a packaging of MalcomRobb's fork of the original dump1090 version. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..ce72a3f --- /dev/null +++ b/debian/copyright @@ -0,0 +1,37 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: dump1090 +Upstream-Contact: https://github.com/MalcolmRobb +Source: https://github.com/MalcolmRobb/dump1090 + +Files: * +Copyright: Salvatore Sanfilippo, Malcom Robb and other contributors. +License: BSD-3-Clause + +Files: debian/* +Copyright: 2014 Oliver Jowett +License: BSD-3-Clause + +License: BSD-3-Clause + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE HOLDERS OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/debian/dump1090-mr.install b/debian/dump1090-mr.install new file mode 100644 index 0000000..a851311 --- /dev/null +++ b/debian/dump1090-mr.install @@ -0,0 +1,3 @@ +dump1090 usr/bin +view1090 usr/bin +public_html/* usr/share/dump1090 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..9430a63 --- /dev/null +++ b/debian/rules @@ -0,0 +1,18 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +export DH_VERBOSE=1 + +export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +DPKG_EXPORT_BUILDFLAGS = 1 +include /usr/share/dpkg/buildflags.mk + +%: + dh $@ diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) From 35a382e3ce50e91781cc9ae75b2481c2c8ff1b9b Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Fri, 5 Dec 2014 21:36:02 +0000 Subject: [PATCH 04/14] Set HTMLPATH correctly when compiling. Put static files in /usr/share/dump1090-mr not /usr/share/dump1090 --- debian/dump1090-mr.install | 2 +- debian/rules | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/dump1090-mr.install b/debian/dump1090-mr.install index a851311..6ca26a8 100644 --- a/debian/dump1090-mr.install +++ b/debian/dump1090-mr.install @@ -1,3 +1,3 @@ dump1090 usr/bin view1090 usr/bin -public_html/* usr/share/dump1090 +public_html/* usr/share/dump1090-mr diff --git a/debian/rules b/debian/rules index 9430a63..251ca29 100755 --- a/debian/rules +++ b/debian/rules @@ -14,5 +14,7 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all DPKG_EXPORT_BUILDFLAGS = 1 include /usr/share/dpkg/buildflags.mk +override_dh_auto_build: + dh_auto_build -- 'EXTRACFLAGS=-DHTMLPATH=\"/usr/share/dump1090-mr\"' %: dh $@ From 77912fb0879da85a245ebb0589a9497ac5e5b622 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Fri, 5 Dec 2014 21:36:51 +0000 Subject: [PATCH 05/14] Install binaries with -mr suffix. --- debian/dump1090-mr.install | 2 -- debian/rules | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/debian/dump1090-mr.install b/debian/dump1090-mr.install index 6ca26a8..8feea8a 100644 --- a/debian/dump1090-mr.install +++ b/debian/dump1090-mr.install @@ -1,3 +1 @@ -dump1090 usr/bin -view1090 usr/bin public_html/* usr/share/dump1090-mr diff --git a/debian/rules b/debian/rules index 251ca29..38f129b 100755 --- a/debian/rules +++ b/debian/rules @@ -16,5 +16,12 @@ include /usr/share/dpkg/buildflags.mk override_dh_auto_build: dh_auto_build -- 'EXTRACFLAGS=-DHTMLPATH=\"/usr/share/dump1090-mr\"' + +override_dh_install: + dh_install + install -d debian/dump1090-mr/usr/bin + cp -a dump1090 debian/dump1090-mr/usr/bin/dump1090-mr + cp -a view1090 debian/dump1090-mr/usr/bin/view1090-mr + %: dh $@ From 373ac8ef0cccd51249aec2961ff70cb47b245ad1 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Fri, 5 Dec 2014 22:37:33 +0000 Subject: [PATCH 06/14] Add init script, defaults from /etc/default/, postinst to create a user to run as. --- debian/dump1090-mr.default | 89 +++++++++++++++++ debian/dump1090-mr.init | 185 ++++++++++++++++++++++++++++++++++++ debian/dump1090-mr.postinst | 40 ++++++++ 3 files changed, 314 insertions(+) create mode 100644 debian/dump1090-mr.default create mode 100644 debian/dump1090-mr.init create mode 100644 debian/dump1090-mr.postinst diff --git a/debian/dump1090-mr.default b/debian/dump1090-mr.default new file mode 100644 index 0000000..8a96f0a --- /dev/null +++ b/debian/dump1090-mr.default @@ -0,0 +1,89 @@ +# Defaults for dump1090-mr +# This is a POSIX shell fragment + +# Set to "yes" to start dump1090 on boot. +START_DUMP1090="no" + +# User to run dump1090 as. +DUMP1090_USER="dump1090" + +# +# The following options are all optional - defaults if not provided are +# shown below. +# + +# +# Receiver options +# + +# RTLSDR device index to use +# If set to "none", dump1090 will be started in --net-only mode +#DEVICE=0 + +# RTLSDR gain in dB. +# If set to "max" (the default) the maximum supported gain is used. +# If set to "agc", the tuner AGC is used to set the gain. +#GAIN=max + +# RTLSDR frequency correction in PPM +#PPM=0 + +# +# Decoding options +# + +# If yes, fixes messages with correctable CRC errors. +# Otherwise, discards messages with errors. +#FIX_CRC=no + +# If yes, enables phase-enhancement of messages that fail to decode +# the first time around. +#PHASE_ENHANCE=no + +# If yes, enables aggressive fixes to damaged messages. +# Use with caution - it can increase the rate of undetected errors. +#AGGRESSIVE=no + +# If set, supplies a reference location for local position decoding. +#LAT=decimal.latitude.value +#LON=decimal.longitude.value + +# +# Networking options +# + +# Port to listen on for HTTP connections. 0 disables. +#HTTP_PORT=8080 + +# Port to listen on for raw (AVR-format) input connections. 0 disables. +#RAW_INPUT_PORT=30001 + +# Port to listen on for raw (AVR-format) output connections. 0 disables. +#RAW_OUTPUT_PORT=30002 + +# Port to listen on for SBS-format output connections. 0 disables. +#SBS_OUTPUT_PORT=30003 + +# Port to listen on for Beast-format input connections. 0 disables. +#BEAST_INPUT_PORT=30004 + +# Port to listen on for Beast-format output connections. 0 disables. +#BEAST_OUTPUT_PORT=30005 + +# TCP heartbeat interval in seconds. 0 disables. +#NET_HEARTBEAT=60 + +# Minimum output buffer size per write, in bytes. +#NET_OUTPUT_SIZE=5 + +# Maximum buffering time before writing. In units of approx 64ms (don't ask..). +#NET_OUTPUT_RATE=5 + +# TCP buffer size order. Power-of-two based - buffer size is 2^(n+16). +#NET_BUFFER=0 + +# Bind ports on a particular address. If unset, binds to all interfaces. +#BIND_ADDRESS= + +# Additional options that are passed to the Daemon. +#EXTRA_ARGS="" diff --git a/debian/dump1090-mr.init b/debian/dump1090-mr.init new file mode 100644 index 0000000..bf526b3 --- /dev/null +++ b/debian/dump1090-mr.init @@ -0,0 +1,185 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: dump1090-mr +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: dump1090 daemon (MalcolmRobb variant) +# Description: Receives ADS-B messages from a RTLSDR dongle +# and makes them available to other applications via +# a variety of network protocols. +### END INIT INFO + +# Do NOT "set -e" + +# PATH should only include /usr/* if it runs after the mountnfs.sh script +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="dump1090-mr daemon" +NAME=dump1090-mr +DAEMON=/usr/bin/$NAME +ARGS="--quiet" +PIDFILE=/var/run/$NAME.pid +SCRIPTNAME=/etc/init.d/$NAME + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Set defaults: +START_DUMP1090=no +DUMP1090_USER=dump1090 +DEVICE=0 +GAIN=max +PPM=0 +FIX_CRC=no +PHASE_ENHANCE=no +AGGRESSIVE=no +LAT= +LON= +HTTP_PORT=8080 +RAW_INPUT_PORT=30001 +RAW_OUTPUT_PORT=30002 +SBS_OUTPUT_PORT=30003 +BEAST_INPUT_PORT=30004 +BEAST_OUTPUT_PORT=30005 +NET_HEARTBEAT=60 +NET_OUTPUT_SIZE=5 +NET_OUTPUT_RATE=5 +NET_BUFFER=0 +BIND_ADDRESS= +EXTRA_ARGS= + +# Read configuration variable file if it is present +[ -r /etc/default/$NAME ] && . /etc/default/$NAME + +# work out daemon args + +# receiver: +case "x$DEVICE" in + x|x0) ARGS="$ARGS --net" ;; + xnone) ARGS="$ARGS --net-only" ;; + *) ARGS="$ARGS --net --device-index $DEVICE" ;; +esac +case "x$GAIN" in + x|xmax) ;; + xagc) ARGS="$ARGS --gain -10" ;; + *) ARGS="$ARGS --gain $GAIN" ;; +esac +if [ "x$PPM" != "x0" ]; then ARGS="$ARGS --ppm $PPM"; fi + +# decoder: +if [ "x$FIX_CRC" = "xyes" ]; then ARGS="$ARGS --fix"; fi +if [ "x$PHASE_ENHANCE" = "xyes" ]; then ARGS="$ARGS --phase-enhance"; fi +if [ "x$AGGRESSIVE" = "xyes" ]; then ARGS="$ARGS --aggressive"; fi +if [ -n "$LAT" ]; then ARGS="$ARGS --lat $LAT"; fi +if [ -n "$LON" ]; then ARGS="$ARGS --lon $LON"; fi + +# net: +if [ "x$HTTP_PORT" != "x8080" ]; then ARGS="$ARGS --net-http-port $HTTP_PORT"; fi +if [ "x$RAW_INPUT_PORT" != "x30001" ]; then ARGS="$ARGS --net-ri-port $RAW_INPUT_PORT"; fi +if [ "x$RAW_OUTPUT_PORT" != "x30002" ]; then ARGS="$ARGS --net-ro-port $RAW_OUTPUT_PORT"; fi +if [ "x$SBS_OUTPUT_PORT" != "x30003" ]; then ARGS="$ARGS --net-sbs-port $SBS_OUTPUT_PORT"; fi +if [ "x$BEAST_INPUT_PORT" != "x30004" ]; then ARGS="$ARGS --net-bi-port $BEAST_INPUT_PORT"; fi +if [ "x$BEAST_OUTPUT_PORT" != "x30005" ]; then ARGS="$ARGS --net-bo-port $BEAST_OUTPUT_PORT"; fi +if [ "x$NET_HEARTBEAT" != "x60" ]; then ARGS="$ARGS --net-heartbeat $NET_HEARTBEAT"; fi +if [ "x$NET_OUTPUT_SIZE" != "x0" ]; then ARGS="$ARGS --net-ro-size $NET_OUTPUT_SIZE"; fi +if [ "x$NET_OUTPUT_RATE" != "x0" ]; then ARGS="$ARGS --net-ro-rate $NET_OUTPUT_RATE"; fi +if [ "x$NET_BUFFER" != "x0" ]; then ARGS="$ARGS --net-buffer $NET_BUFFER"; fi +if [ -n "$BIND_ADDRESS" ]; then ARGS="$ARGS --net-bind-address $BIND_ADDRESS"; fi +if [ -n "$EXTRA_ARGS" ]; then ARGS="$ARGS $EXTRA_ARGS"; fi + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.2-14) to ensure that this file is present +# and status_of_proc is working. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + + if [ "x$START_DUMP1090" != "xyes" ]; then + log_warning_msg "Not starting $NAME daemon, disabled via /etc/default/$NAME" + return 0 + fi + + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ + || return 1 + start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $DUMP1090_USER --make-pidfile --background --exec $DAEMON -- \ + $ARGS \ + || return 2 + sleep 1 +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + start-stop-daemon --stop --retry=TERM/30/KILL/5 --pidfile $PIDFILE --user $DUMP1090_USER --name $NAME + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 + sleep 1 + # Many daemons don't delete their pidfiles when they exit. + rm -f $PIDFILE + return "$RETVAL" +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC:" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC:" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + restart|force-reload) + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/debian/dump1090-mr.postinst b/debian/dump1090-mr.postinst new file mode 100644 index 0000000..e727c02 --- /dev/null +++ b/debian/dump1090-mr.postinst @@ -0,0 +1,40 @@ +#!/bin/sh +# postinst script for dump1090 +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + adduser --system --home /usr/share/dump1090-mr --no-create-home --quiet dump1090 + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 From b1e1878054e8d5172268750f7731b88513e45b62 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Fri, 5 Dec 2014 22:55:04 +0000 Subject: [PATCH 07/14] Fix some stray colons. Report failure if daemon isn't configured to start. --- debian/dump1090-mr.init | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debian/dump1090-mr.init b/debian/dump1090-mr.init index bf526b3..514068f 100644 --- a/debian/dump1090-mr.init +++ b/debian/dump1090-mr.init @@ -108,7 +108,7 @@ do_start() if [ "x$START_DUMP1090" != "xyes" ]; then log_warning_msg "Not starting $NAME daemon, disabled via /etc/default/$NAME" - return 0 + return 2 fi start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ @@ -140,7 +140,7 @@ do_stop() case "$1" in start) - [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC:" "$NAME" + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" do_start case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; @@ -148,7 +148,7 @@ case "$1" in esac ;; stop) - [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC:" "$NAME" + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" do_stop case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; From b7ee4009e4ddeb942423a6c61a34d94788736732 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Fri, 5 Dec 2014 22:56:14 +0000 Subject: [PATCH 08/14] Release changelog. --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index f18cab6..3f500a0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,5 @@ -dump1090-mr (1.08.2302.14+1-1) UNRELEASED; urgency=medium +dump1090-mr (1.08.2302.14+1-1) unstable; urgency=medium * Initial package release. - -- Oliver Jowett Fri, 05 Dec 2014 20:12:40 +0000 + -- Oliver Jowett Fri, 05 Dec 2014 22:55:41 +0000 From 7a3a9f500f0af8525a733afebeaddb9c2ce07eff Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Sat, 6 Dec 2014 16:06:39 +0000 Subject: [PATCH 09/14] Add logging support. --- debian/dump1090-mr.default | 3 +++ debian/dump1090-mr.init | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/debian/dump1090-mr.default b/debian/dump1090-mr.default index 8a96f0a..f5e40a8 100644 --- a/debian/dump1090-mr.default +++ b/debian/dump1090-mr.default @@ -7,6 +7,9 @@ START_DUMP1090="no" # User to run dump1090 as. DUMP1090_USER="dump1090" +# Logfile to log to +#LOGFILE="/var/log/dump1090-mr.log" + # # The following options are all optional - defaults if not provided are # shown below. diff --git a/debian/dump1090-mr.init b/debian/dump1090-mr.init index 514068f..cf03a31 100644 --- a/debian/dump1090-mr.init +++ b/debian/dump1090-mr.init @@ -28,6 +28,7 @@ SCRIPTNAME=/etc/init.d/$NAME # Set defaults: START_DUMP1090=no DUMP1090_USER=dump1090 +LOGFILE=/var/log/$NAME.log DEVICE=0 GAIN=max PPM=0 @@ -113,8 +114,8 @@ do_start() start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ || return 1 - start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $DUMP1090_USER --make-pidfile --background --exec $DAEMON -- \ - $ARGS \ + start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $DUMP1090_USER --make-pidfile --background --no-close --exec $DAEMON -- \ + $ARGS >>$LOGFILE 2>&1 \ || return 2 sleep 1 } From 2e189633dabb2333c1437dedf198960080323519 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Sat, 6 Dec 2014 16:07:02 +0000 Subject: [PATCH 10/14] Add a logrotate configuration. --- debian/dump1090-mr.logrotate | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 debian/dump1090-mr.logrotate diff --git a/debian/dump1090-mr.logrotate b/debian/dump1090-mr.logrotate new file mode 100644 index 0000000..f421184 --- /dev/null +++ b/debian/dump1090-mr.logrotate @@ -0,0 +1,5 @@ +/var/log/dump1090-mr.log { + weekly + rotate 4 + copytruncate +} From 977fc07c393a742fa0fc2abe920e2a3c703aee15 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Sat, 6 Dec 2014 16:07:44 +0000 Subject: [PATCH 11/14] Pass --name and --user during daemon start so that existing processes can be correctly identified. --- debian/dump1090-mr.init | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/dump1090-mr.init b/debian/dump1090-mr.init index cf03a31..96f0ae4 100644 --- a/debian/dump1090-mr.init +++ b/debian/dump1090-mr.init @@ -112,9 +112,9 @@ do_start() return 2 fi - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ + start-stop-daemon --start --quiet --pidfile $PIDFILE --name $NAME --user $DUMP1090_USER --exec $DAEMON --test > /dev/null \ || return 1 - start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $DUMP1090_USER --make-pidfile --background --no-close --exec $DAEMON -- \ + start-stop-daemon --start --quiet --pidfile $PIDFILE --name $NAME --user $DUMP1090_USER --chuid $DUMP1090_USER --make-pidfile --background --no-close --exec $DAEMON -- \ $ARGS >>$LOGFILE 2>&1 \ || return 2 sleep 1 From 3242fcaf29ca591f9c8f135305386ae048c24515 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Sat, 6 Dec 2014 16:08:17 +0000 Subject: [PATCH 12/14] Add support for configuring --stats-every (defaults to hourly) --- debian/dump1090-mr.default | 7 +++++++ debian/dump1090-mr.init | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/debian/dump1090-mr.default b/debian/dump1090-mr.default index f5e40a8..c5a4cce 100644 --- a/debian/dump1090-mr.default +++ b/debian/dump1090-mr.default @@ -88,5 +88,12 @@ DUMP1090_USER="dump1090" # Bind ports on a particular address. If unset, binds to all interfaces. #BIND_ADDRESS= +# +# Misc options +# + +# Interval (in seconds) between logging stats to the logfile. 0 disables. +#STATS_INTERVAL=3600 + # Additional options that are passed to the Daemon. #EXTRA_ARGS="" diff --git a/debian/dump1090-mr.init b/debian/dump1090-mr.init index 96f0ae4..77e70fc 100644 --- a/debian/dump1090-mr.init +++ b/debian/dump1090-mr.init @@ -48,6 +48,7 @@ NET_OUTPUT_SIZE=5 NET_OUTPUT_RATE=5 NET_BUFFER=0 BIND_ADDRESS= +STATS_INTERVAL=3600 EXTRA_ARGS= # Read configuration variable file if it is present @@ -87,6 +88,9 @@ if [ "x$NET_OUTPUT_SIZE" != "x0" ]; then ARGS="$ARGS --net-ro-size $NET_OUTPUT_S if [ "x$NET_OUTPUT_RATE" != "x0" ]; then ARGS="$ARGS --net-ro-rate $NET_OUTPUT_RATE"; fi if [ "x$NET_BUFFER" != "x0" ]; then ARGS="$ARGS --net-buffer $NET_BUFFER"; fi if [ -n "$BIND_ADDRESS" ]; then ARGS="$ARGS --net-bind-address $BIND_ADDRESS"; fi + +# misc: +if [ "x$STATS_INTERVAL" != "x0" ]; then ARGS="$ARGS --stats-every $STATS_INTERVAL"; fi if [ -n "$EXTRA_ARGS" ]; then ARGS="$ARGS $EXTRA_ARGS"; fi # Load the VERBOSE setting and other rcS variables From 786dd622ee07e3e2cac984afbdfce732c06e181f Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Sat, 6 Dec 2014 16:08:42 +0000 Subject: [PATCH 13/14] Update changelog for recent changes. --- debian/changelog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/debian/changelog b/debian/changelog index 3f500a0..75a8e6b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +dump1090-mr (1.08.2302.14+1-2) UNRELEASED; urgency=medium + + * Pass --name / --user to start-stop-daemon when starting + * Log to /var/log/dump1090-mr.log (configurable via LOGFILE) + * Log stats once an hour by default (configurable via STATS_INTERVAL) + * Include a logrotate configuration + + -- Oliver Jowett Sat, 06 Dec 2014 15:36:58 +0000 + dump1090-mr (1.08.2302.14+1-1) unstable; urgency=medium * Initial package release. From d88c9d6ab3d6faaa3fdce27a2009135969832193 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Sat, 6 Dec 2014 18:37:36 +0000 Subject: [PATCH 14/14] Release changelog. --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 75a8e6b..3e071ad 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,11 +1,11 @@ -dump1090-mr (1.08.2302.14+1-2) UNRELEASED; urgency=medium +dump1090-mr (1.08.2302.14+1-2) unstable; urgency=medium * Pass --name / --user to start-stop-daemon when starting * Log to /var/log/dump1090-mr.log (configurable via LOGFILE) * Log stats once an hour by default (configurable via STATS_INTERVAL) * Include a logrotate configuration - -- Oliver Jowett Sat, 06 Dec 2014 15:36:58 +0000 + -- Oliver Jowett Sat, 06 Dec 2014 18:37:12 +0000 dump1090-mr (1.08.2302.14+1-1) unstable; urgency=medium