mirror of
https://github.com/sdr-enthusiasts/docker-adsb-ultrafeeder.git
synced 2024-11-22 13:50:14 +00:00
114 lines
4.4 KiB
Text
Executable file
114 lines
4.4 KiB
Text
Executable file
#!/command/with-contenv bash
|
|
# shellcheck shell=bash disable=SC1091,SC2015,SC2016
|
|
|
|
#---------------------------------------------------------------------------------------------
|
|
# Copyright (C) 2023-2024, Ramon F. Kolb (kx1t) and contributors
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by the
|
|
# Free Software Foundation, either version 3 of the License, or (at your option)
|
|
# any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful, but
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License along with this program.
|
|
# If not, see <https://www.gnu.org/licenses/>.
|
|
#---------------------------------------------------------------------------------------------
|
|
|
|
source /scripts/common
|
|
source /scripts/interpret_ultrafeeder_config
|
|
s6wrap=(s6wrap --quiet --timestamps --prepend="$SCRIPT_NAME")
|
|
|
|
LOGLEVEL="${LOGLEVEL,,}"
|
|
LOGLEVEL="${LOGLEVEL:-verbose}"
|
|
chk_disabled "$LOGLEVEL" && LOGLEVEL="none" || true
|
|
if ! [[ "$LOGLEVEL" =~ ^(verbose|error|none)$ ]]; then
|
|
[[ -n "$LOGLEVEL" ]] && "${s6wrap[@]}" --args echo "[WARNING] LOGLEVEL set to an unknown value. Defaulting to \"verbose\"" || true
|
|
LOGLEVEL="verbose"
|
|
fi
|
|
|
|
if [[ -z "${MLAT_CONFIG}" ]] && [[ -z "$MLATHUB_NET_CONNECTOR" ]]; then
|
|
"${s6wrap[@]}" --args echo "No MLAT servers have been defined in MLAT_CONFIG and no external sources have been defined in MLATHUB_NET_CONNECTOR - no need to start MLATHUB"
|
|
exec sleep infinity
|
|
fi
|
|
|
|
if chk_enabled "${MLATHUB_DISABLE}"; then
|
|
"${s6wrap[@]}" --args echo "MLATHUB is disabled."
|
|
exec sleep infinity
|
|
fi
|
|
|
|
# Build the readsb command line based on options
|
|
MLATHUB_BIN="/usr/local/bin/readsb"
|
|
|
|
# set some basic options:
|
|
MLATHUB_CMD=("--net")
|
|
MLATHUB_CMD+=("--quiet")
|
|
MLATHUB_CMD+=("--net-only")
|
|
MLATHUB_CMD+=("--mlat")
|
|
MLATHUB_CMD+=("--forward-mlat")
|
|
MLATHUB_CMD+=("--forward-mlat-sbs")
|
|
|
|
MLATHUB_CMD+=("--net-connector=localhost,30004,beast_out")
|
|
|
|
# define some more ports:
|
|
MLATHUB_CMD+=("--net-sbs-port=${MLATHUB_SBS_OUT_PORT:-31003}")
|
|
MLATHUB_CMD+=("--net-bi-port=${MLATHUB_BEAST_IN_PORT:-31004}")
|
|
MLATHUB_CMD+=("--net-bo-port=${MLATHUB_BEAST_OUT_PORT:-31005}")
|
|
MLATHUB_CMD+=("--net-beast-reduce-out-port=${MLATHUB_BEAST_REDUCE_OUT_PORT:-31006}")
|
|
|
|
# Add any additional net_connectors:
|
|
if [[ -n "$MLATHUB_NET_CONNECTOR" ]]; then
|
|
# Strip any extraneous spaces:
|
|
MLATHUB_NET_CONNECTOR="${MLATHUB_NET_CONNECTOR#"${MLATHUB_NET_CONNECTOR%%[![:space:]]*}"}" # strip leading spaces
|
|
MLATHUB_NET_CONNECTOR="${MLATHUB_NET_CONNECTOR//; /;}" # strip space after semicolon
|
|
IFS=';' read -r -a MLATHUB_NET_CONNECTOR_ARRAY <<< "$MLATHUB_NET_CONNECTOR"
|
|
for NET_CONNECTOR_ELEMENT in "${MLATHUB_NET_CONNECTOR_ARRAY[@]}"
|
|
do
|
|
MLATHUB_CMD+=("--net-connector=${NET_CONNECTOR_ELEMENT}")
|
|
done
|
|
fi
|
|
|
|
# Handle ULTRAFEEDER_CONFIG / ULTRAFEEDER_NET_CONNECTOR elements relevant to readsb:
|
|
[[ "${#MLATHUB_CONF_ARR[@]}" -gt 0 ]] && MLATHUB_CMD+=("${MLATHUB_CONF_ARR[@]}") || true
|
|
|
|
if chk_enabled "${READSB_DEBUG}"; then
|
|
MLATHUB_CMD+=("--debug=$READSB_DEBUG")
|
|
fi
|
|
|
|
if [ -n "${LAT}" ]; then
|
|
MLATHUB_CMD+=(--lat "${LAT}")
|
|
elif [ -n "${READSB_LAT}" ]; then
|
|
MLATHUB_CMD+=(--lat "${READSB_LAT}")
|
|
fi
|
|
|
|
if [ -n "${LONG}" ]; then
|
|
MLATHUB_CMD+=(--lon "${LONG}")
|
|
elif [ -n "${READSB_LON}" ]; then
|
|
MLATHUB_CMD+=(--lon "${READSB_LON}")
|
|
fi
|
|
|
|
# Handle "--max-range=<dist>"
|
|
if [[ -n "$READSB_MAX_RANGE" ]]; then
|
|
MLATHUB_CMD+=("--max-range=$READSB_MAX_RANGE")
|
|
fi
|
|
|
|
# Handle "--net-connector-delay=<seconds>"
|
|
if [[ -n "$READSB_NET_CONNECTOR_DELAY" ]]; then
|
|
MLATHUB_CMD+=("--net-connector-delay=$READSB_NET_CONNECTOR_DELAY")
|
|
fi
|
|
|
|
# Handle "--net-heartbeat=<rate>"
|
|
MLATHUB_CMD+=("--net-heartbeat=${READSB_NET_HEARTBEAT:-35}")
|
|
|
|
"${s6wrap[@]}" --args echo "Starting MLATHUB..."
|
|
|
|
# shellcheck disable=SC2086,SC2069
|
|
if [[ "${LOGLEVEL}" == "verbose" ]]; then
|
|
exec "${s6wrap[@]}" --args "${MLATHUB_BIN}" "${MLATHUB_CMD[@]}" $MLATHUB_EXTRA_ARGS
|
|
elif [[ "${LOGLEVEL}" == "error" ]]; then
|
|
exec "${s6wrap[@]}" --ignore=stdout --args "${MLATHUB_BIN}" "${MLATHUB_CMD[@]}" $MLATHUB_EXTRA_ARGS
|
|
elif [[ "${LOGLEVEL}" == "none" ]]; then
|
|
exec "${s6wrap[@]}" --ignore=stdtout --ignore=stderr --args "${MLATHUB_BIN}" "${MLATHUB_CMD[@]}" $MLATHUB_EXTRA_ARGS
|
|
fi
|