#!/bin/sh
#
# shell script to create Bacula database(s)
#

bindir=@SQL_BINDIR@
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 consoles work correctly *only* with UTF8.
#ENCODING="ENCODING 'UTF8'"
     

if $bindir/psql -f - -d template1 $* <<END-OF-DATA
CREATE DATABASE ${db_name} $ENCODING;
ALTER DATABASE ${db_name} SET datestyle TO 'ISO, YMD';
END-OF-DATA
then
   echo "Creation of ${db_name} database succeeded."
else
   echo "Creation of ${db_name} database failed."
fi
exit 0


syntax highlighted by Code2HTML, v. 0.9.1