Big rearrangement to add debconf support.
/etc/default/dump1090-mutability is now generated in postinst, if it doesn't exist, from a template in /usr/share/dump1090-mutability. Subsequently, the config file is updated in place if debconf-driven changes are made. Static HTML/javascript have moved to a "html" subdir to avoid exposing the template via the webserver.
This commit is contained in:
parent
c712543ee5
commit
125158b30a
9 changed files with 504 additions and 76 deletions
78
debian/dump1090-mutability.postinst
vendored
78
debian/dump1090-mutability.postinst
vendored
|
@ -17,10 +17,85 @@ set -e
|
|||
# for details, see http://www.debian.org/doc/debian-policy/ or
|
||||
# the debian-policy package
|
||||
|
||||
NAME=dump1090-mutability
|
||||
CONFIGFILE=/etc/default/$NAME
|
||||
TEMPLATECONFIG=/usr/share/$NAME/config-template
|
||||
SEDSCRIPT=$CONFIGFILE.sed.tmp
|
||||
|
||||
subvar_raw() {
|
||||
# $1 = db var value
|
||||
# $2 = config var name
|
||||
|
||||
# if not present in the config file, add it
|
||||
test -z "$1" || grep -Eq "^ *$2=" $CONFIGFILE || echo "$2=" >> $CONFIGFILE
|
||||
# add to the sedscript
|
||||
echo "s@^ *$2=.*@$2=\"$1\"@" >>$SEDSCRIPT
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
adduser --system --home /usr/share/dump1090-mutability --no-create-home --quiet dump1090
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
# Generate config file, if it doesn't exist.
|
||||
if [ ! -e $CONFIGFILE ]; then
|
||||
tail -n +4 $TEMPLATECONFIG >$CONFIGFILE
|
||||
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 rtlsdr-oversample OVERSAMPLE
|
||||
subvar_yn decode-fixcrc FIX_CRC
|
||||
subvar_yn decode-phase-enhance PHASE_ENHANCE
|
||||
subvar_yn decode-aggressive AGGRESSIVE
|
||||
subvar decode-lat LAT
|
||||
subvar decode-lon LON
|
||||
subvar net-http-port HTTP_PORT
|
||||
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-fatsv-port FATSV_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
|
||||
subvar extra-args EXTRA_ARGS
|
||||
|
||||
cp -a -f $CONFIGFILE $CONFIGFILE.tmp
|
||||
sed -f $SEDSCRIPT < $CONFIGFILE > $CONFIGFILE.tmp
|
||||
mv -f $CONFIGFILE.tmp $CONFIGFILE
|
||||
#rm $SEDSCRIPT
|
||||
|
||||
db_get $NAME/auto-start
|
||||
if [ "$RET" = "true" ]; then
|
||||
db_get $NAME/run-as-user
|
||||
adduser --system --home /usr/share/$NAME --no-create-home --quiet "$RET"
|
||||
fi
|
||||
;;
|
||||
|
||||
abort-upgrade|abort-remove|abort-deconfigure)
|
||||
|
@ -37,4 +112,5 @@ esac
|
|||
|
||||
#DEBHELPER#
|
||||
|
||||
if [ "$1" = "configure" ]; then db_stop; fi
|
||||
exit 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue