--- postgresql-8.2.6.ebuild 2008-01-13 01:44:21.000000000 +0000 +++ postgresql-8.2.6-r1.ebuild 2008-03-23 21:05:33.000000000 +0000 @@ -31,17 +31,20 @@ nls? ( sys-devel/gettext ) xml? ( dev-util/pkgconfig )" -PG_DIR="/var/lib/postgresql" +[[ -a "${ROOT}/etc/conf.d/postgresql" ]] && source "${ROOT}/etc/conf.d/postgresql" +[[ -z PGDATA ]] && PGDATA="/var/lib/postgresql" +[[ -z PGUSER ]] && PGUSER="postgres" +[[ -z PGGROUP ]] && PGGROUP="postgres" [[ -z "${PG_MAX_CONNECTIONS}" ]] && PG_MAX_CONNECTIONS="512" pkg_setup() { - if [[ -f "${PG_DIR}/data/PG_VERSION" ]] ; then - if [[ $(cat "${PG_DIR}/data/PG_VERSION") != $(get_version_component_range 1-2) ]] ; then + if [[ -f "${PGDATA}/data/PG_VERSION" ]] ; then + if [[ $(cat "${PGDATA}/data/PG_VERSION") != $(get_version_component_range 1-2) ]] ; then eerror "PostgreSQL ${PV} cannot upgrade your existing databases, you must" eerror "use pg_dump to export your existing databases to a file, and then" eerror "pg_restore to import them when you have upgraded completely." eerror "You must remove your entire database directory to continue." - eerror "(database directory = ${PG_DIR})." + eerror "(database directory = ${PGDATA})." die "Remove your database directory to continue" fi fi @@ -166,15 +169,15 @@ pkg_config() { einfo "Creating the data directory ..." - mkdir -p "${PG_DIR}/data" - chown -Rf postgres:postgres "${PG_DIR}" - chmod 0700 "${PG_DIR}/data" + mkdir -p "${PGDATA}/data" + chown -Rf $PGUSER:$PGGROUP "${PGDATA}" + chmod 0700 "${PGDATA}/data" einfo "Initializing the database ..." - if [[ -f "${PG_DIR}/data/PG_VERSION" ]] ; then + if [[ -f "${PGDATA}/data/PG_VERSION" ]] ; then eerror "PostgreSQL ${PV} cannot upgrade your existing databases." eerror "You must remove your entire database directory to continue." - eerror "(database directory = ${PG_DIR})." + eerror "(database directory = ${PGDATA})." die "Remove your database directory to continue" else if use kernel_linux ; then @@ -191,7 +194,7 @@ echo ${SEM} ${SEMMNI_MIN} > /proc/sys/kernel/sem fi - su postgres -c "/usr/bin/initdb --pgdata ${PG_DIR}/data" + su $PGUSER -c "/usr/bin/initdb --pgdata ${PGDATA}/data" if [ ! `sysctl -n kernel.sem | cut -f4` -eq ${SEMMNI} ] ; then echo ${SEM} ${SEMMNI} > /proc/sys/kernel/sem @@ -211,7 +214,7 @@ eerror fi else - su postgres -c "/usr/bin/initdb --pgdata ${PG_DIR}/data" + su postgres -c "/usr/bin/initdb --pgdata ${PGDATA}/data" fi einfo