From d0b2f2fc16557ca1ae856cca885da4b6f47a9b94 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Tue, 21 Jan 2014 02:41:08 +0000 Subject: renew-config: more convenience if clients.xml differs If the copy of clients.xml in the repo differs from the real version used by bcfg2 display a nice diff and show the cmd that could be used to update the file. --- renew-config | 9 +++++++-- settings.sh | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/renew-config b/renew-config index fbd05c7..6b4a24c 100755 --- a/renew-config +++ b/renew-config @@ -14,8 +14,13 @@ git fetch origin 2>/dev/null git push origin master 2>/dev/null if ! diff -q "$REPO/Metadata/clients.xml" "$REAL/Metadata/clients.xml" >/dev/null; then - error "$REPO: Metadata/clients.xml out of date. -You probably should update it with $REAL/Metadata/clients.xml" + echo "$REPO: Metadata/clients.xml out of date." 1>&2 + echo "You probably should update it with $REAL/Metadata/clients.xml" 1>&2 + echo 1>&2 + $DIFF -u "$REPO/Metadata/clients.xml" "$REAL/Metadata/clients.xml" 1>&2 + echo 1>&2 + echo "Maybe you want:" 1>&2 + error "cp -i '$REAL/Metadata/clients.xml' '$REPO/Metadata/clients.xml'" fi if [ -n "$(git rev-list HEAD..origin/master)" ]; then diff --git a/settings.sh b/settings.sh index e954101..48699a8 100644 --- a/settings.sh +++ b/settings.sh @@ -3,6 +3,11 @@ REAL="/var/lib/bcfg2" OLDPWD="$(pwd)" BINDIR="$( cd -P "$( dirname -- "$0" )" >/dev/null && pwd )" +DIFF=diff +if hash colordiff >/dev/null 2>&1; then + DIFF=colordiff +fi + error() { echo "$@" 1>&2 cd "$OLDPWD" >/dev/null -- cgit v1.2.3-1-g7c22