This is an automated email from the ASF dual-hosted git repository.

wohali pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb-docker.git


The following commit(s) were added to refs/heads/master by this push:
     new 59c4c8d  Fix configuration save
59c4c8d is described below

commit 59c4c8ddfa10a1d9cd828cd7814e62f3368fe197
Author: Le Mouellic Maxime <[email protected]>
AuthorDate: Thu May 17 18:27:13 2018 +0200

    Fix configuration save
    
    On restart configuration saved in local.d/ was lost
    Closes #78
---
 1.7.1/docker-entrypoint.sh | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/1.7.1/docker-entrypoint.sh b/1.7.1/docker-entrypoint.sh
index c1c9f56..db5a60e 100755
--- a/1.7.1/docker-entrypoint.sh
+++ b/1.7.1/docker-entrypoint.sh
@@ -36,7 +36,31 @@ if [ "$1" = 'couchdb' ]; then
                chown couchdb:couchdb /usr/local/etc/couchdb/local.d/docker.ini
        fi
 
-       printf "[httpd]\nport = %s\nbind_address = %s\n" 
${COUCHDB_HTTP_PORT:=5984} ${COUCHDB_HTTP_BIND_ADDRESS:=0.0.0.0} > 
/usr/local/etc/couchdb/local.d/bind_address.ini
+       if [ -f /usr/local/etc/couchdb/local.d/bind_address.ini ]; then
+               if ! grep -Fq "port =" 
/usr/local/etc/couchdb/local.d/bind_address.ini; then
+                       vport=$(printf "[httpd]\\\nport = %s" 
${COUCHDB_HTTP_PORT:=5984})
+                       if grep -qF '[httpd]' 
/usr/local/etc/couchdb/local.d/bind_address.ini; then
+                               sed -i -e "s/\\[httpd\\]/$vport/g" 
/usr/local/etc/couchdb/local.d/bind_address.ini
+                       else
+                               printf "$vport" >> 
/usr/local/etc/couchdb/local.d/bind_address.ini
+                       fi
+
+               fi
+
+               if ! grep -Fq "bind_address =" 
/usr/local/etc/couchdb/local.d/bind_address.ini; then
+                       vaddress=$(printf "[httpd]\\\nbind_address = %s" 
${COUCHDB_HTTP_BIND_ADDRESS:=0.0.0.0})
+                       if grep -qF '[httpd]' 
/usr/local/etc/couchdb/local.d/bind_address.ini; then
+                               sed -i -e "s/\\[httpd\\]/$vaddress/g" 
/usr/local/etc/couchdb/local.d/bind_address.ini
+                       else
+                               printf "$vaddress" >> 
/usr/local/etc/couchdb/local.d/bind_address.ini
+                       fi
+
+               fi
+
+       else
+               printf "[httpd]\nport = %s\nbind_address = %s\n" 
${COUCHDB_HTTP_PORT:=5984} ${COUCHDB_HTTP_BIND_ADDRESS:=0.0.0.0} > 
/usr/local/etc/couchdb/local.d/bind_address.ini
+       fi
+
        chown couchdb:couchdb /usr/local/etc/couchdb/local.d/bind_address.ini
 
        # if we don't find an [admins] section followed by a non-comment, 
display a warning

Reply via email to