From 76b410bf38132c6f0bd8a7e31206d604f9ea6717 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 1 Sep 2016 13:48:15 +0200 Subject: cfg-add-nics: this script only modifies config.rc if needed This one runs check-new-if and only updates config.rc if anything new was detected. This avoids touching the file for no reason, and will not cause issues with save-etc. --- cfg-add-nics | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 cfg-add-nics diff --git a/cfg-add-nics b/cfg-add-nics new file mode 100755 index 0000000..c53eb0e --- /dev/null +++ b/cfg-add-nics @@ -0,0 +1,15 @@ +#!/bin/bash + +[ -x /sbin/check-new-if ] || exit 0 + +TMP=$(mktemp -q) +[ -e "$TMP" ] || exit 1 + +echo "Checking for new network interfaces." +if /sbin/check-new-if >> "$TMP" && + ! cmp -s /etc/config.rc "$TMP"; then + echo "Updating configuration." + cat "$TMP" > /etc/config.rc +fi +rm -f "$TMP" +exit 0 -- 1.7.12.1