1
0
Fork 0
mirror of https://github.com/sdr-enthusiasts/docker-adsb-ultrafeeder.git synced 2024-12-26 14:22:00 +00:00
docker-adsb-ultrafeeder/rootfs/etc/s6-overlay/scripts/adsbx-stats
2023-10-13 08:40:38 -04:00

52 lines
No EOL
2 KiB
Text
Executable file

#!/command/with-contenv bash
# shellcheck shell=bash disable=SC2015,SC2016,SC1091
source /scripts/common
s6wrap=(s6wrap --quiet --timestamps --prepend="$(basename "$0")" --args)
# 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"
sleep infinity & wait $!
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"
sleep infinity & wait $!
fi
chmod 755 /usr/local/bin/json-status
fi
mkdir -p /run/adsbexchange-stats
# wait until readsb is established...
if ! pgrep readsb >/dev/null; then
if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then
"${s6wrap[@]}" echo "Delaying start of the AdsbExchange Stats module until container is established..."
fi
while ! pgrep readsb >/dev/null
do
sleep 2 & wait $!
done
# wait 2 seconds after readsb process exists
sleep 2 & wait $!
fi
"${s6wrap[@]}" echo "invoking: /usr/local/bin/json-status"
"${s6wrap[@]}" /usr/local/bin/json-status