summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'dev-db/postgresql-server/postgresql-server-7.4.19.ebuild')
-rw-r--r--dev-db/postgresql-server/postgresql-server-7.4.19.ebuild117
1 files changed, 72 insertions, 45 deletions
diff --git a/dev-db/postgresql-server/postgresql-server-7.4.19.ebuild b/dev-db/postgresql-server/postgresql-server-7.4.19.ebuild
index ed130ba..2689294 100644
--- a/dev-db/postgresql-server/postgresql-server-7.4.19.ebuild
+++ b/dev-db/postgresql-server/postgresql-server-7.4.19.ebuild
@@ -39,7 +39,6 @@ PDEPEND="doc? ( dev-db/postgresql-docs:${SLOT} )"
[[ -r /etc/conf.d/postgresql-${SLOT} ]] && source /etc/conf.d/postgresql-${SLOT}
[[ -z "${PGDATA}" ]] && PGDATA="/var/lib/postgresql/${SLOT}/data"
-[[ -z "${PG_MAX_CONNECTIONS}" ]] && PG_MAX_CONNECTIONS="512"
S="${WORKDIR}/postgresql-${PV}"
@@ -119,12 +118,25 @@ src_install() {
newinitd "${FILESDIR}/postgresql.init-${SLOT}" postgresql-${SLOT} || die "Inserting init.d-file failed"
newconfd "${FILESDIR}/postgresql.conf-${SLOT}" postgresql-${SLOT} || die "Inserting conf.d-file failed"
+
+ keepdir /var/run/postgresql
+ fperms 0770 /var/run/postgresql
+ fowners postgres:postgres /var/run/postgresql
}
pkg_postinst() {
eselect postgresql update
[[ "$(eselect postgresql show)" = "(none)" ]] && eselect postgresql set ${SLOT}
[[ "$(eselect postgresql show-service)" = "(none)" ]] && eselect postgresql set-service ${SLOT}
+ ewarn "Please note that the standard location of the socket has changed from /tmp"
+ ewarn "to /var/run/postgresql and you have to be in the 'postgres' group to access"
+ ewarn "the socket."
+ ewarn "This can break applications which have the standard location hard-coded."
+ ewarn "If such an application links against the libpq, please re-emerge it,"
+ ewarn "if that doesn't help or the application accesses the socket without using libpq,"
+ ewarn "please file a bug-report."
+ ewarn "You can set PGOPTS='-k /tmp' in /etc/conf.d/postgresql-${SLOT} to restore the original location."
+
elog "Execute the following command to setup the initial database environment:"
elog
elog "emerge --config =${CATEGORY}/${PF}"
@@ -136,58 +148,73 @@ pkg_postrm() {
}
pkg_config() {
- einfo "Creating the data directory ..."
- mkdir -p "${PGDATA}"
- chown -Rf postgres:postgres "${PGDATA}"
- chmod 0700 "${PGDATA}"
-
- einfo "Initializing the database ..."
if [[ -f "${PGDATA}/PG_VERSION" ]] ; then
eerror "PostgreSQL ${PV} cannot upgrade your existing databases."
eerror "You must remove your entire database directory to continue."
eerror "(database directory = ${PGDATA})."
die "Remove your database directory to continue"
- else
- if use kernel_linux ; then
- local SEM=`sysctl -n kernel.sem | cut -f-3`
- local SEMMNI=`sysctl -n kernel.sem | cut -f4`
- local SEMMNI_MIN=`expr \( ${PG_MAX_CONNECTIONS} + 15 \) / 16`
- local SHMMAX=`sysctl -n kernel.shmmax`
- local SHMMAX_MIN=`expr 500000 + 30600 \* ${PG_MAX_CONNECTIONS}`
-
- if [ ${SEMMNI} -lt ${SEMMNI_MIN} ] ; then
- eerror "The current value of SEMMNI is too low"
- eerror "for PostgreSQL to run ${PG_MAX_CONNECTIONS} connections!"
- eerror "Temporary setting this value to ${SEMMNI_MIN} while creating the initial database."
- echo ${SEM} ${SEMMNI_MIN} > /proc/sys/kernel/sem
- fi
- su postgres -c "/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb --pgdata ${PGDATA} ${PG_INITDB_OPTS}"
-
- if [ ! `sysctl -n kernel.sem | cut -f4` -eq ${SEMMNI} ] ; then
- echo ${SEM} ${SEMMNI} > /proc/sys/kernel/sem
- ewarn "Restoring the SEMMNI value to the previous value."
- ewarn "Please edit the last value of kernel.sem in /etc/sysctl.conf"
- ewarn "and set it to at least ${SEMMNI_MIN}:"
- ewarn
- ewarn " kernel.sem = ${SEM} ${SEMMNI_MIN}"
- ewarn
- fi
+ fi
- if [ ${SHMMAX} -lt ${SHMMAX_MIN} ] ; then
- eerror "The current value of SHMMAX is too low for postgresql to run."
- eerror "Please edit /etc/sysctl.conf and set this value to at least ${SHMMAX_MIN}:"
- eerror
- eerror " kernel.shmmax = ${SHMMAX_MIN}"
- eerror
- fi
- else
- su postgres -c "/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb --pgdata ${PGDATA} ${PG_INITDB_OPTS}"
- fi
+ einfo "You can pass options to initdb by setting the PG_INITDB_OPTS variable."
+ einfo "More information can be found here:"
+ einfo " http://www.postgresql.org/docs/${SLOT}/static/creating-cluster.html"
+
+ einfo "PG_INITDB_OPTS is currently set to \"${PG_INITDB_OPTS}\""
+ einfo "Are you ready to continue? (Y/n)"
+ read answer
+ [ -z $answer ] && answer=Y
+ [ "$answer" == "Y" ] || [ "$answer" == "y" ] || die "aborted"
- einfo
- einfo "You can use the '${ROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL instead of 'pg_ctl'."
- einfo
+ [ -z "${PG_MAX_CONNECTIONS}" ] && PG_MAX_CONNECTIONS="128"
+ einfo "Checking system parameters..."
+
+ if ! use kernel_linux ; then
+ SKIP_SYSTEM_TESTS=yes
+ einfo " Tests not supported on this OS (yet)"
fi
+
+ if [ -z ${SKIP_SYSTEM_TESTS} ] ; then
+ einfo "Assuming that you want at least ${PG_MAX_CONNECTIONS} connections"
+
+ local SEMMSL=$(sysctl -n kernel.sem | cut -f1)
+ local SEMMNS=$(sysctl -n kernel.sem | cut -f2)
+ local SEMMNI=$(sysctl -n kernel.sem | cut -f4)
+ local SHMMAX=$(sysctl -n kernel.shmmax)
+
+ local SEMMSL_MIN=17
+ local SEMMNS_MIN=$(( ( ${PG_MAX_CONNECTIONS}/16 ) * 17 ))
+ local SEMMNI_MIN=$(( ( ${PG_MAX_CONNECTIONS}+15 ) / 16 ))
+ local SHMMAX_MIN=$(( 500000 + ( 30600 * ${PG_MAX_CONNECTIONS} ) ))
+
+ for p in SEMMSL SEMMNS SEMMNI SHMMAX ; do
+ if [ $(eval echo \$$p) -lt $(eval echo \$${p}_MIN) ] ; then
+ eerror "The value for ${p} $(eval echo \$$p) is below the recommended value $(eval echo \$${p}_MIN)"
+ eerror "You have now several options:"
+ eerror " - Change the mentioned system parameter."
+ eerror " - Lower the number of max.connections by setting PG_MAX_CONNECTIONS to a value lower than ${PG_MAX_CONNECTIONS}"
+ eerror " - Set SKIP_SYSTEM_TESTS in case you want to ignore this test"
+ eerror "More information can be found here:"
+ eerror " http://www.postgresql.org/docs/${SLOT}/static/kernel-resources.html"
+ die "system test failed"
+ fi
+ done
+ einfo "Passed."
+ else
+ einfo "Skipped."
+ fi
+
+ einfo "Creating the data directory ..."
+ mkdir -p "${PGDATA}"
+ chown -Rf postgres:postgres "${PGDATA}"
+ chmod 0700 "${PGDATA}"
+
+ einfo "Initializing the database ..."
+
+ su postgres -c "/usr/$(get_libdir)/postgresql-${SLOT}/bin/initdb --pgdata \"${PGDATA}\" ${PG_INITDB_OPTS}"
+
+ einfo
+ einfo "You can use the '${ROOT}/etc/init.d/postgresql-${SLOT}' script to run PostgreSQL instead of 'pg_ctl'."
+ einfo
}
src_test() {