fasten-onprem/docker/rootfs/etc/cont-init.d/05-couchdb-config

34 lines
952 B
Plaintext

#!/usr/bin/with-contenv bash
if [ -f "/opt/couchdb/data/.config_complete" ]; then
echo "Couchdb config has already completed, skipping"
else
#echo -n means we dont pass newline to base64 (ugh). eg. hello = aGVsbG8K vs aGVsbG8=
FASTEN_JWT_ISSUER_KEY_BASE64=$(echo -n "${FASTEN_JWT_ISSUER_KEY}" | base64)
cat << EOF >> /opt/couchdb/etc/local.d/generated.ini
; ------------------------------------------ GENERATED MODIFICATIONS
; ------------------------------------------ GENERATED MODIFICATIONS
; ------------------------------------------ GENERATED MODIFICATIONS
;
[jwt_auth]
required_claims = exp, {iss, "docker-fastenhealth"}
[jwt_keys]
hmac:_default = ${FASTEN_JWT_ISSUER_KEY_BASE64}
; users should change this default password
[admins]
${FASTEN_COUCHDB_ADMIN_USERNAME} = ${FASTEN_COUCHDB_ADMIN_PASSWORD}
EOF
# create the config complete flag
echo "Couchdb config: complete"
touch /opt/couchdb/data/.config_complete
fi