1
0
Fork 0
mirror of https://github.com/sdr-enthusiasts/docker-adsb-ultrafeeder.git synced 2024-11-24 14:50:09 +00:00
This commit is contained in:
kx1t 2023-10-13 09:19:36 -04:00
parent 31ae9e3a99
commit 366893507a

View file

@ -1,29 +1,23 @@
#!/command/with-contenv bash #!/command/with-contenv bash
# shellcheck shell=bash disable=SC2015,SC2016,SC1091 # shellcheck shell=bash disable=SC2015,SC2016,SC1091,SC2001
source /scripts/common source /scripts/common
source /scripts/interpret_ultrafeeder_config
s6wrap=(s6wrap --quiet --timestamps --prepend="$(basename "$0")" --args) s6wrap=(s6wrap --quiet --timestamps --prepend="$(basename "$0")" --args)
# First check if ADSBX is in the config string # Check if ADSBExchange is configured
# 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 if ! grep -i adsbexchange.com <<< "$ULTRAFEEDER_CONFIG" >/dev/null 2>&1; then
"${s6wrap[@]}" echo "AdsbExchange not configured - no stats package needed" "${s6wrap[@]}" echo "AdsbExchange not configured - no stats package needed"
sleep infinity & wait $! sleep infinity & wait $!
fi fi
# Install the Stats package: # prep work:
mkdir -p /run/adsbexchange-stats
# Install the Stats package:
if [[ ! -f /etc/default/adsbexchange-stats ]]; then if [[ ! -f /etc/default/adsbexchange-stats ]]; then
echo -e "UUID_FILE=/run/uuid\nJSON_PATHS=(\"/run/readsb\")" > /etc/default/adsbexchange-stats echo -e "UUID_FILE=/run/uuid\nJSON_PATHS=(\"/run/readsb\")" > /etc/default/adsbexchange-stats
fi fi
if [[ ! -f /usr/local/bin/json-status ]]; then 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 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" "${s6wrap[@]}" echo "ERROR: AdsbExchange configure, but cannot download stats package! AdsbExchange will be fed but stats will not be available"
@ -32,7 +26,18 @@ if [[ ! -f /usr/local/bin/json-status ]]; then
chmod 755 /usr/local/bin/json-status chmod 755 /usr/local/bin/json-status
fi fi
mkdir -p /run/adsbexchange-stats # set the UUID:
if [[ ! -f /usr/local/share/adsbexchange/adsbx-uuid ]]; then
ADSBX_UUID="$(sed 's|.*adsbexchange.*uuid=\([a-f0-9-]\+\).*|\1|g' <<< "${READSB_CONF_ARR[@]}")" || true # get UUID from ULTRAFEEDER_CONFIG if it exists
ADSBX_UUID="${ADSBX_UUID:-${UUID}}" || true # ...else get it from the UUID param
ADSBX_UUID="${ADSBX_UUID:-$(cat /proc/sys/kernel/random/uuid 2>/dev/null)}" || true # ...else generate a random one
if [[ -n "$ADSBX_UUID" ]]; then
mkdir -p /usr/local/share/adsbexchange
echo "$ADSBX_UUID" > /usr/local/share/adsbexchange/adsbx-uuid
else
"${s6wrap[@]}" echo "WARNING: no UUID can be identified to be used with AdsbExchange; a random one will be generated every time the container is started."
fi
fi
# wait until readsb is established... # wait until readsb is established...
if ! pgrep readsb >/dev/null; then if ! pgrep readsb >/dev/null; then