diff --git a/pve-netconfig-watch.sh b/pve-netconfig-watch.sh new file mode 100644 index 0000000..ca65da3 --- /dev/null +++ b/pve-netconfig-watch.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Surveille les événements netlink et déclenche la synchronisation /etc/hosts +set -u + +SCRIPT="/usr/local/sbin/pve-netconfig.sh" +DEBOUNCE=15 # secondes d'anti-rebond + +last_run=0 + +ip -4 monitor address | while read -r line; do + case "$line" in + *vmbr0*|*vmbr1*) ;; + *) continue ;; + esac + now=$(date +%s) + if (( now - last_run < DEBOUNCE )); then + continue + fi + last_run=$now + sleep "$DEBOUNCE" + logger -t pve-netconfig-watch "Changement d'adresse détecté : $line" + "$SCRIPT" sync-hosts +done \ No newline at end of file