From cbc92749419160e361e1f42fdf32695e0111e98d Mon Sep 17 00:00:00 2001 From: kx1t <15090643+kx1t@users.noreply.github.com> Date: Thu, 8 Aug 2024 13:31:47 -0400 Subject: [PATCH] Zonetable additions and updates (#77) * auto dns/port selection based on zone * add zone map * Update README.md * make use of zonetable persistent across all functions * make logging more consistent * cleanup * cleanup * made ImAlive more robust * add EU zones * improve zonetable to auto-extract zone names; add EU zones * Update README.md * add FALLBACK_IMALIVE_SERVICE * Update zonetable * implement zonetable auto updates * Update imalive * Update zonetable-update * Update zonetable-update * Update zonetable * change to test zonetable downloads * Create imalive-original * Update Dockerfile * Update imalive * Update zonetable-update * Update zonetable * Update zonetable-update * Update zonetable * Update imalive * Update imalive * Update imalive * Update imalive * Update zonetable * Update zonetable-update * Update zonetable-update * Update zonetable * Update imalive * Update zonetable * Update zonetable-update * Update zonetable * Update 50-radarvirtuel * Update 55-mlat-client * Update imalive * Update mlat-client * Update radarvirtuel * Update zonetable-update * Update healthcheck.sh * remove file * add zonetable coverage for mlat_server * temp change to test zonetable updates for mlat * updates * update zonetable * kill processes more efficiently * zonetable change test * more zonetable change testing * updates * MLAT_SERVER auto config --- rootfs/etc/s6-overlay/scripts/50-radarvirtuel | 40 ++++++++++--------- rootfs/etc/s6-overlay/scripts/55-mlat-client | 11 +++-- rootfs/etc/s6-overlay/scripts/imalive | 6 ++- rootfs/etc/s6-overlay/scripts/mlat-client | 13 ++++-- rootfs/etc/s6-overlay/scripts/radarvirtuel | 4 +- .../etc/s6-overlay/scripts/zonetable-update | 20 +++++----- rootfs/home/zonetable | 37 ++++++++++++++++- 7 files changed, 92 insertions(+), 39 deletions(-) diff --git a/rootfs/etc/s6-overlay/scripts/50-radarvirtuel b/rootfs/etc/s6-overlay/scripts/50-radarvirtuel index 9c8ee88..47ac979 100755 --- a/rootfs/etc/s6-overlay/scripts/50-radarvirtuel +++ b/rootfs/etc/s6-overlay/scripts/50-radarvirtuel @@ -20,6 +20,16 @@ source /scripts/common "${s6wrap[@]}" echo "Initializing RadarVirtuel..." +if [[ "${RV_SERVER%%:*}" == "mg2.adsbnetwork.com" ]]; then + RV_SERVER="mg22.adsbnetwork.com:${RV_SERVER##*:}" + "${s6wrap[@]}" cat </dev/null 2>&1 || true + pkill -f /home/py/ANfeeder >/dev/null 2>&1 || true + pkill -f /usr/local/bin/mlat-client >/dev/null 2>&1 || true echo "$(date +%s) - $ALIVE" >> /run/imalive/errors else echo "" > /run/imalive/errors diff --git a/rootfs/etc/s6-overlay/scripts/mlat-client b/rootfs/etc/s6-overlay/scripts/mlat-client index 8edf20e..26a99be 100755 --- a/rootfs/etc/s6-overlay/scripts/mlat-client +++ b/rootfs/etc/s6-overlay/scripts/mlat-client @@ -27,11 +27,19 @@ MLAT_FLAG="/run/mlat-down" MLAT_INPUT_TYPE="${MLAT_INPUT_TYPE:-auto}" MLAT_RESULTS="${MLAT_RESULTS:-beast,listen,30105}" +# If MLAT_HOST is not defined, use port 30005 (beast_out) on the SOURCE_HOST +MLAT_HOST="${MLAT_HOST:-${SOURCE_HOST%%:*}:30005}" + START_DELAY=10s +# update the MLAT_SERVER from the ZoneTable script: +source /home/zonetable +MLAT_SERVER="${zone_mlat:-${MLAT_SERVER}}" +MLAT_SERVER="${MLAT_SERVER:-mlat.adsbnetwork.com:50000}" + # Do some basic checks: # Sleep forever if the initialization process found that MLAT cannot be started -[[ -f ${MLAT_FLAG} ]] && [[ "$(<${MLAT_FLAG})" != "temp" ]] && sleep infinity || true +if [[ -f ${MLAT_FLAG} ]] && [[ "$(<${MLAT_FLAG})" != "temp" ]]; then stop_service; fi # Sleep for 5 minutes if the issue is that the config is correct but the server is down if [[ -f ${MLAT_FLAG} ]] && [[ "$(<${MLAT_FLAG})" == "temp" ]] then @@ -47,7 +55,6 @@ else fi MLAT_PARAM=(--input-type "${MLAT_INPUT_TYPE}") -# MLAT_PARAM+=(--no-udp) MLAT_PARAM+=(--input-connect "${MLAT_HOST}") MLAT_PARAM+=(--server "${MLAT_SERVER}") MLAT_PARAM+=(--lat "${LAT}") @@ -56,7 +63,7 @@ MLAT_PARAM+=(--alt "${ALT}") MLAT_PARAM+=(--results "${MLAT_RESULTS}") MLAT_PARAM+=(--user "${FEEDER_KEY}") MLAT_PARAM+=(--uuid "${FEEDER_KEY##*:}") -[[ -n "${PRIVATE_MLAT}" ]] && MLAT_PARAM+=(--privacy) || true +MLAT_PARAM+=("${PRIVATE_MLAT:+--privacy}") sleep ${START_DELAY} diff --git a/rootfs/etc/s6-overlay/scripts/radarvirtuel b/rootfs/etc/s6-overlay/scripts/radarvirtuel index 2708eca..17fb314 100755 --- a/rootfs/etc/s6-overlay/scripts/radarvirtuel +++ b/rootfs/etc/s6-overlay/scripts/radarvirtuel @@ -22,8 +22,8 @@ source /scripts/common START_DELAY=5s RV_SERVER="${RV_SERVER:-mg22.adsbnetwork.com:50050}" -[[ "${RV_SERVER%%:*}" == "mg2.adsbnetwork.com" ]] && RV_SERVER="mg22.adsbnetwork.com:${RV_SERVER##*:}" || true -"${s6wrap[@]}" echo "started as an s6 service" +if [[ "${RV_SERVER%%:*}" == "mg2.adsbnetwork.com" ]]; then RV_SERVER="mg22.adsbnetwork.com:${RV_SERVER##*:}"; fi +"${s6wrap[@]}" echo "Started as an s6 service" # check if we are in one of the defined zones, and update the server address accordingly: source /home/zonetable diff --git a/rootfs/etc/s6-overlay/scripts/zonetable-update b/rootfs/etc/s6-overlay/scripts/zonetable-update index c8303f8..1488bdf 100755 --- a/rootfs/etc/s6-overlay/scripts/zonetable-update +++ b/rootfs/etc/s6-overlay/scripts/zonetable-update @@ -21,23 +21,25 @@ source /scripts/common ZONETABLE_CHECK_INT="${ZONETABLE_CHECK_INT:-7200}" # check every 2 hours ZONETABLE_URL="${ZONETABLE_URL:-https://raw.githubusercontent.com/sdr-enthusiasts/docker-radarvirtuel/main/rootfs/home/zonetable}" -"${s6wrap[@]}" echo "[INFO] checking if zonetable needs to get updated" +"${s6wrap[@]}" echo "[INFO] Checking if zonetable needs to get updated" -if curl -sSL "${ZONETABLE_URL}" -o /tmp/zonetable >/dev/null 2>&1; then +if curl -sSL --fail "${ZONETABLE_URL}" -o /tmp/zonetable >/dev/null 2>&1; then if [[ -n "$(comm --nocheck-order -3 /home/zonetable /tmp/zonetable 2>/dev/null)" ]]; then - "${s6wrap[@]}" echo "[INFO] zonetable has changed, installing new version" + "${s6wrap[@]}" echo "[INFO] Zonetable has changed, installing new version and restarting ANFeeder and mlat-client" while [[ -f /run/zonetable.lock ]]; do sleep 1; done touch /run/zonetable.lock - mv -f /tmp/zonetable /home/zonetable - chmod +x /home/zonetable + mv -f /tmp/zonetable /home/zonetable + chmod +x /home/zonetable rm -f /run/zonetable.lock + pkill -f /home/py/ANfeeder >/dev/null 2>&1 || true + pkill -f /usr/local/bin/mlat-client >/dev/null 2>&1 || true else - "${s6wrap[@]}" echo "[INFO] zonetable has not changed since last check" + "${s6wrap[@]}" echo "[INFO] Zonetable has not changed since last check" rm -f /tmp/zonetable fi else - "${s6wrap[@]}" echo "[WARNING] couldn't reach the remote server with the latest zonetable - we will keep on using the current table" + "${s6wrap[@]}" echo "[WARNING] Couldn't reach the remote server with the latest zonetable - we will keep on using the current table" fi -"${s6wrap[@]}" echo "[INFO] next zonetable update check will be at $(date -d "+$ZONETABLE_CHECK_INT seconds" | xargs)" -sleep $ZONETABLE_CHECK_INT +"${s6wrap[@]}" echo "[INFO] Next zonetable update check will be at $(date -d "+$ZONETABLE_CHECK_INT seconds" | xargs)" +exec sleep "$ZONETABLE_CHECK_INT" diff --git a/rootfs/home/zonetable b/rootfs/home/zonetable index 20927d9..b1b5817 100644 --- a/rootfs/home/zonetable +++ b/rootfs/home/zonetable @@ -32,6 +32,7 @@ declare -A ZoneTable=( [EU001:max_lon]="-7.5" [EU001:min_lat]="34.0" [EU001:min_lon]="-25.0" + [EU001:mlat]="mlat.adsbnetwork.com:50000" [EU002:name]="East-Portugal Spain South-France" [EU002:dns]="mg22.adsbnetwork.com" [EU002:port]="50050" @@ -39,6 +40,7 @@ declare -A ZoneTable=( [EU002:max_lon]="10.0" [EU002:min_lat]="34.0" [EU002:min_lon]="-7.5" + [EU002:mlat]="mlat.adsbnetwork.com:50000" [EU003:name]="East-Mediterranean" [EU003:dns]="mg22.adsbnetwork.com" [EU003:port]="50050" @@ -46,6 +48,7 @@ declare -A ZoneTable=( [EU003:max_lon]="27.5" [EU003:min_lat]="34.0" [EU003:min_lon]="10.0" + [EU003:mlat]="mlat.adsbnetwork.com:50000" [EU004:name]="Turkey Middle-East" [EU004:dns]="mg22.adsbnetwork.com" [EU004:port]="50050" @@ -53,6 +56,7 @@ declare -A ZoneTable=( [EU004:max_lon]="45.0" [EU004:min_lat]="34.0" [EU004:min_lon]="27.5" + [EU004:mlat]="mlat.adsbnetwork.com:50000" [EU005:name]="Southwest-Ireland" [EU005:dns]="mg22.adsbnetwork.com" [EU005:port]="50050" @@ -60,6 +64,7 @@ declare -A ZoneTable=( [EU005:max_lon]="-7.5" [EU005:min_lat]="43.5" [EU005:min_lon]="-25.0" + [EU005:mlat]="mlat.adsbnetwork.com:50000" [EU006:name]="Southwest-Ireland South-GreatBritain France Benelux Western-Germany Switzerland NorthWest-Italy" [EU006:dns]="mg22.adsbnetwork.com" [EU006:port]="50050" @@ -67,6 +72,7 @@ declare -A ZoneTable=( [EU006:max_lon]="10.0" [EU006:min_lat]="43.5" [EU006:min_lon]="-7.5" + [EU006:mlat]="mlat.adsbnetwork.com:50000" [EU007:name]="Eastern-Germany Mid-Eastern-Europe" [EU007:dns]="mg22.adsbnetwork.com" [EU007:port]="50050" @@ -74,6 +80,7 @@ declare -A ZoneTable=( [EU007:max_lon]="27.5" [EU007:min_lat]="43.5" [EU007:min_lon]="10.0" + [EU007:mlat]="mlat.adsbnetwork.com:50000" [EU008:name]="Southeastern-Europe" [EU008:dns]="mg22.adsbnetwork.com" [EU008:port]="50050" @@ -81,6 +88,7 @@ declare -A ZoneTable=( [EU008:max_lon]="45.0" [EU008:min_lat]="43.5" [EU008:min_lon]="27.5" + [EU008:mlat]="mlat.adsbnetwork.com:50000" [EU009:name]="Northwestern-Ireland" [EU009:dns]="mg22.adsbnetwork.com" [EU009:port]="50050" @@ -88,6 +96,7 @@ declare -A ZoneTable=( [EU009:max_lon]="-7.5" [EU009:min_lat]="53.0" [EU009:min_lon]="-25.0" + [EU009:mlat]="mlat.adsbnetwork.com:50000" [EU010:name]="Great-Britain Northeastern-Ireland NorthSea-Countries" [EU010:dns]="mg22.adsbnetwork.com" [EU010:port]="50050" @@ -95,6 +104,7 @@ declare -A ZoneTable=( [EU010:max_lon]="10.0" [EU010:min_lat]="53.0" [EU010:min_lon]="-7.5" + [EU010:mlat]="mlat.adsbnetwork.com:50000" [EU011:name]="BalticSea-Countries" [EU011:dns]="mg22.adsbnetwork.com" [EU011:port]="50050" @@ -102,6 +112,7 @@ declare -A ZoneTable=( [EU011:max_lon]="27.5" [EU011:min_lat]="53.0" [EU011:min_lon]="10.0" + [EU011:mlat]="mlat.adsbnetwork.com:50000" [EU012:name]="Belarus Russia Eastern-Finland Eastern-Latvia" [EU012:dns]="mg22.adsbnetwork.com" [EU012:port]="50050" @@ -109,6 +120,7 @@ declare -A ZoneTable=( [EU012:max_lon]="45.0" [EU012:min_lat]="53.0" [EU012:min_lon]="27.5" + [EU012:mlat]="mlat.adsbnetwork.com:50000" [EU013:name]="Iceland" [EU013:dns]="mg22.adsbnetwork.com" [EU013:port]="50050" @@ -116,6 +128,7 @@ declare -A ZoneTable=( [EU013:max_lon]="-7.5" [EU013:min_lat]="62.5" [EU013:min_lon]="-25.0" + [EU013:mlat]="mlat.adsbnetwork.com:50000" [EU014:name]="Mid-Western-Norway" [EU014:dns]="mg22.adsbnetwork.com" [EU014:port]="50050" @@ -123,6 +136,7 @@ declare -A ZoneTable=( [EU014:max_lon]="10.0" [EU014:min_lat]="62.5" [EU014:min_lon]="-7.5" + [EU014:mlat]="mlat.adsbnetwork.com:50000" [EU015:name]="Northern-Scandinavia Northern-Finland" [EU015:dns]="mg22.adsbnetwork.com" [EU015:port]="50050" @@ -130,6 +144,7 @@ declare -A ZoneTable=( [EU015:max_lon]="27.5" [EU015:min_lat]="62.5" [EU015:min_lon]="10.0" + [EU015:mlat]="mlat.adsbnetwork.com:50000" [EU016:name]="Eastern-Finland Northwestern-Russia" [EU016:dns]="mg22.adsbnetwork.com" [EU016:port]="50050" @@ -137,6 +152,7 @@ declare -A ZoneTable=( [EU016:max_lon]="45.0" [EU016:min_lat]="62.5" [EU016:min_lon]="27.5" + [EU016:mlat]="mlat.adsbnetwork.com:50000" [NA001:name]="SoCal" [NA001:dns]="mg21.adsbnetwork.com" [NA001:port]="50021" @@ -144,6 +160,7 @@ declare -A ZoneTable=( [NA001:max_lon]="-117.1984944" [NA001:min_lat]="25.34440649" [NA001:min_lon]="-128.7677266" + [NA001:mlat]="mlat.adsbnetwork.com:50000" [NA002:dns]="mg21.adsbnetwork.com" [NA002:name]="AZ NM Baja nw-Mex" [NA002:port]="50031" @@ -151,6 +168,7 @@ declare -A ZoneTable=( [NA002:max_lon]="-105.6292621" [NA002:min_lat]="25.34440649" [NA002:min_lon]="-117.1984944" + [NA002:mlat]="mlat.adsbnetwork.com:50000" [NA003:name]="se-NM TX se-OK sw-AR" [NA003:dns]="mg21.adsbnetwork.com" [NA003:port]="50033" @@ -158,6 +176,7 @@ declare -A ZoneTable=( [NA003:max_lon]="-94.06002987" [NA003:min_lat]="25.34440649" [NA003:min_lon]="-105.6292621" + [NA003:mlat]="mlat.adsbnetwork.com:50000" [NA004:name]="so-AR LA MS AL FL GA" [NA004:dns]="mg21.adsbnetwork.com" [NA004:port]="50037" @@ -165,6 +184,7 @@ declare -A ZoneTable=( [NA004:max_lon]="-85.13" [NA004:min_lat]="25.34440649" [NA004:min_lon]="-94.06002987" + [NA004:mlat]="mlat.adsbnetwork.com:50000" [NA005:name]="GA FL" [NA005:dns]="mg21.adsbnetwork.com" [NA005:port]="50039" @@ -172,6 +192,7 @@ declare -A ZoneTable=( [NA005:max_lon]="-70.92156537" [NA005:min_lat]="24.5" [NA005:min_lon]="-85.13" + [NA005:mlat]="mlat.adsbnetwork.com:50000" [NA006:name]="CA NV OR" [NA006:dns]="mg21.adsbnetwork.com" [NA006:port]="50040" @@ -179,6 +200,7 @@ declare -A ZoneTable=( [NA006:max_lon]="-117.1984944" [NA006:min_lat]="34.3534155" [NA006:min_lon]="-128.7677266" + [NA006:mlat]="mlat.adsbnetwork.com:50000" [NA007:name]="NV sw-CA UT CO AZ NM ID WY" [NA007:dns]="mg21.adsbnetwork.com" [NA007:port]="50041" @@ -186,6 +208,7 @@ declare -A ZoneTable=( [NA007:max_lon]="-105.6292621" [NA007:min_lat]="34.3534155" [NA007:min_lon]="-117.1984944" + [NA007:mlat]="mlat.adsbnetwork.com:50000" [NA008:name]="WY SD IA CO KS MS NM no_TX OK we-AR" [NA008:dns]="mg21.adsbnetwork.com" [NA008:port]="50042" @@ -193,6 +216,7 @@ declare -A ZoneTable=( [NA008:max_lon]="-94.06002987" [NA008:min_lat]="34.3534155" [NA008:min_lon]="-105.6292621" + [NA008:mlat]="mlat.adsbnetwork.com:50000" [NA009:name]="IA WI MI IL IN OH MS KY AR TN no-MS no-AL no-GA" [NA009:dns]="mg21.adsbnetwork.com" [NA009:port]="50043" @@ -200,6 +224,7 @@ declare -A ZoneTable=( [NA009:max_lon]="-82.49079762" [NA009:min_lat]="34.3534155" [NA009:min_lon]="-94.06002987" + [NA009:mlat]="mlat.adsbnetwork.com:50000" [NA010:name]="mid-Atlantic south-NewEngland" [NA010:dns]="mg21.adsbnetwork.com" [NA010:port]="50044" @@ -207,6 +232,7 @@ declare -A ZoneTable=( [NA010:max_lon]="-69.9" [NA010:min_lat]="34.3534155" [NA010:min_lon]="-82.49079762" + [NA010:mlat]="mlat.adsbnetwork.com:50000" [NA011:name]="Pac NW" [NA011:dns]="mg21.adsbnetwork.com" [NA011:port]="50045" @@ -214,6 +240,7 @@ declare -A ZoneTable=( [NA011:max_lon]="-117.1984944" [NA011:min_lat]="43.3624245" [NA011:min_lon]="-128.7677266" + [NA011:mlat]="mlat.adsbnetwork.com:50000" [NA012:name]="ID MT WY east-BC AB SK" [NA012:dns]="mg21.adsbnetwork.com" [NA012:port]="50046" @@ -221,6 +248,7 @@ declare -A ZoneTable=( [NA012:max_lon]="-105.6292621" [NA012:min_lat]="43.3624245" [NA012:min_lon]="-117.1984944" + [NA012:mlat]="mlat.adsbnetwork.com:50000" [NA013:name]="WY MT ND SD MN SK MB ON" [NA013:dns]="mg21.adsbnetwork.com" [NA013:port]="50048" @@ -228,6 +256,7 @@ declare -A ZoneTable=( [NA013:max_lon]="-94.06002987" [NA013:min_lat]="43.3624245" [NA013:min_lon]="-105.6292621" + [NA013:mlat]="mlat.adsbnetwork.com:50000" [NA014:name]="MN WI MI ON" [NA014:dns]="mg21.adsbnetwork.com" [NA014:port]="50049" @@ -235,6 +264,7 @@ declare -A ZoneTable=( [NA014:max_lon]="-82.49079762" [NA014:min_lat]="43.3624245" [NA014:min_lon]="-94.06002987" + [NA014:mlat]="mlat.adsbnetwork.com:50000" [NA015:name]="No-NewEngland East-Canada StPierreMiquelon" [NA015:dns]="mg21.adsbnetwork.com" [NA015:port]="50051" @@ -242,6 +272,7 @@ declare -A ZoneTable=( [NA015:max_lon]="-52.432265" [NA015:min_lat]="43.3624245" [NA015:min_lon]="-82.49079762" + [NA015:mlat]="mlat.adsbnetwork.com:50000" [NA016:name]="Hawaii" [NA016:dns]="mg21.adsbnetwork.com" [NA016:port]="50039" @@ -249,6 +280,7 @@ declare -A ZoneTable=( [NA016:max_lon]="-154.539553" [NA016:min_lat]="18.809780" [NA016:min_lon]="-160.453822" + [NA016:mlat]="mlat.adsbnetwork.com:50000" [NA017:name]="Alaska" [NA017:dns]="mg21.adsbnetwork.com" [NA017:port]="50039" @@ -256,6 +288,7 @@ declare -A ZoneTable=( [NA017:max_lon]="-130" [NA017:min_lat]="51.2097" [NA017:min_lon]="-172" + [NA017:mlat]="mlat.adsbnetwork.com:50000" ) declare -a ZoneNames=() @@ -276,9 +309,11 @@ if [[ -n "$LON" ]] && [[ -n "$LAT" ]]; then zone_id="$zone" zone_dns="${ZoneTable[$zone:dns]}" zone_port="${ZoneTable[$zone:port]}" + zone_mlat="${ZoneTable[$zone:mlat]}" + unset ZoneTable ZoneNames break fi done else - unset zone_name zone_id zone_dns zone_port + unset zone_name zone_id zone_dns zone_port ZoneTable ZoneNames fi