From f19bdb759f4c9778744c35fe4fce743aeb3cb8c4 Mon Sep 17 00:00:00 2001 From: kx1t Date: Fri, 13 Oct 2023 08:09:13 -0400 Subject: [PATCH] initial commit --- .../dependencies.d/01-print-container-version | 0 .../dependencies.d/02-remove-prometheus-data | 0 .../dependencies.d/03-remove-mlathub-up | 0 .../adsbx-stats/dependencies.d/50-store-uuid | 0 .../dependencies.d/60-mlathub-prep | 0 rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/run | 2 + .../etc/s6-overlay/s6-rc.d/adsbx-stats/type | 1 + rootfs/etc/s6-overlay/scripts/adsbx-stats | 38 +++++++++++++++++++ 8 files changed, 41 insertions(+) create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/dependencies.d/01-print-container-version create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/dependencies.d/02-remove-prometheus-data create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/dependencies.d/03-remove-mlathub-up create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/dependencies.d/50-store-uuid create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/dependencies.d/60-mlathub-prep create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/run create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/type create mode 100755 rootfs/etc/s6-overlay/scripts/adsbx-stats diff --git a/rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/dependencies.d/01-print-container-version b/rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/dependencies.d/01-print-container-version new file mode 100644 index 0000000..e69de29 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/dependencies.d/02-remove-prometheus-data b/rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/dependencies.d/02-remove-prometheus-data new file mode 100644 index 0000000..e69de29 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/dependencies.d/03-remove-mlathub-up b/rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/dependencies.d/03-remove-mlathub-up new file mode 100644 index 0000000..e69de29 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/dependencies.d/50-store-uuid b/rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/dependencies.d/50-store-uuid new file mode 100644 index 0000000..e69de29 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/dependencies.d/60-mlathub-prep b/rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/dependencies.d/60-mlathub-prep new file mode 100644 index 0000000..e69de29 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/run b/rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/run new file mode 100755 index 0000000..c146d12 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/run @@ -0,0 +1,2 @@ +#!/bin/sh +exec /etc/s6-overlay/scripts/adsbx-stats diff --git a/rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/type b/rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/adsbx-stats/type @@ -0,0 +1 @@ +longrun diff --git a/rootfs/etc/s6-overlay/scripts/adsbx-stats b/rootfs/etc/s6-overlay/scripts/adsbx-stats new file mode 100755 index 0000000..c2a9af5 --- /dev/null +++ b/rootfs/etc/s6-overlay/scripts/adsbx-stats @@ -0,0 +1,38 @@ +#!/command/with-contenv bash +# shellcheck shell=bash disable=SC2015,SC2016,SC1091 + +APPNAME="readsb" + +source /scripts/common +s6wrap=(s6wrap --quiet --timestamps --prepend="${APPNAME}" --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" + exec sleep infinity +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" + exec sleep infinity + fi + chmod 755 /usr/local/bin/json-status +fi + +mkdir -p /run/adsbexchange-stats +"${s6wrap[@]}" /usr/local/bin/json-status \ No newline at end of file