#!/bin/sh # Rouse the host when this machine's network changes. # # Installed as a NetworkManager dispatcher script (/etc/NetworkManager/dispatcher.d) and as a # networkd-dispatcher one. Both hand the interface and the event as arguments; both are ignored # beyond the event, because *which* interface changed does not matter — what matters is that a # connection opened over the old route is now pointing at nothing, and that is true whichever # interface it was. # # A machine that moves from wifi to ethernet holds a socket that looks perfectly healthy from # inside the process: no error, no close, because nothing has tried to send anything. Heartbeats # find it twenty or thirty seconds later. The machine knew immediately. set -eu event="${2:-}" case "$event" in up|dhcp4-change|dhcp6-change|connectivity-change|routes-change) # Only events that can change where packets go. `down` is deliberately not one: the link is # already gone, reconnecting will fail, and the backoff exists for exactly that. systemctl start --no-block nox-mesh-host-roused.service 2>/dev/null || true ;; esac