Files
pvedhcp/pve-netconfig-watch.sh
2026-09-10 13:10:19 +00:00

23 lines
555 B
Bash

#!/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