Package changes to support the aircraft DB.

This commit is contained in:
Oliver Jowett 2015-02-25 13:16:54 +00:00
parent 8209267301
commit 60eab2284f
11 changed files with 172 additions and 23 deletions

1
debian/control vendored
View file

@ -10,6 +10,7 @@ Vcs-Git: https://github.com/mutability/dump1090.git
Package: dump1090-mutability
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
Recommends: ${python:Depends}, cron | cron-daemon
Suggests: lighttpd
Provides: fatsv-data-source
Description: ADS-B Ground Station System for RTL-SDR

12
debian/cron-template vendored Normal file
View file

@ -0,0 +1,12 @@
## TEMPLATE FILE - This is used to create /etc/cron.d/dump1090-mutability ##
## The first three lines will be discarded ##
# Checks for updates to the VRS aircraft database once a day at around 5am;
# when an update is available, downloads it and regenerates the JSON data
# used by the webmap.
# NB: the minute value below is randomly generated on install, to avoid
# all installs hitting the server at the same time.
# m h dom mon dow user command
@MIN@ 5 * * * @USER@ test -x /usr/share/dump1090-mutability/update-aircraft-database.sh && /usr/share/dump1090-mutability/update-aircraft-database.sh --log-to-file

View file

@ -5,3 +5,4 @@
/usr/share/dump1090-mutability/html/style.css
/usr/share/dump1090-mutability/html/markers.js
/usr/share/dump1090-mutability/html/formatter.js
/usr/share/dump1090-mutability/html/dbloader.js

View file

@ -184,13 +184,11 @@ is_port_number() {
}
db_input high $NAME/auto-start || true
db_input_verify low $NAME/run-as-user is_non_root_user || true
db_input_verify low $NAME/log-file is_not_empty || true
db_go || true; db_get $NAME/auto-start; if [ "$RET" = "true" ]; then
# all of these are only relevant if the init script is enabled
db_input_verify low $NAME/run-as-user is_non_root_user || true
db_input_verify low $NAME/log-file is_not_empty || true
db_input medium $NAME/rtlsdr-device || true
db_go || true; db_get $NAME/rtlsdr-device; if [ "x$RET" != "xnone" ]; then

View file

@ -130,6 +130,11 @@ do_start()
fi
fi
# create logfile with the appropriate permissions if not already there
# (the cronjob running as DUMP1090_USER wants to append to it)
touch $LOGFILE
chown "$DUMP1090_USER":root $LOGFILE
start-stop-daemon --start $NICELEVEL --quiet --pidfile $PIDFILE --user "$DUMP1090_USER" --chuid "$DUMP1090_USER" --make-pidfile --background --no-close --exec $DAEMON -- \
$ARGS >>$LOGFILE 2>&1 \
|| return 2

View file

@ -1,3 +1,6 @@
public_html/* usr/share/dump1090-mutability/html
debian/lighttpd/* etc/lighttpd/conf-available
debian/config-template usr/share/dump1090-mutability
debian/cron-template usr/share/dump1090-mutability
tools/vrs-basicaircraft-to-json.py usr/share/dump1090-mutability
tools/update-aircraft-database.sh usr/share/dump1090-mutability

View file

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# postinst script for dump1090
#
# see: dh_installdeb(1)
@ -20,6 +20,8 @@ set -e
NAME=dump1090-mutability
CONFIGFILE=/etc/default/$NAME
TEMPLATECONFIG=/usr/share/$NAME/config-template
CRONFILE=/etc/cron.d/$NAME
TEMPLATECRON=/usr/share/$NAME/cron-template
SEDSCRIPT=$CONFIGFILE.sed.tmp
subvar_raw() {
@ -94,20 +96,35 @@ case "$1" in
mv -f $CONFIGFILE.tmp $CONFIGFILE
rm $SEDSCRIPT
db_get $NAME/auto-start
if [ "$RET" = "true" ]; then
db_get $NAME/run-as-user
if ! getent passwd "$RET" >/dev/null
then
adduser --system --home /usr/share/$NAME --no-create-home --quiet "$RET"
fi
db_get $NAME/run-as-user
RUNAS="$RET"
if ! getent passwd "$RUNAS" >/dev/null
then
adduser --system --home /usr/share/$NAME --no-create-home --quiet "$RUNAS"
fi
# -10 changed the lighttpd config file, but didn't arrange to restart it.
# If we are upgrading from -10 or earlier, and lighttpd is in use,
# restart it.
# create log if missing; change ownership if needed so the cronjob works
db_get $NAME/log-file
touch $RET
chown $RUNAS $RET
# create cronjob
if ! test -e $CRONFILE; then
echo "Creating cronjob in $CRONFILE to periodically update the aircraft database.." >&2
MIN=$(($RANDOM % 60))
tail -n +4 $TEMPLATECRON | sed -e "s/@USER@/$RUNAS/g" -e "s/@MIN@/$MIN/g" >$CRONFILE
fi
# update the DB
echo "Updating aircraft database now.."
mkdir -m 0755 -p /var/cache/$NAME
chown $RUNAS /var/cache/$NAME
su $RUNAS -s /bin/bash -c /usr/share/$NAME/update-aircraft-database.sh || \
echo "Aircraft database update failed. It will be retried periodically from cron." >&2
# config file changed between 1.14 and 1.15
if [ -e /etc/lighttpd/conf-enabled/89-dump1090.conf ]; then
if dpkg --compare-versions "$2" le "1.10.3010.14mu-10"; then
if dpkg --compare-versions "$2" le "1.14"; then
echo "Restarting lighttpd.." >&2
service lighttpd restart || echo "Warning: lighttpd failed to restart." >&2
fi

View file

@ -22,6 +22,8 @@ set -e
case "$1" in
purge)
rm -f /etc/default/dump1090-mutability
rm -f /etc/cron.d/dump1090-mutability
rm -rf /var/cache/dump1090-mutability
;;
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)

View file

@ -9,10 +9,11 @@ url.redirect += (
alias.url += (
"/dump1090/data/" => "/run/dump1090-mutability/",
"/dump1090/db/" => "/var/cache/dump1090-mutability/db/",
"/dump1090/" => "/usr/share/dump1090-mutability/html/"
)
# The stat cache must be disabled, as receiver.json changes
# rapidly and lighttpd's stat cache often ends up with the
# The stat cache must be disabled, as aircraft.json changes
# frequently and lighttpd's stat cache often ends up with the
# wrong content length.
server.stat-cache-engine = "disable"