2023-10-13 12:09:13 +00:00
|
|
|
#!/command/with-contenv bash
|
|
|
|
# shellcheck shell=bash disable=SC2015,SC2016,SC1091
|
|
|
|
|
|
|
|
source /scripts/common
|
2023-10-13 12:18:57 +00:00
|
|
|
s6wrap=(s6wrap --quiet --timestamps --prepend="$(basename "$0")" --args)
|
2023-10-13 12:09:13 +00:00
|
|
|
|
|
|
|
# First check if ADSBX is in the config string
|
|
|
|
|
|
|
|
# combine ULTRAFEEDER_CONFIG and ULTRAFEEDER_NET_CONNECTOR
|
|
|
|
ULTRAFEEDER_CONFIG="${ULTRAFEEDER_CONFIG}${ULTRAFEEDER_CONFIG:+;}${ULTRAFEEDER_NET_CONNECTOR}"
|
|
|
|
# remove any newlines:
|
|
|
|
ULTRAFEEDER_CONFIG="${ULTRAFEEDER_CONFIG//$'\n'/}"
|
|
|
|
# Strip any extraneous spaces:
|
|
|
|
ULTRAFEEDER_CONFIG="${ULTRAFEEDER_CONFIG#"${ULTRAFEEDER_CONFIG%%[![:space:]]*}"}" # strip leading space
|
|
|
|
ULTRAFEEDER_CONFIG="${ULTRAFEEDER_CONFIG//; /;}"
|
|
|
|
if ! grep -i adsbexchange.com <<< "$ULTRAFEEDER_CONFIG" >/dev/null 2>&1; then
|
|
|
|
"${s6wrap[@]}" echo "AdsbExchange not configured - no stats package needed"
|
2023-10-13 12:37:54 +00:00
|
|
|
sleep infinity & wait $!
|
2023-10-13 12:09:13 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Install the Stats package:
|
|
|
|
|
|
|
|
if [[ ! -f /etc/default/adsbexchange-stats ]]; then
|
|
|
|
echo -e "UUID_FILE=/run/uuid\nJSON_PATHS=(\"/run/readsb\")" > /etc/default/adsbexchange-stats
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -f /usr/local/bin/json-status ]]; then
|
|
|
|
if ! curl -sSL -o /usr/local/bin/json-status https://raw.githubusercontent.com/ADSBexchange/adsbexchange-stats/master/json-status; then
|
|
|
|
"${s6wrap[@]}" echo "ERROR: AdsbExchange configure, but cannot download stats package! AdsbExchange will be fed but stats will not be available"
|
2023-10-13 12:37:54 +00:00
|
|
|
sleep infinity & wait $!
|
2023-10-13 12:09:13 +00:00
|
|
|
fi
|
|
|
|
chmod 755 /usr/local/bin/json-status
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p /run/adsbexchange-stats
|
2023-10-13 12:37:54 +00:00
|
|
|
|
|
|
|
# wait until readsb is established...
|
|
|
|
if ! pgrep readsb >/dev/null; then
|
|
|
|
if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then
|
2023-10-13 12:40:38 +00:00
|
|
|
"${s6wrap[@]}" echo "Delaying start of the AdsbExchange Stats module until container is established..."
|
2023-10-13 12:37:54 +00:00
|
|
|
fi
|
|
|
|
while ! pgrep readsb >/dev/null
|
|
|
|
do
|
|
|
|
sleep 2 & wait $!
|
|
|
|
done
|
|
|
|
# wait 2 seconds after readsb process exists
|
|
|
|
sleep 2 & wait $!
|
|
|
|
fi
|
|
|
|
|
2023-10-13 12:40:38 +00:00
|
|
|
"${s6wrap[@]}" echo "invoking: /usr/local/bin/json-status"
|
2023-10-13 12:37:54 +00:00
|
|
|
|
2023-10-13 12:09:13 +00:00
|
|
|
"${s6wrap[@]}" /usr/local/bin/json-status
|