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