2015-02-25 14:16:54 +01:00
|
|
|
#!/bin/bash
|
2014-12-05 23:37:33 +01:00
|
|
|
# postinst script for dump1090
|
|
|
|
#
|
|
|
|
# see: dh_installdeb(1)
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# summary of how this script can be called:
|
|
|
|
# * <postinst> `configure' <most-recently-configured-version>
|
|
|
|
# * <old-postinst> `abort-upgrade' <new version>
|
|
|
|
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
|
|
|
|
# <new-version>
|
|
|
|
# * <postinst> `abort-remove'
|
|
|
|
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
|
|
|
|
# <failed-install-package> <version> `removing'
|
|
|
|
# <conflicting-package> <version>
|
|
|
|
# for details, see http://www.debian.org/doc/debian-policy/ or
|
|
|
|
# the debian-policy package
|
|
|
|
|
2014-12-09 21:36:24 +01:00
|
|
|
NAME=dump1090-mutability
|
|
|
|
CONFIGFILE=/etc/default/$NAME
|
2016-01-25 16:16:41 +01:00
|
|
|
SRCCONFIGFILE=$CONFIGFILE
|
2014-12-09 21:36:24 +01:00
|
|
|
TEMPLATECONFIG=/usr/share/$NAME/config-template
|
2015-02-25 14:16:54 +01:00
|
|
|
CRONFILE=/etc/cron.d/$NAME
|
|
|
|
TEMPLATECRON=/usr/share/$NAME/cron-template
|
2014-12-09 21:36:24 +01:00
|
|
|
SEDSCRIPT=$CONFIGFILE.sed.tmp
|
|
|
|
|
|
|
|
subvar_raw() {
|
2016-01-25 16:16:41 +01:00
|
|
|
# $1 = config value
|
2014-12-09 21:36:24 +01:00
|
|
|
# $2 = config var name
|
|
|
|
|
2016-01-25 16:16:41 +01:00
|
|
|
if ! grep -Eq "^ *$2=" $SRCCONFIGFILE; then
|
|
|
|
# if not present in the config file, add it at the end
|
2016-01-25 16:22:53 +01:00
|
|
|
echo "\$a $2=$1" >> $SEDSCRIPT
|
2016-01-25 16:16:41 +01:00
|
|
|
else
|
|
|
|
# otherwise, replace the current value
|
|
|
|
echo "s@^ *$2=.*@$2=\"$1\"@" >>$SEDSCRIPT
|
|
|
|
fi
|
2014-12-09 21:36:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
subvar() {
|
|
|
|
# $1 = db var name
|
|
|
|
# $2 = config var name
|
|
|
|
db_get $NAME/$1
|
|
|
|
subvar_raw "$RET" "$2"
|
|
|
|
}
|
|
|
|
|
|
|
|
subvar_yn() {
|
|
|
|
# $1 = db var name
|
|
|
|
# $2 = config var name
|
|
|
|
db_get $NAME/$1
|
|
|
|
if [ "$RET" = "true" ]; then subvar_raw "yes" "$2"; else subvar_raw "no" "$2"; fi
|
|
|
|
}
|
2014-12-05 23:37:33 +01:00
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
configure)
|
2014-12-09 21:36:24 +01:00
|
|
|
. /usr/share/debconf/confmodule
|
|
|
|
|
2016-01-25 16:16:41 +01:00
|
|
|
# If we have no config file, start from the template.
|
|
|
|
# Avoid copying the template to the config file
|
|
|
|
# before substitution; this leaves an all-blank config
|
|
|
|
# in place if something fails, which causes problems
|
|
|
|
# on subsequent reconfiguration.
|
|
|
|
SKIPLINES=0
|
|
|
|
if [ ! -e $SRCCONFIGFILE ]; then
|
|
|
|
SRCCONFIGFILE=$TEMPLATECONFIG
|
|
|
|
SKIPLINES=4
|
2014-12-09 21:36:24 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
rm -f $SEDSCRIPT
|
|
|
|
|
|
|
|
subvar_yn auto-start START_DUMP1090
|
|
|
|
subvar run-as-user DUMP1090_USER
|
|
|
|
subvar log-file LOGFILE
|
|
|
|
subvar rtlsdr-device DEVICE
|
|
|
|
subvar rtlsdr-gain GAIN
|
|
|
|
subvar rtlsdr-ppm PPM
|
|
|
|
subvar_yn decode-fixcrc FIX_CRC
|
|
|
|
subvar decode-lat LAT
|
|
|
|
subvar decode-lon LON
|
2015-01-13 21:03:34 +01:00
|
|
|
subvar decode-max-range MAX_RANGE
|
2014-12-09 21:36:24 +01:00
|
|
|
subvar net-ri-port RAW_INPUT_PORT
|
|
|
|
subvar net-ro-port RAW_OUTPUT_PORT
|
|
|
|
subvar net-bi-port BEAST_INPUT_PORT
|
|
|
|
subvar net-bo-port BEAST_OUTPUT_PORT
|
|
|
|
subvar net-sbs-port SBS_OUTPUT_PORT
|
|
|
|
subvar net-heartbeat NET_HEARTBEAT
|
|
|
|
subvar net-out-size NET_OUTPUT_SIZE
|
|
|
|
subvar net-out-interval NET_OUTPUT_INTERVAL
|
|
|
|
subvar net-buffer NET_BUFFER
|
|
|
|
subvar net-bind-address NET_BIND_ADDRESS
|
|
|
|
subvar stats-interval STATS_INTERVAL
|
|
|
|
subvar json-dir JSON_DIR
|
|
|
|
subvar json-interval JSON_INTERVAL
|
2014-12-27 21:52:56 +01:00
|
|
|
subvar json-location-accuracy JSON_LOCATION_ACCURACY
|
2014-12-30 18:08:55 +01:00
|
|
|
subvar_yn log-decoded-messages LOG_DECODED_MESSAGES
|
2014-12-09 21:36:24 +01:00
|
|
|
subvar extra-args EXTRA_ARGS
|
|
|
|
|
2016-01-25 16:16:41 +01:00
|
|
|
tail -n +$SKIPLINES < $SRCCONFIGFILE | sed -f $SEDSCRIPT > $CONFIGFILE.tmp
|
|
|
|
if [ -e $CONFIGFILE ]; then
|
|
|
|
chown --reference=$CONFIGFILE $CONFIGFILE.tmp
|
|
|
|
chmod --reference=$CONFIGFILE $CONFIGFILE.tmp
|
|
|
|
fi
|
2014-12-09 21:36:24 +01:00
|
|
|
mv -f $CONFIGFILE.tmp $CONFIGFILE
|
2014-12-09 21:45:00 +01:00
|
|
|
rm $SEDSCRIPT
|
2014-12-09 21:36:24 +01:00
|
|
|
|
2015-02-25 14:16:54 +01:00
|
|
|
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"
|
2014-12-09 21:36:24 +01:00
|
|
|
fi
|
2015-01-14 01:34:06 +01:00
|
|
|
|
2015-02-25 14:16:54 +01:00
|
|
|
# create log if missing; change ownership if needed so the cronjob works
|
|
|
|
db_get $NAME/log-file
|
|
|
|
touch $RET
|
|
|
|
chown $RUNAS $RET
|
|
|
|
|
2016-07-10 13:00:46 +02:00
|
|
|
# enable lighttpd if needed
|
|
|
|
db_get $NAME/use-lighttpd
|
|
|
|
if [ "$RET" = "true" -a -x /usr/sbin/lighty-enable-mod ]
|
|
|
|
then
|
|
|
|
echo "Enabling lighttpd integration.." >&2
|
|
|
|
/usr/sbin/lighty-enable-mod dump1090 || true
|
|
|
|
fi
|
|
|
|
|
2016-02-16 11:33:18 +01:00
|
|
|
# this config file has changed a few times, restart lighttpd to make sure we
|
|
|
|
# have the latest version
|
2015-01-14 01:34:06 +01:00
|
|
|
if [ -e /etc/lighttpd/conf-enabled/89-dump1090.conf ]; then
|
2016-02-16 11:33:18 +01:00
|
|
|
echo "Restarting lighttpd.." >&2
|
|
|
|
invoke-rc.d lighttpd restart || echo "Warning: lighttpd failed to restart." >&2
|
2015-01-14 01:34:06 +01:00
|
|
|
fi
|
2014-12-05 23:37:33 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
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#
|
|
|
|
|
2014-12-09 21:36:24 +01:00
|
|
|
if [ "$1" = "configure" ]; then db_stop; fi
|
2014-12-05 23:37:33 +01:00
|
|
|
exit 0
|