initial commit
This commit is contained in:
commit
88c14b627e
224 files changed
+17204
No files matched your search
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ -z "${POSTGRES_EXPORTER_USER:-}" && -z "${POSTGRES_EXPORTER_PASSWORD:-}" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
: "${POSTGRES_EXPORTER_USER:?POSTGRES_EXPORTER_USER and POSTGRES_EXPORTER_PASSWORD must both be set}"
|
||||
: "${POSTGRES_EXPORTER_PASSWORD:?POSTGRES_EXPORTER_USER and POSTGRES_EXPORTER_PASSWORD must both be set}"
|
||||
|
||||
psql \
|
||||
--username "$POSTGRES_USER" \
|
||||
--dbname "$POSTGRES_DB" \
|
||||
--set=exporter_user="$POSTGRES_EXPORTER_USER" \
|
||||
--set=exporter_password="$POSTGRES_EXPORTER_PASSWORD" <<'SQL'
|
||||
SELECT format('CREATE ROLE %I LOGIN PASSWORD %L', :'exporter_user', :'exporter_password')
|
||||
WHERE NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = :'exporter_user')
|
||||
\gexec
|
||||
|
||||
GRANT pg_monitor TO :"exporter_user";
|
||||
SQL
|
||||
Reference in new issue
Block a user