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 <yukha.dw@samsung.com>
  • Loading branch information
yukha-dw committed Oct 29, 2024
1 parent c41d3eb commit ec8e7c6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,12 @@ 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)
echo "CREATE ROLE \"${REPMGR_USERNAME}\" WITH LOGIN CREATEDB PASSWORD '${escaped_password}';" | postgresql_execute "" "postgres" "$postgres_password"
# 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"
# 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,7 +348,12 @@ 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)
echo "CREATE ROLE \"${REPMGR_USERNAME}\" WITH LOGIN CREATEDB PASSWORD '${escaped_password}';" | postgresql_execute "" "postgres" "$postgres_password"
# 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"
# 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,7 +348,12 @@ 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)
echo "CREATE ROLE \"${REPMGR_USERNAME}\" WITH LOGIN CREATEDB PASSWORD '${escaped_password}';" | postgresql_execute "" "postgres" "$postgres_password"
# 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"
# 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,7 +348,12 @@ 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)
echo "CREATE ROLE \"${REPMGR_USERNAME}\" WITH LOGIN CREATEDB PASSWORD '${escaped_password}';" | postgresql_execute "" "postgres" "$postgres_password"
# 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"
# 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,7 +348,12 @@ 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)
echo "CREATE ROLE \"${REPMGR_USERNAME}\" WITH LOGIN CREATEDB PASSWORD '${escaped_password}';" | postgresql_execute "" "postgres" "$postgres_password"
# 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"
# 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 ec8e7c6

Please sign in to comment.