From 7c49d9b8b8b1224edcd7069d3e3e8ad3bf27d3d6 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 30 Apr 2023 14:46:27 +0200 Subject: scripts/restore-etc: make diff fail if flash cannot be read Issuing "config diff" when the flash is already mounted results in a full diff being displayed instead of the mount error message. Let's make sure we can abort in such a case. If the user wants to check what has changed from the rom, they can issue "config diff factory" instead. --- scripts/restore-etc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/restore-etc b/scripts/restore-etc index f6db32f..9645690 100755 --- a/scripts/restore-etc +++ b/scripts/restore-etc @@ -316,6 +316,11 @@ if [ $DIFF -eq 1 ]; then exit 1 fi restore_config + if [ $? -ne 0 ]; then + echo "Cannot load the current config from the flash." >&2 + [ -n "$ROOTDIR" -a "$ROOTDIR" != "/" ] && rm -rf "$ROOTDIR" + exit 1 + fi flx check --ignore-dot --ignore-link --ignore-date "$ROOTDIR"/etc=etc /etc=etc \ | awk '/^. [^d]/ { print $9 }' | sort -u \ -- 2.35.3