Some checks failed
Vulhub Format Check and Lint / format-check (push) Has been cancelled
Vulhub Format Check and Lint / markdown-check (push) Has been cancelled
Vulhub Docker Image CI / longtime-images-test (push) Has been cancelled
Vulhub Docker Image CI / images-test (push) Has been cancelled
45 lines
1.3 KiB
Bash
45 lines
1.3 KiB
Bash
#!/bin/bash
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
# use this file except in compliance with the License. You may obtain a copy of
|
|
# the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations under
|
|
# the License.
|
|
|
|
set -e
|
|
|
|
# first arg is `-something` or `+something`
|
|
if [ "${1#-}" != "$1" ] || [ "${1#+}" != "$1" ]; then
|
|
set -- /opt/couchdb/bin/couchdb "$@"
|
|
fi
|
|
|
|
# first arg is the bare word `couchdb`
|
|
if [ "$1" = 'couchdb' ]; then
|
|
shift
|
|
set -- /opt/couchdb/bin/couchdb "$@"
|
|
fi
|
|
|
|
if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
|
|
|
|
if [ ! -z "$NODENAME" ] && ! grep "couchdb@" /opt/couchdb/etc/vm.args; then
|
|
echo "-name couchdb@$NODENAME" >> /opt/couchdb/etc/vm.args
|
|
fi
|
|
|
|
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
|
|
fi
|
|
|
|
if [ "$COUCHDB_SECRET" ]; then
|
|
# Set secret
|
|
printf "[couch_httpd_auth]\nsecret = %s\n" "$COUCHDB_SECRET" >> /opt/couchdb/etc/local.d/docker.ini
|
|
fi
|
|
|
|
fi
|
|
|
|
exec "$@" |