From 031c3cf7f613abe08aaa4b632082303b903f65c6 Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Sun, 10 Nov 2024 18:15:59 +0100 Subject: [PATCH] move adsb.lol station map check out of interpret_ultrafeeder_config this script is sourced by multiple scripts and we only need to do show the station map URL once also curl has long maximum timeouts which can block important services from starting up if there is an issue with adsb.lol or the network / DNS --- .../aggregator-urls/dependencies.d/startup | 0 .../s6-overlay/s6-rc.d/aggregator-urls/run | 2 ++ .../s6-overlay/s6-rc.d/aggregator-urls/type | 1 + .../s6-rc.d/user/contents.d/aggregator-urls | 0 rootfs/etc/s6-overlay/scripts/aggregator-urls | 34 +++++++++++++++++++ rootfs/scripts/interpret_ultrafeeder_config | 8 ----- 6 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/aggregator-urls/dependencies.d/startup create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/aggregator-urls/run create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/aggregator-urls/type create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/aggregator-urls create mode 100755 rootfs/etc/s6-overlay/scripts/aggregator-urls diff --git a/rootfs/etc/s6-overlay/s6-rc.d/aggregator-urls/dependencies.d/startup b/rootfs/etc/s6-overlay/s6-rc.d/aggregator-urls/dependencies.d/startup new file mode 100644 index 0000000..e69de29 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/aggregator-urls/run b/rootfs/etc/s6-overlay/s6-rc.d/aggregator-urls/run new file mode 100755 index 0000000..93b5eb4 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/aggregator-urls/run @@ -0,0 +1,2 @@ +#!/bin/sh +exec /etc/s6-overlay/scripts/aggregator-urls diff --git a/rootfs/etc/s6-overlay/s6-rc.d/aggregator-urls/type b/rootfs/etc/s6-overlay/s6-rc.d/aggregator-urls/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/aggregator-urls/type @@ -0,0 +1 @@ +longrun diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/aggregator-urls b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/aggregator-urls new file mode 100644 index 0000000..e69de29 diff --git a/rootfs/etc/s6-overlay/scripts/aggregator-urls b/rootfs/etc/s6-overlay/scripts/aggregator-urls new file mode 100755 index 0000000..828dbf3 --- /dev/null +++ b/rootfs/etc/s6-overlay/scripts/aggregator-urls @@ -0,0 +1,34 @@ +#!/command/with-contenv bash +# shellcheck shell=bash disable=SC2015,SC2016,SC1091 + +#--------------------------------------------------------------------------------------------- +# 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 . +#--------------------------------------------------------------------------------------------- + +source /scripts/common +source /scripts/interpret_ultrafeeder_config + +# wait 30 seconds for connections to be established +sleep 30 + +if [[ "${READSB_CONF_ARR[*]}" =~ "in.adsb.lol" ]]; then + myadsblol="$(curl -sLD - https://my.adsb.lol -o /dev/null -w '%{url_effective}' 2>&1 | sed '/location: /h;g;$!d;s/^.* \(.*\)$/\1/')" + if [[ -n "$myadsblol" ]] && [[ ! $myadsblol =~ sorry-but-i-could-not-find-your-receiver ]]; then + "${s6wrap[@]}" echo "ADSB.LOL station map available at $myadsblol" + fi +fi + +# one shots have weird behaviour, just use longrun and stop the service once this is done +stop_service diff --git a/rootfs/scripts/interpret_ultrafeeder_config b/rootfs/scripts/interpret_ultrafeeder_config index 00f09a8..2495fd2 100755 --- a/rootfs/scripts/interpret_ultrafeeder_config +++ b/rootfs/scripts/interpret_ultrafeeder_config @@ -97,14 +97,6 @@ do done # Now add $readsb_str to the READSB_CONF_ARR() as --net-connector argument: READSB_CONF_ARR+=("--net-connector=${readsb_str}") - - if [[ ${param[1],,} == "in.adsb.lol" ]]; then - myadsblol="$(curl -sLD - https://my.adsb.lol -o /dev/null -w '%{url_effective}' 2>&1 | sed '/location: /h;g;$!d;s/^.* \(.*\)$/\1/')" - if [[ -n "$myadsblol" ]] && [[ ! $myadsblol =~ sorry-but-i-could-not-find-your-receiver ]]; then - "${s6wrap[@]}" echo "ADSB.LOL station map available at $myadsblol" - fi - fi - ;; mlat)