Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/command/with-contenv-merge bashio
# shellcheck shell=bash
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

# 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
Comment thread
lmagyar marked this conversation as resolved.
# Better stop app than risking losing all network connections
halt-app
fi
fi
;;
connectivity-change)
bashio::log.debug "Unhandled Network Manager action ${NM_DISPATCHER_ACTION} ${CONNECTIVITY_STATE-}"
;;
*)
bashio::log.debug "Unhandled Network Manager action ${DEVICE_IP_IFACE-} ${NM_DISPATCHER_ACTION}"
;;
esac
44 changes: 0 additions & 44 deletions tailscale/rootfs/etc/NetworkManager/dispatcher.d/protect-subnets

This file was deleted.

Loading