github.com/darrenli6/fabric-sdk-example@v0.0.0-20220109053535-94b13b56df8c/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  
    18  	if [ ! -z "$NODENAME" ] && ! grep "couchdb@" /opt/couchdb/etc/vm.args; then
    19  		echo "-name couchdb@$NODENAME" >> /opt/couchdb/etc/vm.args
    20  	fi
    21  
    22  	if [ "$COUCHDB_USER" ] && [ "$COUCHDB_PASSWORD" ]; then
    23  		# Create admin
    24  		printf "[admins]\n%s = %s\n" "$COUCHDB_USER" "$COUCHDB_PASSWORD" > /opt/couchdb/etc/local.d/docker.ini
    25  	fi
    26  
    27  	# if we don't find an [admins] section followed by a non-comment, display a warning
    28  	if ! grep -Pzoqr '\[admins\]\n[^;]\w+' /opt/couchdb/etc/local.d/*.ini; then
    29  		# The - option suppresses leading tabs but *not* spaces. :)
    30  		cat >&2 <<-'EOWARN'
    31  			****************************************************
    32  			WARNING: CouchDB is running in Admin Party mode.
    33  			         This will allow anyone with access to the
    34  			         CouchDB port to access your database. In
    35  			         Docker's default configuration, this is
    36  			         effectively any other container on the same
    37  			         system.
    38  			         Use "-e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password"
    39  			         to set it in "docker run".
    40  			****************************************************
    41  		EOWARN
    42  	fi
    43  
    44  	sleep 1
    45  fi
    46  
    47  chown -R couchdb:couchdb /opt/couchdb/data
    48  
    49  su-exec couchdb "$@"