loggalicious/backend/docker/images/couchdb/entrypoint.sh

40 lines
800 B
Bash
Raw Normal View History

2018-02-05 16:18:33 +00:00
#!/bin/sh -e
echo "Waiting for CouchDB to do first initial startup..."
/docker-entrypoint.sh "$@" >/dev/null 2>&1 &
pid=$!
while ! curl --fail -s -o /dev/null http://127.0.0.1:5984; do
sleep 1
printf "."
done
echo " ok"
createdb() {
curl --fail -s -o /dev/null -X GET "http://127.0.0.1:5984/$1" ||\
curl --fail -s -o /dev/null -X PUT "http://127.0.0.1:5984/$1"
}
echo "Ensuring initial databases exist..."
createdb _global_changes
createdb _metadata
createdb _replicator
createdb _users
kill "$pid"
echo "Waiting for shutdown..."
while curl --fail -o /dev/null -s http://127.0.0.1:5984; do
sleep 1
done
echo ""
echo "===================================="
echo "== ACTUAL COUCHDB LOG STARTS HERE =="
echo "===================================="
exec tini -- /docker-entrypoint.sh "$@"