AutoDevReverseProxy/templates/sqlproxy.sh
2022-12-21 19:26:49 +01:00

21 lines
616 B
Bash

#!/usr/bin/env bash
EXCLUDE_USERPASS="${EXCLUDE_USERPASS:-false}"
set -e
WRAP_START='[\n'
if ${EXCLUDE_USERPASS}
then
TEMPLATE=' { "type": "${LOCAL_DB_TYPE}", "host": "${LOCAL_DB_HOST}", "port": "${LOCAL_DB_PORT}" }'
else
TEMPLATE=' { "type": "${LOCAL_DB_TYPE}", "user": "${LOCAL_DB_USER}", "password": "${LOCAL_DB_PASSWORD}", "host": "${LOCAL_DB_HOST}", "port": "${LOCAL_DB_PORT}" }'
fi
SEPARATOR=',\n'
WRAP_END='\n]'
OUT="/config/sqlproxy.json"
template_hook() {
if grep -q '"type": "(?mysql|psql)".*"host": ".+", port: "\d+"' <<< "${PARTIAL_RESULT}"
then
return 0
fi
return 1
}