From d023c6fb2e7fc674cec8be9dd50455c833aafc93 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Mon, 2 Apr 2012 14:40:41 +0000 Subject: [PATCH] Fix VERBOSE usage (and while at it slightly rework it) From: Michael Prokop --- ngcp-update-db-schema | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ngcp-update-db-schema b/ngcp-update-db-schema index 20c80fdb..11441179 100755 --- a/ngcp-update-db-schema +++ b/ngcp-update-db-schema @@ -1,6 +1,11 @@ #!/bin/bash -VERBOSE=no +# iff executed under VERBOSE=yes provide more information +verbose() { + if [[ "$VERBOSE" == "yes" ]] ; then + echo "$*" + fi +} # do not rely on hostname(1), might return hostname of the # deployment system when initially deploying via chroot @@ -72,10 +77,10 @@ fi running_on_active_node() { if [ -x /usr/sbin/ngcp-check_active ] ; then if /usr/sbin/ngcp-check_active -q ; then - [ "$VERBOSE" != no ] && echo "This seems to be the active node, nothing to do." + verbose "This seems to be the active node, nothing to do." return 0 else - [ "$VERBOSE" != no ] && echo "This seems to be the inactive node, applying revisions." + verbose "This seems to be the inactive node, applying revisions." return 1 fi else @@ -99,7 +104,7 @@ apply_revision() { fi if mysql -usipwise -p${SIPWISE_DB_PASSWORD} ngcp -e "insert into db_schema values (0, '${revname}', \""${hostname}"\", CURRENT_TIMESTAMP);" ; then - [ "$VERBOSE" != no ] && echo "Marked revision $rev as applied." + verbose "Marked revision $rev as applied." else echo "Error while executing DB commands using revision $rev for host $hostname" >&2 exit 1