mirror of
https://github.com/sdr-enthusiasts/docker-adsb-ultrafeeder.git
synced 2024-12-25 22:02:00 +00:00
80 lines
3.4 KiB
Text
Executable file
80 lines
3.4 KiB
Text
Executable file
#!/command/with-contenv bash
|
|
# shellcheck shell=bash disable=SC2015,SC2016,SC1091,SC2001,SC2154
|
|
|
|
#---------------------------------------------------------------------------------------------
|
|
# 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
|
|
|
|
# Check if ADSBExchange is configured
|
|
if ! grep -i adsbexchange.com <<< "$ULTRAFEEDER_CONFIG" >/dev/null 2>&1; then
|
|
"${s6wrap[@]}" echo "AdsbExchange not configured - no stats package needed"
|
|
stop_service
|
|
fi
|
|
|
|
# Check if ADSBExchange stats are disabled
|
|
if chk_disabled "$ADSBX_STATS" ; then
|
|
"${s6wrap[@]}" echo "AdsbExchange stats disabled"
|
|
stop_service
|
|
fi
|
|
|
|
# prep work:
|
|
mkdir -p /run/adsbexchange-stats
|
|
|
|
# set the UUID:
|
|
# get UUID from ULTRAFEEDER_CONFIG if it exists
|
|
for entry in "${READSB_CONF_ARR[@]}"; do
|
|
echo "$entry"
|
|
if echo "$entry" | grep -q 'adsbexchange.*uuid'; then
|
|
ADSBX_UUID="$(sed 's|.*adsbexchange.*uuid=\([a-f0-9-]\+\).*|\1|g' <<< "$entry")"
|
|
fi
|
|
done
|
|
|
|
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
|
|
# export the variable, it's used by json-status which is started by this script at the very end
|
|
export ADSBX_UUID
|
|
"${s6wrap[@]}" echo "Using UUID $ADSBX_UUID for AdsbExchange"
|
|
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
|
|
|
|
# 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
|
|
|
|
# Let adsbexchange-json-status start up, and then print the Anywhere Map and Anywhere Stats URLs to the container logs:
|
|
{ sleep 15
|
|
AnywhereMap="$(curl -sSL https://www.adsbexchange.com/myip/ | grep "https://globe.adsbexchange.com/?feed=" | sed -n 's|.*\(https.*\)\"|\1|p')"
|
|
AnywhereStats="$(curl -sSL https://www.adsbexchange.com/myip/ | grep "https://www.adsbexchange.com/api/feeders/?feed=" | sed -n 's|.*\(https.*\)\"|\1|p')"
|
|
"${s6wrap[@]}" echo "Your AdsbExchange Anywhere Map URL is $AnywhereMap"
|
|
"${s6wrap[@]}" echo "Your AdsbExchange Anywhere Stats URL is $AnywhereStats"
|
|
} &
|
|
|
|
"${s6wrap[@]}" echo "invoking: /usr/local/bin/adsbexchange-json-status"
|
|
exec "${s6wrap[@]}" /usr/local/bin/adsbexchange-json-status
|