From 388690b1a6e1c24552ea0ca2b0616ee22e70bc9a Mon Sep 17 00:00:00 2001 From: SDE Informatique <1+sde@noreply.localhost> Date: Thu, 10 Sep 2026 13:10:19 +0000 Subject: [PATCH] Ajouter pve-netconfig-watch.sh --- pve-netconfig-watch.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 pve-netconfig-watch.sh 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