]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/create_postgresql_database.in
Big backport from Enterprise
[bacula/bacula] / bacula / src / cats / create_postgresql_database.in
index a9fe0930d1aab30012d0250946f833007b7b530c..ac15d524e822a2658b3c8018b5c310ddd8e1d637 100644 (file)
@@ -1,5 +1,8 @@
 #!/bin/sh
 #
+# Copyright (C) 2000-2017 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
 # shell script to create Bacula database(s)
 #
 
@@ -10,7 +13,7 @@ db_name=${db_name:-@db_name@}
 # 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()' | awk '/PostgreSQL/ {print $2}' | cut -d '.' -f 1,2`
+PSQLVERSION=`psql -d template1 -c 'select version()' $* | awk '/PostgreSQL/ {print $2}' | cut -d '.' -f 1,2`
 
 #
 # Note, LC_COLLATE and LC_TYPE are needed on 8.4 and beyond, but are
@@ -51,11 +54,13 @@ else
    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    echo "!!!! Creation of ${db_name} database failed. !!!!"
    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+   exit 1
 fi
-if psql -l ${dbname} | grep " ${db_name}.*SQL_ASCII" >/dev/null; then 
+if psql -l | grep " ${db_name}.*SQL_ASCII" >/dev/null; then 
    echo "Database encoding OK"
 else
    echo " "
    echo "Database encoding bad. Do not use this database"
    echo " "
+   exit 1
 fi