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

kocolosk pushed a commit to branch magic-cookie-writer
in repository https://gitbox.apache.org/repos/asf/couchdb-docker.git

commit 3eefe2ca7fcffb8dad333f673958e2b278145b7d
Author: Adam Kocoloski <[email protected]>
AuthorDate: Tue Feb 8 18:50:23 2022 -0500

    Listen for COUCHDB_ERLANG_COOKIE and write it down
---
 3.2.1/docker-entrypoint.sh | 15 +++++++++++++++
 dev/docker-entrypoint.sh   | 15 +++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/3.2.1/docker-entrypoint.sh b/3.2.1/docker-entrypoint.sh
index 4b8b4f4..8d6456d 100755
--- a/3.2.1/docker-entrypoint.sh
+++ b/3.2.1/docker-entrypoint.sh
@@ -77,6 +77,21 @@ if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
                fi
        fi
 
+       if [ "$COUCHDB_ERLANG_COOKIE" ]; then
+               cookieFile='/opt/couchdb/.erlang.cookie'
+               if [ -e "$cookieFile" ]; then
+                       if [ "$(cat "$cookieFile" 2>/dev/null)" != 
"$COUCHDB_ERLANG_COOKIE" ]; then
+                               echo >&2
+                               echo >&2 "warning: $cookieFile contents do not 
match COUCHDB_ERLANG_COOKIE"
+                               echo >&2
+                       fi
+               else
+                       echo "$COUCHDB_ERLANG_COOKIE" > "$cookieFile"
+               fi
+               chown couchdb:couchdb "$cookieFile"
+               chmod 600 "$cookieFile"
+       fi
+
        if [ "$(id -u)" = '0' ]; then
                chown -f couchdb:couchdb /opt/couchdb/etc/local.d/docker.ini || 
true
        fi
diff --git a/dev/docker-entrypoint.sh b/dev/docker-entrypoint.sh
index 4c1f9bf..95691c2 100755
--- a/dev/docker-entrypoint.sh
+++ b/dev/docker-entrypoint.sh
@@ -69,6 +69,21 @@ if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
                fi
        fi
 
+       if [ "$COUCHDB_ERLANG_COOKIE" ]; then
+               cookieFile='/opt/couchdb/.erlang.cookie'
+               if [ -e "$cookieFile" ]; then
+                       if [ "$(cat "$cookieFile" 2>/dev/null)" != 
"$COUCHDB_ERLANG_COOKIE" ]; then
+                               echo >&2
+                               echo >&2 "warning: $cookieFile contents do not 
match COUCHDB_ERLANG_COOKIE"
+                               echo >&2
+                       fi
+               else
+                       echo "$COUCHDB_ERLANG_COOKIE" > "$cookieFile"
+               fi
+               chown couchdb:couchdb "$cookieFile"
+               chmod 600 "$cookieFile"
+       fi
+
        chown -f couchdb:couchdb /opt/couchdb/etc/local.d/docker.ini || true
 
        # if we don't find an [admins] section followed by a non-comment, 
display a warning

Reply via email to