From 40f7e9b455891224c9d67ba0e4e22e5ad41b43cf Mon Sep 17 00:00:00 2001 From: Philipp Storz Date: Thu, 23 Jan 2020 15:01:19 +0100 Subject: [PATCH] cats scripts: psql: suppress hints when doing database operations --- core/src/cats/create_bareos_database.in | 6 +++--- core/src/cats/drop_bareos_tables.in | 2 +- core/src/cats/grant_bareos_privileges.in | 2 +- core/src/cats/make_bareos_tables.in | 2 +- core/src/cats/update_bareos_tables.in | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/src/cats/create_bareos_database.in b/core/src/cats/create_bareos_database.in index 391bfaf1248..c2f5ef9776b 100755 --- a/core/src/cats/create_bareos_database.in +++ b/core/src/cats/create_bareos_database.in @@ -95,7 +95,7 @@ case ${db_type} in # # use SQL_ASCII to be able to put any filename into # the database even those created with unusual character sets - PSQLVERSION=`psql -d template1 -c 'SELECT version()' $* 2>/dev/null | \ + PSQLVERSION=`PGOPTIONS='--client-min-messages=warning' psql -d template1 -c 'SELECT version()' $* 2>/dev/null | \ awk '/PostgreSQL/ { print $2 }' | \ cut -d '.' -f 1,2` @@ -120,14 +120,14 @@ case ${db_type} in ;; esac - psql -f - -d template1 $* << END-OF-DATA + PGOPTIONS='--client-min-messages=warning' psql -f - -d template1 $* << END-OF-DATA \set ON_ERROR_STOP on CREATE DATABASE ${db_name} $ENCODING TEMPLATE template0; ALTER DATABASE ${db_name} SET datestyle TO 'ISO, YMD'; END-OF-DATA retval=$? - if psql -l ${dbname} $* | grep " ${db_name}.*SQL_ASCII" >/dev/null; then + if PGOPTIONS='--client-min-messages=warning' psql -l ${dbname} $* | grep " ${db_name}.*SQL_ASCII" >/dev/null; then echo "Database encoding OK" else echo " " diff --git a/core/src/cats/drop_bareos_tables.in b/core/src/cats/drop_bareos_tables.in index 2a0c0d2d793..6cb91a37a8b 100755 --- a/core/src/cats/drop_bareos_tables.in +++ b/core/src/cats/drop_bareos_tables.in @@ -123,7 +123,7 @@ case ${db_type} in fi ;; postgresql) - psql -f ${temp_sql_schema} -d ${db_name} $* + PGOPTIONS='--client-min-messages=warning' psql -f ${temp_sql_schema} -d ${db_name} $* retval=$? if test $retval = 0; then diff --git a/core/src/cats/grant_bareos_privileges.in b/core/src/cats/grant_bareos_privileges.in index 0768d97dcea..2d745b17d54 100755 --- a/core/src/cats/grant_bareos_privileges.in +++ b/core/src/cats/grant_bareos_privileges.in @@ -99,7 +99,7 @@ case ${db_type} in retval=$? ;; postgresql) - psql -f ${temp_sql_grants} -d ${db_name} $* + PGOPTIONS='--client-min-messages=warning' psql -f ${temp_sql_grants} -d ${db_name} $* retval=$? ;; diff --git a/core/src/cats/make_bareos_tables.in b/core/src/cats/make_bareos_tables.in index 99f61f40643..318884f0a44 100755 --- a/core/src/cats/make_bareos_tables.in +++ b/core/src/cats/make_bareos_tables.in @@ -124,7 +124,7 @@ case ${db_type} in fi ;; postgresql) - psql -f ${temp_sql_schema} -d ${db_name} $* + PGOPTIONS='--client-min-messages=warning' psql -f ${temp_sql_schema} -d ${db_name} $* retval=$? if test $retval = 0; then echo "Creation of Bareos PostgreSQL tables succeeded." diff --git a/core/src/cats/update_bareos_tables.in b/core/src/cats/update_bareos_tables.in index 870a4b0784b..c000568ce8e 100755 --- a/core/src/cats/update_bareos_tables.in +++ b/core/src/cats/update_bareos_tables.in @@ -94,7 +94,7 @@ do sed -n -e 's/^.*VersionId.*: \(.*\)$/\1/p'` ;; postgresql) - DBVERSION=`psql -d ${db_name} -t --pset format=unaligned -c "SELECT MAX(VersionId) FROM Version;" $*` + DBVERSION=`PGOPTIONS='--client-min-messages=warning' psql -d ${db_name} -t --pset format=unaligned -c "SELECT MAX(VersionId) FROM Version;" $*` ;; *) echo "Unknown database type ${db_type}" @@ -168,15 +168,15 @@ do retval=$? ;; postgresql) - psql -f ${temp_sql_schema} -d ${db_name} $* + PGOPTIONS='--client-min-messages=warning' -f ${temp_sql_schema} -d ${db_name} $* retval=$? if [ $retval -eq 0 ] && [ ${end_version} -eq 2192 ]; then - PGSQLVERSION=`psql -d template1 -c 'SELECT version()' $* 2>/dev/null | \ + PGSQLVERSION=`PGOPTIONS='--client-min-messages=warning' -d template1 -c 'SELECT version()' $* 2>/dev/null | \ awk '/PostgreSQL/ { print $2 }' | \ cut -d '.' -f 1,2` case ${PGSQLVERSION} in 10.*|11.*|12.*) - psql -d ${db_name} -c 'ALTER SEQUENCE basefiles_baseid_seq AS BIGINT' + PGOPTIONS='--client-min-messages=warning' -d ${db_name} -c 'ALTER SEQUENCE basefiles_baseid_seq AS BIGINT' result=$? if [ $result -ne 0 ]; then echo "WARNING: Failed to update sequence basefiles_baseid_seq"