--- /usr/portage/dev-db/postgresql/postgresql-7.4.2.ebuild 2004-04-06 12:15:54.000000000 +0900 +++ postgresql-7.4.2-r1.ebuild 2004-04-23 11:44:47.078271280 +0900 @@ -45,6 +45,7 @@ ssl? ( >=dev-libs/openssl-0.9.6-r1 )" PG_DIR="/var/lib/postgresql" +MAX_CONNECTIONS=1024 pkg_setup() { if [ -f ${PG_DIR}/data/PG_VERSION ] ; then @@ -123,7 +124,7 @@ --libdir=/usr/lib \ --enable-depend \ --with-gnu-ld \ - --with-maxbackends=1024 \ + --with-maxbackends=${MAX_CONNECTIONS} \ $myconf || die make || die @@ -222,33 +223,37 @@ einfo "Read the documentation to check how to upgrade to version ${PV}." fi else - # On hppa, postgresql need way more than the default sem index and shmmax - if [ "${ARCH}" = "hppa" ]; then - SEM_IDX_MIN=1024 - SHMMAX_MIN=100000000 - SEM_IDX=`sysctl kernel.sem | awk '{ print $6 }'` - if [ $SEM_IDX -lt ${SEM_IDX_MIN} ]; then - eerror "The last value of /proc/sys/kernel/sem is too low for postgresql to run" - eerror "Temporary setting this value to ${SEM_IDX_MIN} while creating the initial database." - cat /proc/sys/kernel/sem | sed -e "s/\t${SEM_IDX}/\t${SEM_IDX_MIN}/" > /proc/sys/kernel/sem - fi + local SEM=`sysctl -n kernel.sem | cut -f-3` + local SEMMNI=`sysctl -n kernel.sem | cut -f4` + local SEMMNI_MIN=`expr \( ${MAX_CONNECTIONS} + 15 \) / 16` + local SHMMAX=`sysctl -n kernel.shmmax` + local SHMMAX_MIN=134217728 # 128M + + if [ ${SEMMNI} -lt ${SEMMNI_MIN} ]; then + eerror "The current value of SEMMNI is too low" + eerror "for postgresql to run ${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 sudo -u postgres /usr/bin/initdb --pgdata ${PG_DIR}/data - if [ "${ARCH}" = "hppa" ]; then - if [ ! `sysctl kernel.sem | awk '{ print $6 }'` -eq ${SEM_IDX} ] ; then - cat /proc/sys/kernel/sem | sed -e "s/\t${SEM_IDX_MIN}/\t${SEM_IDX}/" > /proc/sys/kernel/sem - ewarn "Restoring the sem idx 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 ${SEM_IDX_MIN}" - fi - - if [ `sysctl kernel.shmmax | awk '{ print $3 }'` -lt ${SHMMAX_MIN} ]; then - eerror "The current value of /proc/sys/kernel/shmmax is too low" - eerror "for postgresql to run. Please edit /etc/sysctl.conf and set" - eerror "this value to at least ${SHMMAX_MIN}." + 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 + + 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 fi einfo "If you are upgrading from a pre-7.3 version of PostgreSQL, please read"