From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1SXddq-0000Gh-VD for garchives@archives.gentoo.org; Thu, 24 May 2012 19:24:13 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3301BE07D0; Thu, 24 May 2012 19:23:58 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id E5883E07D0 for ; Thu, 24 May 2012 19:23:57 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 333BC1B4030 for ; Thu, 24 May 2012 19:23:57 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id B9CC7E542A for ; Thu, 24 May 2012 19:23:54 +0000 (UTC) From: "Aaron Swenson" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Aaron Swenson" Message-ID: <1337798918.d8732f86c3fe03b224bdeb5d7575de29ab8bc779.titanofold@gentoo> Subject: [gentoo-commits] proj/pgsql-patches:initscripts commit in: / X-VCS-Repository: proj/pgsql-patches X-VCS-Files: postgresql.init X-VCS-Directories: / X-VCS-Committer: titanofold X-VCS-Committer-Name: Aaron Swenson X-VCS-Revision: d8732f86c3fe03b224bdeb5d7575de29ab8bc779 X-VCS-Branch: initscripts Date: Thu, 24 May 2012 19:23:54 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 06004486-ff51-4bf5-919f-ff59c901a442 X-Archives-Hash: f406451e96e8588036a2e563e42f7112 commit: d8732f86c3fe03b224bdeb5d7575de29ab8bc779 Author: Aaron W. Swenson gentoo org> AuthorDate: Wed May 23 18:48:38 2012 +0000 Commit: Aaron Swenson gentoo org> CommitDate: Wed May 23 18:48:38 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/pgsql-patches= .git;a=3Dcommit;h=3Dd8732f86 Fixed startup command for 9.2. Refactored config file check. --- postgresql.init | 200 ++++++++++++++++++++++++++-----------------------= ----- 1 files changed, 96 insertions(+), 104 deletions(-) diff --git a/postgresql.init b/postgresql.init old mode 100644 new mode 100755 index 363ea1a..ec31748 --- a/postgresql.init +++ b/postgresql.init @@ -16,7 +16,7 @@ depend() { provide postgresql =20 if [ "$(get_config log_destination)" =3D "syslog" ]; then - use logger + use logger fi } =20 @@ -26,116 +26,108 @@ socket_path=3D$(get_config unix_socket_path) : ${socket_path:=3D@RUNDIR@/run/postgresql} =20 checkconfig() { - # Check that DATA_DIR has been set and exists - if [ -z ${DATA_DIR} ] ; then - eerror "DATA_DIR not set" - eerror "HINT: Perhaps you need to update /etc/conf.d/postgresql-@SLOT@= " - fi - if [ ! -d ${DATA_DIR} ] ; then - eerror "Directory not found: ${DATA_DIR}" - eerror "HINT: Ensure that DATA_DIR points to the right path." - eerror "HINT: Or perhaps you need to create the database cluster:" - eerror " emerge --config dev-db/postgresql-server:@SLOT@" - return 1 - fi - - # Check for the existence of and PostgreSQL's ability to read the confi= g files. - if [ ! -f ${PGDATA}/postgresql.conf -o \ - ! -f ${PGDATA}/pg_hba.conf -o ! -f ${PGDATA}/pg_ident.conf ] ; then - eerror "The following file(s) were not found in ${PGDATA}:" - [ ! -f ${PGDATA}/postgresql.conf ] && eerror " postgresql.conf" - [ ! -f ${PGDATA}/pg_hba.conf ] && eerror " pg_hba.conf" - [ ! -f ${PGDATA}/pg_ident.conf ] && eerror " pg_ident.conf" - eerror "HINT: Try:" - eerror " mv ${DATA_DIR}/*.conf ${PGDATA}" - return 1 - fi - - local file - local failed - for file in pg_hba pg_ident postgresql ; do - file=3D"${PGDATA}/${file}.conf" - su postgres -c "test -r ${file}" || failed=3D"${file} ${failed}" - done - if [ -n "${failed}" ] ; then - eerror "The following file(s) are not readable by 'postgres':" - local x - for x in ${failed} ; do - eerror " ${x}" - done - eerror "HINT: Try: 'chmod 644 ${PGDATA}/*.conf'" - return 1 - fi - - checkpath -d -m 0770 -o postgres:postgres ${socket_path} - if [ -e ${socket_path}/.s.PGSQL.${configured_port} ] ; then - eerror "Socket conflict." - eerror "A server is already listening on:" - eerror " ${socket_path}/.s.PGSQL.${configured_port}" - eerror "HINT: Change PGPORT to listen on a different socket." - return 1 - fi + # Check that DATA_DIR has been set and exists + if [ -z ${DATA_DIR} ] ; then + eerror "DATA_DIR not set" + eerror "HINT: Perhaps you need to update /etc/conf.d/postgresql-= @SLOT@" + fi + if [ ! -d ${DATA_DIR} ] ; then + eerror "Directory not found: ${DATA_DIR}" + eerror "HINT: Ensure that DATA_DIR points to the right path." + eerror "HINT: Or perhaps you need to create the database cluster= :" + eerror " emerge --config dev-db/postgresql-server:@SLOT@" + return 1 + fi + + # Check for the existence of PostgreSQL's config files. + local file + local status=3D0 + for file in postgresql pg_hba pg_ident ; do + file=3D"${PGDATA}/${file}.conf" + if [ -f ${file} ] ; then + checkpath -f -m 0600 -o postgres:postgres ${file} + else + eerror "${file} not found" + status=3D1 + fi + done + if [ ${status} ] ; then + eerror "HINT: Try:" + eerror " mv ${DATA_DIR}/*.conf ${PGDATA}" + return 1 + fi + + # Check the socket directory + checkpath -d -m 0770 -o postgres:postgres ${socket_path} + if [ -e ${socket_path}/.s.PGSQL.${configured_port} ] ; then + eerror "Socket conflict." + eerror "A server is already listening on:" + eerror " ${socket_path}/.s.PGSQL.${configured_port}" + eerror "HINT: Change PGPORT to listen on a different socket." + return 1 + fi } =20 start() { - checkconfig || return 1 - - ebegin "Starting PostgreSQL" - - rm -f ${DATA_DIR}/postmaster.pid - - local extraenv - local x - for x in ${PG_EXTRA_ENV} ; do - extraenv=3D"${extraenv} --env ${x}" - done - - start-stop-daemon --start \ - --user postgres \ - --exec /usr/lib/postgresql-@SLOT@/bin/postgres \ - --env "PGPORT=3D${configured_port}" \ - ${extraenv} \ - --wait $((${START_TIMEOUT}*1000)) \ - --pidfile ${DATA_DIR}/postmaster.pid \ - -- -D ${PGDATA} --data-directory=3D${DATA_DIR} --silent-mode=3Dtrue ${= PGOPTS} - local retval=3D$? - - if [ $retval -ne 0 ] ; then - eerror "Check the PostgreSQL @SLOT@ log for a detailed explanation of = the above error." - eend $retval - return $retval - fi - - eend $retval + checkconfig || return 1 + + ebegin "Starting PostgreSQL" + + rm -f ${DATA_DIR}/postmaster.pid + + local extraenv + local x + for x in ${PG_EXTRA_ENV} ; do + extraenv=3D"${extraenv} --env ${x}" + done + + start-stop-daemon --start \ + --user postgres \ + --env "PGPORT=3D${configured_port}" \ + ${extraenv} \ + --pidfile ${DATA_DIR}/postmaster.pid \ + --exec /usr/bin/pg_ctl@SLOT@ \ + -- start -s -l ${DATA_DIR}/postmaster.log -D ${PGDATA} \ + -o "--data-directory=3D${DATA_DIR} ${PGOPTS}" + local retval=3D$? + + if [ $retval -ne 0 ] ; then + eerror "Check the log for a possible explanation of the above er= ror." + eerror " ${DATA_DIR}/postmaster.log" + eend $retval + return $retval + fi + + eend $retval } =20 stop() { - local seconds=3D$(( ${NICE_TIMEOUT} + ${RUDE_TIMEOUT} + ${FORCE_TIMEOUT= } )) - ebegin "Stopping PostgreSQL (this can take up to ${seconds} seconds)" - - local retval - local retries=3DSIGTERM/${NICE_TIMEOUT} - - if [ "${RUDE_QUIT}" !=3D "NO" ] ; then - einfo "RUDE_QUIT enabled." - retries=3D"${retries}/SIGINT/${RUDE_TIMEOUT}" - fi - if [ "${FORCE_QUIT}" =3D "YES" ] ; then - einfo "FORCE_QUIT enabled." - ewarn "A recover-run might be executed on next startup." - retries=3D"${retries}/SIGQUIT/${FORCE_TIMEOUT}" - fi - - start-stop-daemon --stop \ - --exec /usr/lib/postgresql-@SLOT@/bin/postgres \ - --retry ${retries} \ - --pidfile ${DATA_DIR}/postmaster.pid - - eend + local seconds=3D$(( ${NICE_TIMEOUT} + ${RUDE_TIMEOUT} + ${FORCE_TIME= OUT} )) + ebegin "Stopping PostgreSQL (this can take up to ${seconds} seconds)= " + + local retval + local retries=3DSIGTERM/${NICE_TIMEOUT} + + if [ "${RUDE_QUIT}" !=3D "NO" ] ; then + einfo "RUDE_QUIT enabled." + retries=3D"${retries}/SIGINT/${RUDE_TIMEOUT}" + fi + if [ "${FORCE_QUIT}" =3D "YES" ] ; then + einfo "FORCE_QUIT enabled." + ewarn "A recover-run might be executed on next startup." + retries=3D"${retries}/SIGQUIT/${FORCE_TIMEOUT}" + fi + + start-stop-daemon --stop \ + --exec /usr/lib/postgresql-@SLOT@/bin/postgres \ + --retry ${retries} \ + --pidfile ${DATA_DIR}/postmaster.pid + + eend } =20 reload() { - ebegin "Reloading PostgreSQL configuration" - kill -HUP $(head -n1 ${DATA_DIR}/postmaster.pid) - eend $? + ebegin "Reloading PostgreSQL configuration" + kill -HUP $(head -n1 ${DATA_DIR}/postmaster.pid) + eend $? }