#!/bin/sh # # Copyright (C) 2000-2017 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS # # shell script to create Bacula database(s) # 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 # # 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. # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # # if psql -f - -d template1 $* </dev/null; then echo "Database encoding OK" else echo " " echo "Database encoding bad. Do not use this database" echo " " exit 1 fi