X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fcats%2Fcreate_postgresql_database.in;h=50fe6c4bf06509f58f9f35e7d8af706f51ba1d80;hb=fb71554fa28e81b6125c2063e028976df18334f2;hp=152eab8e416d2ac10cf8d7025f4d14f57542536f;hpb=f3414c1960d117a7e664b27007ff906ea71ecf9c;p=bacula%2Fbacula diff --git a/bacula/src/cats/create_postgresql_database.in b/bacula/src/cats/create_postgresql_database.in index 152eab8e41..50fe6c4bf0 100644 --- a/bacula/src/cats/create_postgresql_database.in +++ b/bacula/src/cats/create_postgresql_database.in @@ -3,34 +3,59 @@ # shell script to create Bacula database(s) # -bindir=@SQL_BINDIR@ -db_name=@db_name@ +PATH="@SQL_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 -ENCODING="ENCODING 'SQL_ASCII'" - -# use UTF8 if you are using standard Unix/Linux LANG specifications -# that use UTF8 -- this is normally the default and *should* be -# your standard. Bacula works correctly *only* with correct UTF8. + +PSQLVERSION=`psql -d template1 -c 'select version()' | awk '/PostgreSQL/ {print $2}' | cut -d '.' -f 1,2` + # -# Note, with this encoding, if you have any "weird" filenames on -# your system (names generated from Win32 or Mac OS), you may -# get Bacula batch insert failures. +# 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 # -#ENCODING="ENCODING 'UTF8'" - +case ${PSQLVERSION} in + "9.*") + ENCODING="ENCODING 'SQL_ASCII' LC_COLLATE 'C' LC_CTYPE 'C'" + ;; + "8.[456789]") + ENCODING="ENCODING 'SQL_ASCII' LC_COLLATE 'C' LC_CTYPE 'C'" + ;; + *) + ENCODING="ENCODING 'SQL_ASCII'" + ;; +esac + + + +# +# Please note: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +# We do not recommend that you use ENCODING 'SQL_UTF8' +# It can result in creating filenames in the database that +# cannot be seen or restored. +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # -# KES: Note: the CREATE DATABASE, probably should be -# CREATE DATABASE ${db_name} $ENCODING TEMPLATE template0 # -if $bindir/psql -f - -d template1 $* </dev/null; then + echo "Database encoding OK" +else + echo " " + echo "Database encoding bad. Do not use this database" + echo " " fi -exit 0