Skip to content

Instantly share code, notes, and snippets.

@disafronov
Created April 28, 2025 08:30
Show Gist options
  • Save disafronov/081e2f90ca49f46a6d8efe0d31f66f95 to your computer and use it in GitHub Desktop.
Save disafronov/081e2f90ca49f46a6d8efe0d31f66f95 to your computer and use it in GitHub Desktop.
Proxmox DHCP watchdog
#!/usr/bin/env bash
restore_dhcp() {
if [ -n "$(grep 'iface vmbr0 inet static' /etc/network/interfaces)" ]; then
sed -e 's|iface\ vmbr0\ inet\ static|iface\ vmbr0\ inet\ dhcp|g' -i /etc/network/interfaces
fi
}
restore_dhcp
inotifywait -e close_write,moved_to,create -m /etc/network |
while read -r directory events filename; do
if [ "$filename" = "interfaces" ]; then
restore_dhcp
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment