#!/bin/sh

if [ $# -ne 3 ]
then
    echo "Usage: $0 <DATABASE-NAME> <DATABASE-USER> <DATABASE-PASWORD>"
    exit 1
fi

CATMAID_DATABASE="$1"
CATMAID_USER="$2"
CATMAID_PASSWORD="$(echo $3 | sed -e "s/\\\\/\\\\\\\/g" -e "s/'/\\\'/g")"

cat <<EOSQL
CREATE ROLE "$CATMAID_USER" LOGIN PASSWORD '$CATMAID_PASSWORD';

CREATE DATABASE "$CATMAID_DATABASE" OWNER "$CATMAID_USER";

\c $CATMAID_DATABASE

CREATE PROCEDURAL LANGUAGE plpgsql;
EOSQL

#!/bin/sh

if [ $# -ne 3 ]
then
    echo "Usage: $0 <DATABASE-NAME> <DATABASE-USER> <DATABASE-PASWORD>"
    exit 1
fi

CATMAID_DATABASE="$1"
CATMAID_USER="$2"
CATMAID_PASSWORD="$(echo $3 | sed -e "s/\\\\/\\\\\\\/g" -e "s/'/\\\'/g")"

cat <<EOSQL
CREATE ROLE "$CATMAID_USER" LOGIN PASSWORD '$CATMAID_PASSWORD';

CREATE DATABASE "$CATMAID_DATABASE" OWNER "$CATMAID_USER";
EOSQL

Remove plpgsql install from user creation script
Remove plpgsql install from user creation script

PLPGSQL is included in databases by default since PostgreSQL 9.0 (we
require 9.2), so explicitly creating it in the user creation script
prints a potentially confusing error and returns a error status to
scripted installs.
