You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wo...@apache.org on 2018/07/10 20:35:37 UTC
[couchdb-docker] branch master updated: Backport fix for #81 and
#82 to 2.1.x image
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 9057152 Backport fix for #81 and #82 to 2.1.x image
9057152 is described below
commit 9057152522f919c79acde1a61ad25c31d0ad2f25
Author: Joan Touzet <wo...@apache.org>
AuthorDate: Tue Jul 10 13:21:32 2018 -0700
Backport fix for #81 and #82 to 2.1.x image
---
2.1.1/docker-entrypoint.sh | 30 ++++++++++++++++++------------
dev/docker-entrypoint.sh | 2 +-
2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/2.1.1/docker-entrypoint.sh b/2.1.1/docker-entrypoint.sh
index e03cd1a..c60c957 100755
--- a/2.1.1/docker-entrypoint.sh
+++ b/2.1.1/docker-entrypoint.sh
@@ -26,32 +26,38 @@ fi
if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
# we need to set the permissions here because docker mounts volumes as root
- chown -R couchdb:couchdb /opt/couchdb
+ chown -fR couchdb:couchdb /opt/couchdb || true
- chmod -R 0770 /opt/couchdb/data
+ chmod -fR 0770 /opt/couchdb/data || true
- chmod 664 /opt/couchdb/etc/*.ini
- chmod 664 /opt/couchdb/etc/default.d/*.ini
- chmod 775 /opt/couchdb/etc/*.d
+ find /opt/couchdb/etc -name \*.ini -exec chmod -f 664 {} \;
+ chmod -f 775 /opt/couchdb/etc/*.d || true
if [ ! -z "$NODENAME" ] && ! grep "couchdb@" /opt/couchdb/etc/vm.args; then
echo "-name couchdb@$NODENAME" >> /opt/couchdb/etc/vm.args
fi
+ # Ensure that CouchDB will write custom settings in this file
+ touch /opt/couchdb/etc/local.d/docker.ini
+
if [ "$COUCHDB_USER" ] && [ "$COUCHDB_PASSWORD" ]; then
- # Create admin
- printf "[admins]\n%s = %s\n" "$COUCHDB_USER" "$COUCHDB_PASSWORD" > /opt/couchdb/etc/local.d/docker.ini
- chown couchdb:couchdb /opt/couchdb/etc/local.d/docker.ini
+ # Create admin only if not already present
+ if ! grep -Pzoqr "\[admins\]\n$COUCHDB_USER =" /opt/couchdb/etc/local.d/*.ini; then
+ printf "[admins]\n%s = %s\n" "$COUCHDB_USER" "$COUCHDB_PASSWORD" >> /opt/couchdb/etc/local.d/docker.ini
+ fi
fi
if [ "$COUCHDB_SECRET" ]; then
- # Set secret
- printf "[couch_httpd_auth]\nsecret = %s\n" "$COUCHDB_SECRET" >> /opt/couchdb/etc/local.d/docker.ini
- chown couchdb:couchdb /opt/couchdb/etc/local.d/docker.ini
+ # Set secret only if not already present
+ if ! grep -Pzoqr "\[couch_httpd_auth\]\nsecret =" /opt/couchdb/etc/local.d/*.ini; then
+ printf "[couch_httpd_auth]\nsecret = %s\n" "$COUCHDB_SECRET" >> /opt/couchdb/etc/local.d/docker.ini
+ fi
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
- if ! grep -Pzoqr '\[admins\]\n[^;]\w+' /opt/couchdb/etc/default.d/*.ini /opt/couchdb/etc/local.d/*.ini; then
+ if ! grep -Pzoqr '\[admins\]\n[^;]\w+' /opt/couchdb/etc/default.d/*.ini /opt/couchdb/etc/local.d/*.ini; then
# The - option suppresses leading tabs but *not* spaces. :)
cat >&2 <<-'EOWARN'
****************************************************
diff --git a/dev/docker-entrypoint.sh b/dev/docker-entrypoint.sh
index de42028..c60c957 100755
--- a/dev/docker-entrypoint.sh
+++ b/dev/docker-entrypoint.sh
@@ -57,7 +57,7 @@ if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
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
- if ! grep -Pzoqr '\[admins\]\n[^;]\w+' /opt/couchdb/etc/local.d/*.ini; then
+ if ! grep -Pzoqr '\[admins\]\n[^;]\w+' /opt/couchdb/etc/default.d/*.ini /opt/couchdb/etc/local.d/*.ini; then
# The - option suppresses leading tabs but *not* spaces. :)
cat >&2 <<-'EOWARN'
****************************************************