From 666141d07fef0bcda59a87a358d96c5515898f05 Mon Sep 17 00:00:00 2001 From: Laszlo Magyar Date: Sun, 3 May 2026 20:33:17 +0200 Subject: [PATCH 1/6] Refactor slow activities from nm-dispatcher script into separate listener service --- .../dispatcher.d/protect-subnets | 31 +++-------- .../dependencies.d/local-network | 0 .../s6-rc.d/init-protect-subnets/down | 1 + .../s6-rc.d/init-protect-subnets/finish | 9 +++ .../s6-rc.d/init-protect-subnets/run | 9 +++ .../s6-rc.d/init-protect-subnets/type | 1 + .../s6-rc.d/init-protect-subnets/up | 1 + .../dependencies.d/init-protect-subnets | 0 .../s6-rc.d/nm-dispatcher-listener/finish | 32 +++++++++++ .../s6-rc.d/nm-dispatcher-listener/run | 55 +++++++++++++++++++ .../s6-rc.d/nm-dispatcher-listener/type | 1 + .../dependencies.d/nm-dispatcher-listener | 0 .../{protect-subnets => nm-dispatcher}/finish | 6 +- .../{protect-subnets => nm-dispatcher}/run | 4 +- .../etc/s6-overlay/s6-rc.d/nm-dispatcher/type | 1 + .../contents.d/init-protect-subnets | 0 .../protect-subnets/contents.d/nm-dispatcher | 0 .../contents.d/nm-dispatcher-listener | 0 .../s6-overlay/s6-rc.d/protect-subnets/type | 2 +- 19 files changed, 122 insertions(+), 31 deletions(-) rename tailscale/rootfs/etc/s6-overlay/s6-rc.d/{protect-subnets => init-protect-subnets}/dependencies.d/local-network (100%) create mode 100644 tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/down create mode 100755 tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/finish create mode 100755 tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/run create mode 100644 tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/type create mode 100644 tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/up create mode 100644 tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/dependencies.d/init-protect-subnets create mode 100755 tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/finish create mode 100755 tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/run create mode 100644 tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/type create mode 100644 tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/dependencies.d/nm-dispatcher-listener rename tailscale/rootfs/etc/s6-overlay/s6-rc.d/{protect-subnets => nm-dispatcher}/finish (89%) rename tailscale/rootfs/etc/s6-overlay/s6-rc.d/{protect-subnets => nm-dispatcher}/run (84%) create mode 100644 tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/type create mode 100644 tailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/contents.d/init-protect-subnets create mode 100644 tailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/contents.d/nm-dispatcher create mode 100644 tailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/contents.d/nm-dispatcher-listener diff --git a/tailscale/rootfs/etc/NetworkManager/dispatcher.d/protect-subnets b/tailscale/rootfs/etc/NetworkManager/dispatcher.d/protect-subnets index 3c14671d2..c54d5ce50 100755 --- a/tailscale/rootfs/etc/NetworkManager/dispatcher.d/protect-subnets +++ b/tailscale/rootfs/etc/NetworkManager/dispatcher.d/protect-subnets @@ -3,36 +3,21 @@ export LOG_FD # The shebang 'with-contenv-merge' above is identical with 'with-contenv', but doesn't clear the current environment containing the dispatcher variables +readonly NM_DISPATCHER_LISTENER_QUEUE=/run/nm-dispatcher-listener-queue + # Redirect outputs to the log (&2 is already set up as pipe by s6) exec 1>&2 if [[ "${LOG_FD:-}" =~ ^[0-9]+$ ]]; then eval "exec ${LOG_FD}>&1" || true fi -function halt-app() { - bashio::log.error "Failed to protect subnet routes. Halting app to prevent network loss." - echo -n 1 > /run/s6-linux-init-container-results/exitcode - exec /run/s6/basedir/bin/halt -} - case "${NM_DISPATCHER_ACTION}" in - up|down) - bashio::log.info "Handling Network Manager action ${DEVICE_IP_IFACE-} ${NM_DISPATCHER_ACTION}" - unprotect-subnet-routes - if ! protect-subnet-routes; then - # Better stop app than risking losing all network connections - halt-app - fi - ;; - dhcp4-change|dhcp6-change) - # Do anything only when the addresses are really changed - if [[ "$(unprotect-subnet-routes test)" != "$(protect-subnet-routes test)" ]]; then - bashio::log.info "Handling Network Manager action ${DEVICE_IP_IFACE-} ${NM_DISPATCHER_ACTION}" - unprotect-subnet-routes - if ! protect-subnet-routes tested; then - # Better stop app than risking losing all network connections - halt-app - fi + up|down|dhcp4-change|dhcp6-change) + bashio::log.debug "Receiving Network Manager action ${DEVICE_IP_IFACE-} ${NM_DISPATCHER_ACTION}" + if ! echo "${DEVICE_IP_IFACE-} ${NM_DISPATCHER_ACTION}" > "${NM_DISPATCHER_LISTENER_QUEUE}"; then + bashio::log.fatal "Failed to send nm-dispatcher action to listener. Halting app to prevent network loss." + echo -n 1 > /run/s6-linux-init-container-results/exitcode + exec /run/s6/basedir/bin/halt fi ;; connectivity-change) diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/dependencies.d/local-network b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/dependencies.d/local-network similarity index 100% rename from tailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/dependencies.d/local-network rename to tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/dependencies.d/local-network diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/down b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/down new file mode 100644 index 000000000..5a86836db --- /dev/null +++ b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/down @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-protect-subnets/finish diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/finish b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/finish new file mode 100755 index 000000000..c36ff3296 --- /dev/null +++ b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/finish @@ -0,0 +1,9 @@ +#!/command/with-contenv bashio +# shellcheck shell=bash +export LOG_FD +# ============================================================================== +# Home Assistant Community App: Tailscale +# Remove subnet protection +# ============================================================================== + +unprotect-subnet-routes diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/run b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/run new file mode 100755 index 000000000..713a27b62 --- /dev/null +++ b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/run @@ -0,0 +1,9 @@ +#!/command/with-contenv bashio +# shellcheck shell=bash +export LOG_FD +# ============================================================================== +# Home Assistant Community App: Tailscale +# Prevent local subnets to be routed toward the tailnet +# ============================================================================== + +protect-subnet-routes diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/type b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/type new file mode 100644 index 000000000..bdd22a185 --- /dev/null +++ b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/type @@ -0,0 +1 @@ +oneshot diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/up b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/up new file mode 100644 index 000000000..854fa8af2 --- /dev/null +++ b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-protect-subnets/run diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/dependencies.d/init-protect-subnets b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/dependencies.d/init-protect-subnets new file mode 100644 index 000000000..e69de29bb diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/finish b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/finish new file mode 100755 index 000000000..018fd3df7 --- /dev/null +++ b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/finish @@ -0,0 +1,32 @@ +#!/command/with-contenv bashio +# shellcheck shell=bash +export LOG_FD +# ============================================================================== +# Home Assistant Community App: Tailscale +# Take down the S6 supervision tree when nm-dispatcher-listener fails +# ============================================================================== +readonly exit_code_container=$(&- +rm -rf "${NM_DISPATCHER_LISTENER_QUEUE}" + +bashio::log.info \ + "Service ${service} exited with code ${exit_code_service}" \ + "(by signal ${exit_code_signal})" + +if [[ "${exit_code_service}" -eq 256 ]]; then + if [[ "${exit_code_container}" -eq 0 ]]; then + echo $((128 + $exit_code_signal)) > /run/s6-linux-init-container-results/exitcode + fi + [[ "${exit_code_signal}" -eq 15 ]] && exec /run/s6/basedir/bin/halt +elif [[ "${exit_code_service}" -ne 0 ]]; then + if [[ "${exit_code_container}" -eq 0 ]]; then + echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode + fi + exec /run/s6/basedir/bin/halt +fi diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/run b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/run new file mode 100755 index 000000000..51033537c --- /dev/null +++ b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/run @@ -0,0 +1,55 @@ +#!/command/with-contenv bashio +# shellcheck shell=bash +export LOG_FD +# ============================================================================== +# Home Assistant Community App: Tailscale +# Runs the nm-dispatcher-listener service +# ============================================================================== + +readonly NM_DISPATCHER_LISTENER_QUEUE=/run/nm-dispatcher-listener-queue + +declare action +declare subnet_routes_to_unprotect +declare subnet_routes_to_protect + +function try { + set +e + (set -e; "$@") + declare -gx TRY_ERROR=$? + set -e +} + +mkfifo "${NM_DISPATCHER_LISTENER_QUEUE}" + +# Pin it to prevent closing it by other processes +exec 4<>"${NM_DISPATCHER_LISTENER_QUEUE}" + +while IFS= read -r -u 4 action +do + case "${action}" in + *up|*down) + bashio::log.info "Handling Network Manager action ${action}" + unprotect-subnet-routes + try protect-subnet-routes + if ((TRY_ERROR)); then + bashio::exit.nok "Failed to protect subnet routes. Halting app to prevent network loss." + fi + ;; + *dhcp4-change|*dhcp6-change) + # Do anything only when the addresses are really changed + subnet_routes_to_unprotect="$(unprotect-subnet-routes test)" + subnet_routes_to_protect="$(protect-subnet-routes test)" + if ! bashio::var.equals "${subnet_routes_to_unprotect}" "${subnet_routes_to_protect}"; then + bashio::log.info "Handling Network Manager action ${action}" + unprotect-subnet-routes + try protect-subnet-routes tested + if ((TRY_ERROR)); then + bashio::exit.nok "Failed to protect subnet routes. Halting app to prevent network loss." + fi + fi + ;; + *) + bashio::exit.nok "Unknown Network Manager action ${action}" + ;; + esac +done diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/type b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/type new file mode 100644 index 000000000..5883cff0c --- /dev/null +++ b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/type @@ -0,0 +1 @@ +longrun diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/dependencies.d/nm-dispatcher-listener b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/dependencies.d/nm-dispatcher-listener new file mode 100644 index 000000000..e69de29bb diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/finish b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/finish similarity index 89% rename from tailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/finish rename to tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/finish index cbc296213..701d34c51 100755 --- a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/finish +++ b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/finish @@ -3,14 +3,12 @@ export LOG_FD # ============================================================================== # Home Assistant Community App: Tailscale -# Take down the S6 supervision tree when protect-subnets fails +# Take down the S6 supervision tree when nm-dispatcher fails # ============================================================================== readonly exit_code_container=$( /dev/null diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/type b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/type new file mode 100644 index 000000000..5883cff0c --- /dev/null +++ b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/type @@ -0,0 +1 @@ +longrun diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/contents.d/init-protect-subnets b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/contents.d/init-protect-subnets new file mode 100644 index 000000000..e69de29bb diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/contents.d/nm-dispatcher b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/contents.d/nm-dispatcher new file mode 100644 index 000000000..e69de29bb diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/contents.d/nm-dispatcher-listener b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/contents.d/nm-dispatcher-listener new file mode 100644 index 000000000..e69de29bb diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/type b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/type index 5883cff0c..757b42211 100644 --- a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/type +++ b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/type @@ -1 +1 @@ -longrun +bundle From 52a3525e92109c16a933572253cb37839829448d Mon Sep 17 00:00:00 2001 From: Laszlo Magyar Date: Sun, 3 May 2026 21:22:22 +0200 Subject: [PATCH 2/6] delay the starting of the dependent services until listener queue is created --- .../s6-overlay/s6-rc.d/nm-dispatcher-listener/notification-fd | 1 + .../rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/run | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/notification-fd diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/notification-fd b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/notification-fd new file mode 100644 index 000000000..00750edc0 --- /dev/null +++ b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/notification-fd @@ -0,0 +1 @@ +3 diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/run b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/run index 51033537c..69694a0c7 100755 --- a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/run +++ b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/run @@ -24,6 +24,10 @@ mkfifo "${NM_DISPATCHER_LISTENER_QUEUE}" # Pin it to prevent closing it by other processes exec 4<>"${NM_DISPATCHER_LISTENER_QUEUE}" +# We need to delay the starting of the dependent services until listener queue is created +echo "" >&3 +exec 3>&- + while IFS= read -r -u 4 action do case "${action}" in From 357b422a564f70ea8edcd0f6b7d230f9eaa76a79 Mon Sep 17 00:00:00 2001 From: Laszlo Magyar Date: Sun, 3 May 2026 22:21:10 +0200 Subject: [PATCH 3/6] fine tune log mesage --- .../rootfs/etc/NetworkManager/dispatcher.d/protect-subnets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tailscale/rootfs/etc/NetworkManager/dispatcher.d/protect-subnets b/tailscale/rootfs/etc/NetworkManager/dispatcher.d/protect-subnets index c54d5ce50..66779d913 100755 --- a/tailscale/rootfs/etc/NetworkManager/dispatcher.d/protect-subnets +++ b/tailscale/rootfs/etc/NetworkManager/dispatcher.d/protect-subnets @@ -13,7 +13,7 @@ fi case "${NM_DISPATCHER_ACTION}" in up|down|dhcp4-change|dhcp6-change) - bashio::log.debug "Receiving Network Manager action ${DEVICE_IP_IFACE-} ${NM_DISPATCHER_ACTION}" + bashio::log.debug "Received Network Manager action ${DEVICE_IP_IFACE-} ${NM_DISPATCHER_ACTION}" if ! echo "${DEVICE_IP_IFACE-} ${NM_DISPATCHER_ACTION}" > "${NM_DISPATCHER_LISTENER_QUEUE}"; then bashio::log.fatal "Failed to send nm-dispatcher action to listener. Halting app to prevent network loss." echo -n 1 > /run/s6-linux-init-container-results/exitcode From 76935e7b45a5e1e186a50c2aad0f587b27c69a09 Mon Sep 17 00:00:00 2001 From: Laszlo Magyar Date: Wed, 17 Jun 2026 01:25:39 +0200 Subject: [PATCH 4/6] Graceful shutdown on SIGTERM caused by manual app stop --- .../rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/finish | 2 +- tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/finish | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/finish b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/finish index 018fd3df7..5d57033cc 100755 --- a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/finish +++ b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/finish @@ -20,7 +20,7 @@ bashio::log.info \ "(by signal ${exit_code_signal})" if [[ "${exit_code_service}" -eq 256 ]]; then - if [[ "${exit_code_container}" -eq 0 ]]; then + if [[ "${exit_code_signal}" -ne 15 && "${exit_code_container}" -eq 0 ]]; then echo $((128 + $exit_code_signal)) > /run/s6-linux-init-container-results/exitcode fi [[ "${exit_code_signal}" -eq 15 ]] && exec /run/s6/basedir/bin/halt diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/finish b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/finish index 701d34c51..c72c83493 100755 --- a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/finish +++ b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/finish @@ -15,7 +15,7 @@ bashio::log.info \ "(by signal ${exit_code_signal})" if [[ "${exit_code_service}" -eq 256 ]]; then - if [[ "${exit_code_container}" -eq 0 ]]; then + if [[ "${exit_code_signal}" -ne 15 && "${exit_code_container}" -eq 0 ]]; then echo $((128 + $exit_code_signal)) > /run/s6-linux-init-container-results/exitcode fi [[ "${exit_code_signal}" -eq 15 ]] && exec /run/s6/basedir/bin/halt From d9efe406b47bf50cf8833d87c2a50473ceeda72b Mon Sep 17 00:00:00 2001 From: Laszlo Magyar Date: Tue, 4 Aug 2026 23:28:23 +0200 Subject: [PATCH 5/6] use bashio::log.reinitialize_output --- .../etc/NetworkManager/dispatcher.d/protect-subnets | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tailscale/rootfs/etc/NetworkManager/dispatcher.d/protect-subnets b/tailscale/rootfs/etc/NetworkManager/dispatcher.d/protect-subnets index 66779d913..1e7e707b5 100755 --- a/tailscale/rootfs/etc/NetworkManager/dispatcher.d/protect-subnets +++ b/tailscale/rootfs/etc/NetworkManager/dispatcher.d/protect-subnets @@ -5,11 +5,9 @@ export LOG_FD readonly NM_DISPATCHER_LISTENER_QUEUE=/run/nm-dispatcher-listener-queue -# Redirect outputs to the log (&2 is already set up as pipe by s6) -exec 1>&2 -if [[ "${LOG_FD:-}" =~ ^[0-9]+$ ]]; then - eval "exec ${LOG_FD}>&1" || true -fi +# Redirect outputs to the log (though &2 is already set up as pipe by s6) +exec &> /proc/1/fd/1 +bashio::log.reinitialize_output case "${NM_DISPATCHER_ACTION}" in up|down|dhcp4-change|dhcp6-change) From 88ed8b62f4135f1a4cae03ac62f166fa0009a08d Mon Sep 17 00:00:00 2001 From: Laszlo Magyar Date: Mon, 13 Apr 2026 13:28:39 +0200 Subject: [PATCH 6/6] use bashio::try --- .../s6-overlay/s6-rc.d/nm-dispatcher-listener/run | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/run b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/run index 69694a0c7..4d7d26154 100755 --- a/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/run +++ b/tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/run @@ -12,13 +12,6 @@ declare action declare subnet_routes_to_unprotect declare subnet_routes_to_protect -function try { - set +e - (set -e; "$@") - declare -gx TRY_ERROR=$? - set -e -} - mkfifo "${NM_DISPATCHER_LISTENER_QUEUE}" # Pin it to prevent closing it by other processes @@ -34,8 +27,8 @@ do *up|*down) bashio::log.info "Handling Network Manager action ${action}" unprotect-subnet-routes - try protect-subnet-routes - if ((TRY_ERROR)); then + bashio::try protect-subnet-routes + if bashio::try.failed; then bashio::exit.nok "Failed to protect subnet routes. Halting app to prevent network loss." fi ;; @@ -46,8 +39,8 @@ do if ! bashio::var.equals "${subnet_routes_to_unprotect}" "${subnet_routes_to_protect}"; then bashio::log.info "Handling Network Manager action ${action}" unprotect-subnet-routes - try protect-subnet-routes tested - if ((TRY_ERROR)); then + bashio::try protect-subnet-routes tested + if bashio::try.failed; then bashio::exit.nok "Failed to protect subnet routes. Halting app to prevent network loss." fi fi