Skip to content

Commit

Permalink
[bitnami/postgresql-repmgr] fix init script tries to recreate repmgr
Browse files Browse the repository at this point in the history
Signed-off-by: Yukha Dharmeswara <[email protected]>
  • Loading branch information
yukha-dw committed Oct 29, 2024
1 parent ec8e7c6 commit 8188e1c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,8 @@ repmgr_create_repmgr_user() {
[[ "$POSTGRESQL_USERNAME" != "postgres" ]] && [[ -n "$POSTGRESQL_POSTGRES_PASSWORD" ]] && postgres_password="$POSTGRESQL_POSTGRES_PASSWORD"
# The repmgr user is created as superuser for simplicity (ref: https://repmgr.org/docs/4.3/quickstart-repmgr-user-database.html)
# In case REPMGR_USERNAME == POSTGRESQL_REPLICATION_USER, we just need to grant repmgr with CREATEDB
if [[ "$REPMGR_USERNAME" == "$POSTGRESQL_REPLICATION_USER" ]]; then
echo "ALTER USER ${REPMGR_USERNAME} WITH CREATEDB;" | postgresql_execute "" "postgres" "$postgres_password"
else
echo "CREATE ROLE \"${REPMGR_USERNAME}\" WITH LOGIN CREATEDB PASSWORD '${escaped_password}';" | postgresql_execute "" "postgres" "$postgres_password"
fi
echo "ALTER USER ${REPMGR_USERNAME} WITH SUPERUSER;" | postgresql_execute "" "postgres" "$postgres_password"
postgresql_ensure_user_exists "$REPMGR_USERNAME" --password "$postgres_password"
echo "ALTER USER ${REPMGR_USERNAME} WITH SUPERUSER CREATEDB;" | postgresql_execute "" "postgres" "$postgres_password"
# set the repmgr user's search path to include the 'repmgr' schema name (ref: https://repmgr.org/docs/4.3/quickstart-repmgr-user-database.html)
echo "ALTER USER ${REPMGR_USERNAME} SET search_path TO repmgr, \"\$user\", public;" | postgresql_execute "" "postgres" "$postgres_password"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,8 @@ repmgr_create_repmgr_user() {
[[ "$POSTGRESQL_USERNAME" != "postgres" ]] && [[ -n "$POSTGRESQL_POSTGRES_PASSWORD" ]] && postgres_password="$POSTGRESQL_POSTGRES_PASSWORD"
# The repmgr user is created as superuser for simplicity (ref: https://repmgr.org/docs/4.3/quickstart-repmgr-user-database.html)
# In case REPMGR_USERNAME == POSTGRESQL_REPLICATION_USER, we just need to grant repmgr with CREATEDB
if [[ "$REPMGR_USERNAME" == "$POSTGRESQL_REPLICATION_USER" ]]; then
echo "ALTER USER ${REPMGR_USERNAME} WITH CREATEDB;" | postgresql_execute "" "postgres" "$postgres_password"
else
echo "CREATE ROLE \"${REPMGR_USERNAME}\" WITH LOGIN CREATEDB PASSWORD '${escaped_password}';" | postgresql_execute "" "postgres" "$postgres_password"
fi
echo "ALTER USER ${REPMGR_USERNAME} WITH SUPERUSER;" | postgresql_execute "" "postgres" "$postgres_password"
postgresql_ensure_user_exists "$REPMGR_USERNAME" --password "$postgres_password"
echo "ALTER USER ${REPMGR_USERNAME} WITH SUPERUSER CREATEDB;" | postgresql_execute "" "postgres" "$postgres_password"
# set the repmgr user's search path to include the 'repmgr' schema name (ref: https://repmgr.org/docs/4.3/quickstart-repmgr-user-database.html)
echo "ALTER USER ${REPMGR_USERNAME} SET search_path TO repmgr, \"\$user\", public;" | postgresql_execute "" "postgres" "$postgres_password"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,8 @@ repmgr_create_repmgr_user() {
[[ "$POSTGRESQL_USERNAME" != "postgres" ]] && [[ -n "$POSTGRESQL_POSTGRES_PASSWORD" ]] && postgres_password="$POSTGRESQL_POSTGRES_PASSWORD"
# The repmgr user is created as superuser for simplicity (ref: https://repmgr.org/docs/4.3/quickstart-repmgr-user-database.html)
# In case REPMGR_USERNAME == POSTGRESQL_REPLICATION_USER, we just need to grant repmgr with CREATEDB
if [[ "$REPMGR_USERNAME" == "$POSTGRESQL_REPLICATION_USER" ]]; then
echo "ALTER USER ${REPMGR_USERNAME} WITH CREATEDB;" | postgresql_execute "" "postgres" "$postgres_password"
else
echo "CREATE ROLE \"${REPMGR_USERNAME}\" WITH LOGIN CREATEDB PASSWORD '${escaped_password}';" | postgresql_execute "" "postgres" "$postgres_password"
fi
echo "ALTER USER ${REPMGR_USERNAME} WITH SUPERUSER;" | postgresql_execute "" "postgres" "$postgres_password"
postgresql_ensure_user_exists "$REPMGR_USERNAME" --password "$postgres_password"
echo "ALTER USER ${REPMGR_USERNAME} WITH SUPERUSER CREATEDB;" | postgresql_execute "" "postgres" "$postgres_password"
# set the repmgr user's search path to include the 'repmgr' schema name (ref: https://repmgr.org/docs/4.3/quickstart-repmgr-user-database.html)
echo "ALTER USER ${REPMGR_USERNAME} SET search_path TO repmgr, \"\$user\", public;" | postgresql_execute "" "postgres" "$postgres_password"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,8 @@ repmgr_create_repmgr_user() {
[[ "$POSTGRESQL_USERNAME" != "postgres" ]] && [[ -n "$POSTGRESQL_POSTGRES_PASSWORD" ]] && postgres_password="$POSTGRESQL_POSTGRES_PASSWORD"
# The repmgr user is created as superuser for simplicity (ref: https://repmgr.org/docs/4.3/quickstart-repmgr-user-database.html)
# In case REPMGR_USERNAME == POSTGRESQL_REPLICATION_USER, we just need to grant repmgr with CREATEDB
if [[ "$REPMGR_USERNAME" == "$POSTGRESQL_REPLICATION_USER" ]]; then
echo "ALTER USER ${REPMGR_USERNAME} WITH CREATEDB;" | postgresql_execute "" "postgres" "$postgres_password"
else
echo "CREATE ROLE \"${REPMGR_USERNAME}\" WITH LOGIN CREATEDB PASSWORD '${escaped_password}';" | postgresql_execute "" "postgres" "$postgres_password"
fi
echo "ALTER USER ${REPMGR_USERNAME} WITH SUPERUSER;" | postgresql_execute "" "postgres" "$postgres_password"
postgresql_ensure_user_exists "$REPMGR_USERNAME" --password "$postgres_password"
echo "ALTER USER ${REPMGR_USERNAME} WITH SUPERUSER CREATEDB;" | postgresql_execute "" "postgres" "$postgres_password"
# set the repmgr user's search path to include the 'repmgr' schema name (ref: https://repmgr.org/docs/4.3/quickstart-repmgr-user-database.html)
echo "ALTER USER ${REPMGR_USERNAME} SET search_path TO repmgr, \"\$user\", public;" | postgresql_execute "" "postgres" "$postgres_password"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,8 @@ repmgr_create_repmgr_user() {
[[ "$POSTGRESQL_USERNAME" != "postgres" ]] && [[ -n "$POSTGRESQL_POSTGRES_PASSWORD" ]] && postgres_password="$POSTGRESQL_POSTGRES_PASSWORD"
# The repmgr user is created as superuser for simplicity (ref: https://repmgr.org/docs/4.3/quickstart-repmgr-user-database.html)
# In case REPMGR_USERNAME == POSTGRESQL_REPLICATION_USER, we just need to grant repmgr with CREATEDB
if [[ "$REPMGR_USERNAME" == "$POSTGRESQL_REPLICATION_USER" ]]; then
echo "ALTER USER ${REPMGR_USERNAME} WITH CREATEDB;" | postgresql_execute "" "postgres" "$postgres_password"
else
echo "CREATE ROLE \"${REPMGR_USERNAME}\" WITH LOGIN CREATEDB PASSWORD '${escaped_password}';" | postgresql_execute "" "postgres" "$postgres_password"
fi
echo "ALTER USER ${REPMGR_USERNAME} WITH SUPERUSER;" | postgresql_execute "" "postgres" "$postgres_password"
postgresql_ensure_user_exists "$REPMGR_USERNAME" --password "$postgres_password"
echo "ALTER USER ${REPMGR_USERNAME} WITH SUPERUSER CREATEDB;" | postgresql_execute "" "postgres" "$postgres_password"
# set the repmgr user's search path to include the 'repmgr' schema name (ref: https://repmgr.org/docs/4.3/quickstart-repmgr-user-database.html)
echo "ALTER USER ${REPMGR_USERNAME} SET search_path TO repmgr, \"\$user\", public;" | postgresql_execute "" "postgres" "$postgres_password"
}
Expand Down

0 comments on commit 8188e1c

Please sign in to comment.