commit:     315323499fa5e267317d413318481e7cfec8d7c9
Author:     Austin English <wizardedit <AT> gentoo <DOT> org>
AuthorDate: Mon Apr  3 20:51:52 2017 +0000
Commit:     Austin English <wizardedit <AT> gentoo <DOT> org>
CommitDate: Mon Apr  3 20:56:56 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=31532349

dev-db/postgresql: respect PG_AUTOCONFIG env variable

This allows configuring postgresql without further input from the input
(i.e., makes it scriptable).

Gentoo-Bug: https://bugs.gentoo.org/610418

 dev-db/postgresql/postgresql-9.5.5.ebuild    | 27 ++++++++++++++++-----------
 dev-db/postgresql/postgresql-9.5.6.ebuild    | 26 +++++++++++++++-----------
 dev-db/postgresql/postgresql-9.6.1-r1.ebuild | 26 +++++++++++++++-----------
 dev-db/postgresql/postgresql-9.6.2.ebuild    | 26 +++++++++++++++-----------
 dev-db/postgresql/postgresql-9999.ebuild     | 26 +++++++++++++++-----------
 5 files changed, 76 insertions(+), 55 deletions(-)

diff --git a/dev-db/postgresql/postgresql-9.5.5.ebuild 
b/dev-db/postgresql/postgresql-9.5.5.ebuild
index b352149ac96..56cafc185c7 100644
--- a/dev-db/postgresql/postgresql-9.5.5.ebuild
+++ b/dev-db/postgresql/postgresql-9.5.5.ebuild
@@ -350,17 +350,22 @@ pkg_config() {
        einfo "The database cluster will be created in:"
        einfo "    ${DATA_DIR}"
        einfo
-       while [ "$correct" != "true" ] ; do
-               einfo "Are you ready to continue? (y/n)"
-               read answer
-               if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-                       correct="true"
-               elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-                       die "Aborting initialization."
-               else
-                       echo "Answer not recognized"
-               fi
-       done
+
+       if [ -z "$PG_AUTOCONFIG" ] ; then
+               while [ "$correct" != "true" ] ; do
+                       einfo "Are you ready to continue? (y/n)"
+                       read answer
+                       if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
+                               correct="true"
+                       elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
+                               die "Aborting initialization."
+                       else
+                               echo "Answer not recognized"
+                       fi
+               done
+       else
+               einfo "PG_AUTOCONFIG set, not prompting"
+       fi
 
        if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
                eerror "The given directory, '${DATA_DIR}', is not empty."

diff --git a/dev-db/postgresql/postgresql-9.5.6.ebuild 
b/dev-db/postgresql/postgresql-9.5.6.ebuild
index 8e8412b1fc7..eb493f3f392 100644
--- a/dev-db/postgresql/postgresql-9.5.6.ebuild
+++ b/dev-db/postgresql/postgresql-9.5.6.ebuild
@@ -350,17 +350,21 @@ pkg_config() {
        einfo "The database cluster will be created in:"
        einfo "    ${DATA_DIR}"
        einfo
-       while [ "$correct" != "true" ] ; do
-               einfo "Are you ready to continue? (y/n)"
-               read answer
-               if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-                       correct="true"
-               elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-                       die "Aborting initialization."
-               else
-                       echo "Answer not recognized"
-               fi
-       done
+       if [ -z "$PG_AUTOCONFIG" ] ; then
+               while [ "$correct" != "true" ] ; do
+                       einfo "Are you ready to continue? (y/n)"
+                       read answer
+                       if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
+                               correct="true"
+                       elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
+                               die "Aborting initialization."
+                       else
+                               echo "Answer not recognized"
+                       fi
+               done
+       else
+               einfo "PG_AUTOCONFIG set, not prompting"
+       fi
 
        if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
                eerror "The given directory, '${DATA_DIR}', is not empty."

diff --git a/dev-db/postgresql/postgresql-9.6.1-r1.ebuild 
b/dev-db/postgresql/postgresql-9.6.1-r1.ebuild
index 0c0ba8278ad..0e4412b472c 100644
--- a/dev-db/postgresql/postgresql-9.6.1-r1.ebuild
+++ b/dev-db/postgresql/postgresql-9.6.1-r1.ebuild
@@ -347,17 +347,21 @@ pkg_config() {
        einfo "The database cluster will be created in:"
        einfo "    ${DATA_DIR}"
        einfo
-       while [ "$correct" != "true" ] ; do
-               einfo "Are you ready to continue? (y/n)"
-               read answer
-               if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-                       correct="true"
-               elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-                       die "Aborting initialization."
-               else
-                       echo "Answer not recognized"
-               fi
-       done
+       if [ -z "$PG_AUTOCONFIG" ] ; then
+               while [ "$correct" != "true" ] ; do
+                       einfo "Are you ready to continue? (y/n)"
+                       read answer
+                       if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
+                               correct="true"
+                       elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
+                               die "Aborting initialization."
+                       else
+                               echo "Answer not recognized"
+                       fi
+               done
+       else
+               einfo "PG_AUTOCONFIG set, not prompting"
+       fi
 
        if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
                eerror "The given directory, '${DATA_DIR}', is not empty."

diff --git a/dev-db/postgresql/postgresql-9.6.2.ebuild 
b/dev-db/postgresql/postgresql-9.6.2.ebuild
index 0c0ba8278ad..0e4412b472c 100644
--- a/dev-db/postgresql/postgresql-9.6.2.ebuild
+++ b/dev-db/postgresql/postgresql-9.6.2.ebuild
@@ -347,17 +347,21 @@ pkg_config() {
        einfo "The database cluster will be created in:"
        einfo "    ${DATA_DIR}"
        einfo
-       while [ "$correct" != "true" ] ; do
-               einfo "Are you ready to continue? (y/n)"
-               read answer
-               if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-                       correct="true"
-               elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-                       die "Aborting initialization."
-               else
-                       echo "Answer not recognized"
-               fi
-       done
+       if [ -z "$PG_AUTOCONFIG" ] ; then
+               while [ "$correct" != "true" ] ; do
+                       einfo "Are you ready to continue? (y/n)"
+                       read answer
+                       if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
+                               correct="true"
+                       elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
+                               die "Aborting initialization."
+                       else
+                               echo "Answer not recognized"
+                       fi
+               done
+       else
+               einfo "PG_AUTOCONFIG set, not prompting"
+       fi
 
        if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
                eerror "The given directory, '${DATA_DIR}', is not empty."

diff --git a/dev-db/postgresql/postgresql-9999.ebuild 
b/dev-db/postgresql/postgresql-9999.ebuild
index b1d33768336..6a995c154ba 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9999.ebuild
@@ -297,17 +297,21 @@ pkg_config() {
        einfo "The database cluster will be created in:"
        einfo "    ${DATA_DIR}"
        einfo
-       while [ "$correct" != "true" ] ; do
-               einfo "Are you ready to continue? (y/n)"
-               read answer
-               if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
-                       correct="true"
-               elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
-                       die "Aborting initialization."
-               else
-                       echo "Answer not recognized"
-               fi
-       done
+       if [ -z "$PG_AUTOCONFIG" ] ; then
+               while [ "$correct" != "true" ] ; do
+                       einfo "Are you ready to continue? (y/n)"
+                       read answer
+                       if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
+                               correct="true"
+                       elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
+                               die "Aborting initialization."
+                       else
+                               echo "Answer not recognized"
+                       fi
+               done
+       else
+               einfo "PG_AUTOCONFIG set, not prompting"
+       fi
 
        if [ -n "$(ls -A ${DATA_DIR} 2> /dev/null)" ] ; then
                eerror "The given directory, '${DATA_DIR}', is not empty."

Reply via email to