X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fcats%2Fcreate_postgresql_database.in;h=deff1017c5ef9ba381812005762cee54144ee48b;hb=9a00193e3365f782493e66c97173ef1459a99142;hp=2d9e43f3d0727aceb8f565196bbd7c196e485b6c;hpb=49f732e9a5d77f59f1560b32cd5f1298709f21ba;p=bacula%2Fbacula diff --git a/bacula/src/cats/create_postgresql_database.in b/bacula/src/cats/create_postgresql_database.in index 2d9e43f3d0..deff1017c5 100644 --- a/bacula/src/cats/create_postgresql_database.in +++ b/bacula/src/cats/create_postgresql_database.in @@ -1,16 +1,63 @@ #!/bin/sh # +# Copyright (C) 2000-2017 Kern Sibbald +# License: BSD 2-Clause; see file LICENSE-FOSS +# # shell script to create Bacula database(s) # -bindir=@SQL_BINDIR@ +PATH="@POSTGRESQL_BINDIR@:$PATH" +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` + +# +# Note, LC_COLLATE and LC_TYPE are needed on 8.4 and beyond, but are +# not implemented in 8.3 or below. +# This must be updated for future versions of PostgreSQL +# +case ${PSQLVERSION} in + 8.[456789] | 9.* | 10.*) + ENCODING="ENCODING 'SQL_ASCII' LC_COLLATE 'C' LC_CTYPE 'C'" + ;; + *) + ENCODING="ENCODING 'SQL_ASCII'" + ;; +esac + + -if $bindir/psql $* -f - </dev/null; then + echo "Database encoding OK" else - echo "Creation of bacula database failed." + echo " " + echo "Database encoding bad. Do not use this database" + echo " " + exit 1 fi -exit 0