feat: Add specific environment variable postgres user password
This commit is contained in:
parent
d9b2af7c97
commit
6743a02af2
|
|
@ -136,6 +136,15 @@ EOF
|
|||
else
|
||||
cat <<"EOF"
|
||||
export POSTGRESQL_REPLICATION_PASSWORD="${POSTGRESQL_REPLICATION_PASSWORD:-}"
|
||||
EOF
|
||||
fi
|
||||
if [[ -n "${POSTGRESQL_POSTGRES_PASSWORD_FILE:-}" ]] && [[ -f "$POSTGRESQL_POSTGRES_PASSWORD_FILE" ]]; then
|
||||
cat <<"EOF"
|
||||
export POSTGRESQL_POSTGRES_PASSWORD="$(< "${POSTGRESQL_POSTGRES_PASSWORD_FILE}")"
|
||||
EOF
|
||||
else
|
||||
cat <<"EOF"
|
||||
export POSTGRESQL_POSTGRES_PASSWORD="${POSTGRESQL_POSTGRES_PASSWORD:-}"
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
|
@ -381,13 +390,13 @@ postgresql_configure_fsync() {
|
|||
# Globals:
|
||||
# POSTGRESQL_*
|
||||
# Arguments:
|
||||
# None
|
||||
# Password
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
postgresql_alter_postgres_user() {
|
||||
local -r escaped_password="${POSTGRESQL_PASSWORD//\'/\'\'}"
|
||||
info "Changing password of ${POSTGRESQL_USERNAME}"
|
||||
local -r escaped_password="${1//\'/\'\'}"
|
||||
info "Changing password of postgres"
|
||||
echo "ALTER ROLE postgres WITH PASSWORD '$escaped_password';" | postgresql_execute
|
||||
}
|
||||
|
||||
|
|
@ -511,8 +520,11 @@ postgresql_initialize() {
|
|||
postgresql_start_bg
|
||||
[[ -n "${POSTGRESQL_DATABASE}" ]] && [[ "$POSTGRESQL_DATABASE" != "postgres" ]] && postgresql_create_custom_database
|
||||
if [[ "$POSTGRESQL_USERNAME" = "postgres" ]]; then
|
||||
postgresql_alter_postgres_user
|
||||
postgresql_alter_postgres_user "$POSTGRESQL_PASSWORD"
|
||||
else
|
||||
if [[ ! -z "$POSTGRESQL_POSTGRES_PASSWORD" ]]; then
|
||||
postgresql_alter_postgres_user "$POSTGRESQL_POSTGRES_PASSWORD"
|
||||
fi
|
||||
postgresql_create_admin_user
|
||||
fi
|
||||
is_boolean_yes "$create_pghba_file" && postgresql_restrict_pghba
|
||||
|
|
|
|||
Loading…
Reference in New Issue