Add CONFIG_STYLE to default config for unambiguous detection of
new-style config. Try to handle un-upgraded config files in start-dump1090-fa. Always pass --quiet to dump1090-fa.
This commit is contained in:
parent
d6405ddefd
commit
899ee2530c
|
|
@ -57,3 +57,6 @@ EXTRA_OPTIONS=""
|
|||
# If OVERRIDE_OPTIONS is set, only those options are used; all other options
|
||||
# in this config file are ignored.
|
||||
OVERRIDE_OPTIONS=""
|
||||
|
||||
# This is a marker to make it easier for scripts to identify a v6-style config file
|
||||
CONFIG_STYLE=6
|
||||
|
|
|
|||
|
|
@ -23,6 +23,17 @@ fi
|
|||
|
||||
# process options
|
||||
|
||||
# if there's no CONFIG_STYLE, infer a version
|
||||
if [ -z "$CONFIG_STYLE" ]
|
||||
then
|
||||
if [ -n "$RECEIVER_OPTIONS" -o -n "$DECODER_OPTIONS" -o -n "$NET_OPTIONS" -o -n "$JSON_OPTIONS" ]
|
||||
then
|
||||
CONFIG_STYLE=5
|
||||
else
|
||||
CONFIG_STYLE=6
|
||||
fi
|
||||
fi
|
||||
|
||||
is_slow_cpu() {
|
||||
case "$SLOW_CPU" in
|
||||
yes) return 0 ;;
|
||||
|
|
@ -36,51 +47,61 @@ is_slow_cpu() {
|
|||
esac
|
||||
}
|
||||
|
||||
OPTS="--quiet"
|
||||
|
||||
if [ "${RECEIVER:-none}" = "none" ]
|
||||
if [ "$CONFIG_STYLE" = "5" ]
|
||||
then
|
||||
OPTS="$OPTS --device-type none"
|
||||
# old style config file
|
||||
echo "/etc/default/dump1090-fa is using the old config style, please consider updating it" >&2
|
||||
OPTS="$RECEIVER_OPTIONS $DECODER_OPTIONS $NET_OPTIONS $JSON_OPTIONS"
|
||||
elif [ -n "$OVERRIDE_OPTIONS" ]
|
||||
then
|
||||
# ignore all other settings, use only provided options
|
||||
OPTS="$OVERRIDE_OPTIONS"
|
||||
else
|
||||
if [ -n "$RECEIVER" ]; then OPTS="$OPTS --device-type $RECEIVER"; fi
|
||||
if [ -n "$RECEIVER_SERIAL" ]; then OPTS="$OPTS --device-index $RECEIVER_SERIAL"; fi
|
||||
if [ -n "$RECEIVER_GAIN" ]; then OPTS="$OPTS --gain $RECEIVER_GAIN"; fi
|
||||
if [ -n "$WISDOM" -a -f "$WISDOM" ]; then OPTS="$OPTS --wisdom $WISDOM"; fi
|
||||
# build a list of options based on config settings
|
||||
OPTS=""
|
||||
|
||||
if [ "$ADAPTIVE_DYNAMIC_RANGE" = "yes" ]; then OPTS="$OPTS --adaptive-range"; fi
|
||||
if [ -n "$ADAPTIVE_DYNAMIC_RANGE_TARGET" ]; then OPTS="$OPTS --adaptive-range-target $ADAPTIVE_DYNAMIC_RANGE_TARGET"; fi
|
||||
if [ "$ADAPTIVE_BURST" = "yes" ]; then OPTS="$OPTS --adaptive-burst"; fi
|
||||
if [ -n "$ADAPTIVE_MIN_GAIN" ]; then OPTS="$OPTS --adaptive-min-gain $ADAPTIVE_MIN_GAIN"; fi
|
||||
if [ -n "$ADAPTIVE_MAX_GAIN" ]; then OPTS="$OPTS --adaptive-max-gain $ADAPTIVE_MAX_GAIN"; fi
|
||||
|
||||
if is_slow_cpu
|
||||
if [ "${RECEIVER:-none}" = "none" ]
|
||||
then
|
||||
OPTS="$OPTS --adaptive-duty-cycle 10 --no-fix-df"
|
||||
OPTS="$OPTS --device-type none"
|
||||
else
|
||||
if [ -n "$RECEIVER" ]; then OPTS="$OPTS --device-type $RECEIVER"; fi
|
||||
if [ -n "$RECEIVER_SERIAL" ]; then OPTS="$OPTS --device-index $RECEIVER_SERIAL"; fi
|
||||
if [ -n "$RECEIVER_GAIN" ]; then OPTS="$OPTS --gain $RECEIVER_GAIN"; fi
|
||||
if [ -n "$WISDOM" -a -f "$WISDOM" ]; then OPTS="$OPTS --wisdom $WISDOM"; fi
|
||||
|
||||
if [ "$ADAPTIVE_DYNAMIC_RANGE" = "yes" ]; then OPTS="$OPTS --adaptive-range"; fi
|
||||
if [ -n "$ADAPTIVE_DYNAMIC_RANGE_TARGET" ]; then OPTS="$OPTS --adaptive-range-target $ADAPTIVE_DYNAMIC_RANGE_TARGET"; fi
|
||||
if [ "$ADAPTIVE_BURST" = "yes" ]; then OPTS="$OPTS --adaptive-burst"; fi
|
||||
if [ -n "$ADAPTIVE_MIN_GAIN" ]; then OPTS="$OPTS --adaptive-min-gain $ADAPTIVE_MIN_GAIN"; fi
|
||||
if [ -n "$ADAPTIVE_MAX_GAIN" ]; then OPTS="$OPTS --adaptive-max-gain $ADAPTIVE_MAX_GAIN"; fi
|
||||
|
||||
if is_slow_cpu
|
||||
then
|
||||
OPTS="$OPTS --adaptive-duty-cycle 10 --no-fix-df"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$ERROR_CORRECTION" = "yes" ]; then OPTS="$OPTS --fix"; fi
|
||||
|
||||
if [ -n "$RECEIVER_LAT" -a -n "$RECEIVER_LON" ]; then
|
||||
OPTS="$OPTS --lat $RECEIVER_LAT --lon $RECEIVER_LON"
|
||||
elif [ -n "$PIAWARE_LAT" -a -n "$PIAWARE_LON" ]; then
|
||||
OPTS="$OPTS --lat $PIAWARE_LAT --lon $PIAWARE_LON"
|
||||
fi
|
||||
|
||||
if [ -n "$MAX_RANGE" ]; then OPTS="$OPTS --max-range $MAX_RANGE"; fi
|
||||
|
||||
if [ -n "$NET_RAW_INPUT_PORTS" ]; then OPTS="$OPTS --net-ri-port $NET_RAW_INPUT_PORTS"; fi
|
||||
if [ -n "$NET_RAW_OUTPUT_PORTS" ]; then OPTS="$OPTS --net-ro-port $NET_RAW_OUTPUT_PORTS"; fi
|
||||
if [ -n "$NET_SBS_OUTPUT_PORTS" ]; then OPTS="$OPTS --net-sbs-port $NET_SBS_OUTPUT_PORTS"; fi
|
||||
if [ -n "$NET_BEAST_INPUT_PORTS" ]; then OPTS="$OPTS --net-bi-port $NET_BEAST_INPUT_PORTS"; fi
|
||||
if [ -n "$NET_BEAST_OUTPUT_PORTS" ]; then OPTS="$OPTS --net-bo-port $NET_BEAST_OUTPUT_PORTS"; fi
|
||||
|
||||
if [ -n "$JSON_LOCATION_ACCURACY" ]; then OPTS="$OPTS --json-location-accuracy $JSON_LOCATION_ACCURACY"; fi
|
||||
|
||||
if [ -n "$EXTRA_OPTIONS" ]; then OPTS="$OPTS $EXTRA_OPTIONS"; fi
|
||||
fi
|
||||
|
||||
if [ "$ERROR_CORRECTION" = "yes" ]; then OPTS="$OPTS --fix"; fi
|
||||
|
||||
if [ -n "$RECEIVER_LAT" -a -n "$RECEIVER_LON" ]; then
|
||||
OPTS="$OPTS --lat $RECEIVER_LAT --lon $RECEIVER_LON"
|
||||
elif [ -n "$PIAWARE_LAT" -a -n "$PIAWARE_LON" ]; then
|
||||
OPTS="$OPTS --lat $PIAWARE_LAT --lon $PIAWARE_LON"
|
||||
fi
|
||||
|
||||
if [ -n "$MAX_RANGE" ]; then OPTS="$OPTS --max-range $MAX_RANGE"; fi
|
||||
|
||||
if [ -n "$NET_RAW_INPUT_PORTS" ]; then OPTS="$OPTS --net-ri-port $NET_RAW_INPUT_PORTS"; fi
|
||||
if [ -n "$NET_RAW_OUTPUT_PORTS" ]; then OPTS="$OPTS --net-ro-port $NET_RAW_OUTPUT_PORTS"; fi
|
||||
if [ -n "$NET_SBS_OUTPUT_PORTS" ]; then OPTS="$OPTS --net-sbs-port $NET_SBS_OUTPUT_PORTS"; fi
|
||||
if [ -n "$NET_BEAST_INPUT_PORTS" ]; then OPTS="$OPTS --net-bi-port $NET_BEAST_INPUT_PORTS"; fi
|
||||
if [ -n "$NET_BEAST_OUTPUT_PORTS" ]; then OPTS="$OPTS --net-bo-port $NET_BEAST_OUTPUT_PORTS"; fi
|
||||
|
||||
if [ -n "$JSON_LOCATION_ACCURACY" ]; then OPTS="$OPTS --json-location-accuracy $JSON_LOCATION_ACCURACY"; fi
|
||||
|
||||
if [ -n "$EXTRA_OPTIONS" ]; then OPTS="$OPTS $EXTRA_OPTIONS"; fi
|
||||
|
||||
if [ -n "$OVERRIDE_OPTIONS" ]; then OPTS="$OVERRIDE_OPTIONS"; fi
|
||||
|
||||
exec /usr/bin/dump1090-fa $OPTS "$@"
|
||||
exec /usr/bin/dump1090-fa --quiet $OPTS "$@"
|
||||
# exec failed, do not restart
|
||||
exit 64
|
||||
|
|
|
|||
|
|
@ -21,13 +21,6 @@ then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
# Use EXTRA_OPTIONS as a marker for a new-style config file
|
||||
if grep -q EXTRA_OPTIONS ${OLDCONFIG}
|
||||
then
|
||||
echo "$OLDCONFIG seems to already be a new-style config, nothing to upgrade" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ! -f $PACKAGECONFIG ]
|
||||
then
|
||||
echo "$PACKAGECONFIG does not exist, cannot continue" >&2
|
||||
|
|
@ -60,6 +53,23 @@ EXTRAS_NET_HEARTBEAT="60"
|
|||
# read the old config
|
||||
. "$OLDCONFIG"
|
||||
|
||||
# if there's no CONFIG_STYLE, infer a version
|
||||
if [ -z "$CONFIG_STYLE" ]
|
||||
then
|
||||
if [ -n "$RECEIVER_OPTIONS" -o -n "$DECODER_OPTIONS" -o -n "$NET_OPTIONS" -o -n "$JSON_OPTIONS" ]
|
||||
then
|
||||
CONFIG_STYLE=5
|
||||
else
|
||||
CONFIG_STYLE=6
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$CONFIG_STYLE" = "6" ]
|
||||
then
|
||||
echo "$OLDCONFIG seems to already be a new-style config, nothing to upgrade" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# process all the options from the old config file and accumulate settings in env vars
|
||||
process_options() {
|
||||
while [ $# -gt 0 ]
|
||||
|
|
|
|||
Loading…
Reference in New Issue