github.com/adnan-c/fabric_e2e_couchdb@v0.6.1-preview.0.20170228180935-21ce6b23cf91/images/couchdb/docker-entrypoint.sh (about) 1 #!/bin/bash 2 # Licensed under the Apache License, Version 2.0 (the "License"); you may not 3 # use this file except in compliance with the License. You may obtain a copy of 4 # the License at 5 # 6 # http://www.apache.org/licenses/LICENSE-2.0 7 # 8 # Unless required by applicable law or agreed to in writing, software 9 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 # License for the specific language governing permissions and limitations under 12 # the License. 13 14 set -e 15 16 if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then 17 # we need to set the permissions here because docker mounts volumes as root 18 chown -R couchdb:couchdb /opt/couchdb 19 20 chmod -R 0770 /opt/couchdb/data 21 22 chmod 664 /opt/couchdb/etc/*.ini 23 chmod 664 /opt/couchdb/etc/local.d/*.ini 24 chmod 775 /opt/couchdb/etc/*.d 25 26 if [ ! -z "$NODENAME" ] && ! grep "couchdb@" /opt/couchdb/etc/vm.args; then 27 echo "-name couchdb@$NODENAME" >> /opt/couchdb/etc/vm.args 28 fi 29 30 if [ "$COUCHDB_USER" ] && [ "$COUCHDB_PASSWORD" ]; then 31 # Create admin 32 printf "[admins]\n%s = %s\n" "$COUCHDB_USER" "$COUCHDB_PASSWORD" > /opt/couchdb/etc/local.d/docker.ini 33 chown couchdb:couchdb /opt/couchdb/etc/local.d/docker.ini 34 fi 35 36 # if we don't find an [admins] section followed by a non-comment, display a warning 37 if ! grep -Pzoqr '\[admins\]\n[^;]\w+' /opt/couchdb/etc/local.d/*.ini; then 38 # The - option suppresses leading tabs but *not* spaces. :) 39 cat >&2 <<-'EOWARN' 40 **************************************************** 41 WARNING: CouchDB is running in Admin Party mode. 42 This will allow anyone with access to the 43 CouchDB port to access your database. In 44 Docker's default configuration, this is 45 effectively any other container on the same 46 system. 47 Use "-e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password" 48 to set it in "docker run". 49 **************************************************** 50 EOWARN 51 fi 52 53 54 exec su-exec couchdb "$@" 55 fi 56 57 exec "$@"