diff options
Diffstat (limited to 'www/openacs/files/create_sampledb.sh.in')
| -rw-r--r-- | www/openacs/files/create_sampledb.sh.in | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/www/openacs/files/create_sampledb.sh.in b/www/openacs/files/create_sampledb.sh.in new file mode 100644 index 000000000000..6321527d5beb --- /dev/null +++ b/www/openacs/files/create_sampledb.sh.in @@ -0,0 +1,45 @@ +#!/bin/sh +# $FreeBSD$ +# +# This script prepares a sample PostgreSQL database +# for use by OpenACS +# +PGUSER=%%PGUSER%% +OPENACS_USER=%%OPENACS_USER%% +OPENACS_DB=%%OPENACS_DB%% +LOCALBASE=%%LOCALBASE%% +# +PGREP=/usr/bin/pgrep +SU=/usr/bin/su +AWK=/usr/bin/awk + +CREATEUSERFLAGS="-A -d" + +# Check if PostgreSQL version is >= 8.1.0 +${LOCALBASE}/bin/postmaster -V | ${AWK} -F '[ .]' '{if ($3=8 && $4>=1) {exit 0} else {exit 1}}' && { +POSTGRESQL81=YES +CREATEUSERFLAGS="-S -R -d" +} + +${PGREP} -U ${PGUSER} postgres > /dev/null || { + echo "You need PostgreSQL server installed and running." + echo "After a fresh install, you need to initialize the database with:" + echo "su - ${PGUSER} -c initdb" + echo "Exiting ..." + exit 1 +} +echo "Creating PostgreSQL user ${OPENACS_USER} ..." +${SU} -l ${PGUSER} -c "${LOCALBASE}/bin/createuser ${CREATEUSERFLAGS} ${OPENACS_USER}" +echo "Creating PostgreSQL database ${OPENACS_DB} ..." +${SU} -l ${OPENACS_USER} -c "${LOCALBASE}/bin/createdb -E UNICODE ${OPENACS_DB}" +echo "Registering language plpgsql for database ${OPENACS_DB} ..." +${SU} -l ${PGUSER} -c "${LOCALBASE}/bin/createlang plpgsql ${OPENACS_DB}" +[ "x${POSTGRESQL81}" = "xYES" ] && { +echo "" +echo "**************************** NOTICE ****************************" +echo "You have PostgreSQL 8.1 or greater installed." +echo "Your may need to alter your PostgreSQL configuration." +echo "Please read the instructions under the following URL:" +echo "http://openacs.org/xowiki/en/How_to_install_in_Postgres_8.1.x" +echo "****************************************************************" +} |
