1.1 --- a/tools/init.sh Sun Apr 03 22:39:53 2016 +0200
1.2 +++ b/tools/init.sh Sun Apr 03 22:41:28 2016 +0200
1.3 @@ -92,7 +92,7 @@
1.4
1.5 # Check for the database.
1.6
1.7 - if psql -tA -c 'select datname from pg_database' postgres | grep -q ^"$POSTGRESQL_DB"$ ; then
1.8 + if $AS_POSTGRES psql -tA -c 'select datname from pg_database' postgres | grep -q ^"$POSTGRESQL_DB"$ ; then
1.9 cat 1>&2 <<EOF
1.10 Database $POSTGRESQL_DB already exists.
1.11 EOF
1.12 @@ -101,7 +101,7 @@
1.13
1.14 # Attempt to create the database.
1.15
1.16 - if ! createdb "$POSTGRESQL_DB" ; then
1.17 + if ! $AS_POSTGRES createdb "$POSTGRESQL_DB" ; then
1.18 cat 1>&2 <<EOF
1.19 Could not create database $POSTGRESQL_DB using createdb.
1.20 EOF
1.21 @@ -110,7 +110,7 @@
1.22
1.23 # Attempt to initialise the schema.
1.24
1.25 - if ! psql -f "$SCHEMA" "$POSTGRESQL_DB" ; then
1.26 + if ! $AS_POSTGRES psql -f "$SCHEMA" "$POSTGRESQL_DB" ; then
1.27 cat 1>&2 <<EOF
1.28 Could not initialise schema in database $POSTGRESQL_DB using psql.
1.29 EOF
1.30 @@ -121,12 +121,12 @@
1.31 # privileges on the tables.
1.32
1.33 for USER in $POSTGRESQL_USERS ; do
1.34 - if ! createuser -D -R -S "$USER" ; then
1.35 + if ! $AS_POSTGRES createuser -D -R -S "$USER" ; then
1.36 cat 1>&2 <<EOF
1.37 Could not create database user $USER using createuser.
1.38 EOF
1.39 fi
1.40 - if ! psql -Atc '\dt' "$POSTGRESQL_DB" \
1.41 + if ! $AS_POSTGRES psql -Atc '\dt' "$POSTGRESQL_DB" \
1.42 | cut -d '|' -f 2 \
1.43 | xargs -I{} psql -c "grant all privileges on table {} to \"$USER\"" "$POSTGRESQL_DB" ; then
1.44