1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-27 10:03:20 +00:00
freebsd-ports/www/openacs/files/create_sampledb.sh.in
2008-09-04 10:31:54 +00:00

50 lines
1.7 KiB
Bash

#!/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=%%PGREP%%
SU=%%SU%%
AWK=%%AWK%%
CREATEUSERFLAGS="-A -d"
# Check if PostgreSQL version is >= 8.1.0
if `${LOCALBASE}/bin/postmaster -V | ${AWK} -F '[ .]' '{if ($3==8 && $4>=1) {exit 0} else {exit 1}}'`; then
POSTGRESQL81=YES
CREATEUSERFLAGS="-S -R -d"
fi
if ! `${PGREP} -U ${PGUSER} postgres > /dev/null`; then
echo "You need PostgreSQL server installed and running."
echo "After a fresh install, you need to initialize the database with:"
echo "${LOCALBASE}/etc/rc.d/postgresql initdb"
echo "Exiting ..."
exit 1
fi
echo "Creating PostgreSQL user ${OPENACS_USER} ..."
${SU} -l ${PGUSER} -c "${LOCALBASE}/bin/createuser ${CREATEUSERFLAGS} ${OPENACS_USER}"
echo "Creating PostgreSQL database ${OPENACS_DB} ..."
${SU} -m ${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}"
if [ "x${POSTGRESQL81}" = "xYES" ]; then
echo ""
echo "**************************** NOTICE ****************************"
echo "You have PostgreSQL 8.1 or greater installed."
echo "Your may need to alter your PostgreSQL configuration."
echo "You can do this by running the supplied script:"
echo "%%DOCSDIR%%/adjust_pgsql_conf.sh"; echo ""
echo "Alternatively you can follow the instructions at:"
echo "http://openacs.org/xowiki/How_to_install_in_Postgres_8.x"
echo "****************************************************************"
fi