13.2.0-debian-10-r40 release
This commit is contained in:
parent
179250cf8a
commit
91fce145e4
|
|
@ -22,7 +22,7 @@ COPY rootfs /
|
|||
RUN /opt/bitnami/scripts/postgresql-repmgr/postunpack.sh
|
||||
RUN /opt/bitnami/scripts/locales/add-extra-locales.sh
|
||||
ENV BITNAMI_APP_NAME="postgresql-repmgr" \
|
||||
BITNAMI_IMAGE_VERSION="13.2.0-debian-10-r39" \
|
||||
BITNAMI_IMAGE_VERSION="13.2.0-debian-10-r40" \
|
||||
LANG="en_US.UTF-8" \
|
||||
LANGUAGE="en_US:en" \
|
||||
NSS_WRAPPER_LIB="/opt/bitnami/common/lib/libnss_wrapper.so" \
|
||||
|
|
|
|||
|
|
@ -357,19 +357,6 @@ postgresql_create_replication_user() {
|
|||
echo "CREATE ROLE \"$POSTGRESQL_REPLICATION_USER\" REPLICATION LOGIN ENCRYPTED PASSWORD '$escaped_password'" | postgresql_execute
|
||||
}
|
||||
|
||||
########################
|
||||
# Return PostgreSQL major version
|
||||
# Globals:
|
||||
# POSTGRESQL_*
|
||||
# Arguments:
|
||||
# None
|
||||
# Returns:
|
||||
# String
|
||||
#########################
|
||||
postgresql_get_major_version() {
|
||||
psql --version | grep -oE "[0-9]+\.[0-9]+" | grep -oE "^[0-9]+"
|
||||
}
|
||||
|
||||
########################
|
||||
# Change postgresql.conf by setting replication parameters
|
||||
# Globals:
|
||||
|
|
@ -493,7 +480,7 @@ postgresql_create_admin_user() {
|
|||
# None
|
||||
#########################
|
||||
postgresql_create_custom_database() {
|
||||
echo "CREATE DATABASE \"$POSTGRESQL_DATABASE\"" | postgresql_execute "" "postgres" "" "localhost"
|
||||
echo "CREATE DATABASE \"$POSTGRESQL_DATABASE\"" | postgresql_execute "" "postgres" ""
|
||||
}
|
||||
|
||||
########################
|
||||
|
|
@ -732,43 +719,6 @@ postgresql_stop() {
|
|||
fi
|
||||
}
|
||||
|
||||
########################
|
||||
# Execute an arbitrary query/queries against the running PostgreSQL service
|
||||
# Stdin:
|
||||
# Query/queries to execute
|
||||
# Globals:
|
||||
# BITNAMI_DEBUG
|
||||
# POSTGRESQL_*
|
||||
# Arguments:
|
||||
# $1 - Database where to run the queries
|
||||
# $2 - User to run queries
|
||||
# $3 - Password
|
||||
# $4 - Host
|
||||
# $5 - Port
|
||||
# $6 - Extra options (eg. -tA)
|
||||
# Returns:
|
||||
# None
|
||||
postgresql_execute() {
|
||||
local -r db="${1:-}"
|
||||
local -r user="${2:-postgres}"
|
||||
local -r pass="${3:-}"
|
||||
local -r host="${4:-localhost}"
|
||||
local -r port="${5:-5432}"
|
||||
local -r opts="${6:-}"
|
||||
|
||||
local args=("-h" "$host" "-p" "$port" "-U" "$user")
|
||||
local cmd=("$POSTGRESQL_BIN_DIR/psql")
|
||||
[[ -n "$db" ]] && args+=("-d" "$db")
|
||||
[[ -n "$opts" ]] && args+=("$opts")
|
||||
if [[ "${BITNAMI_DEBUG:-false}" = true ]]; then
|
||||
PGPASSWORD=$pass "${cmd[@]}" "${args[@]}"
|
||||
elif [[ "${NO_ERRORS:-false}" = true ]]; then
|
||||
PGPASSWORD=$pass "${cmd[@]}" "${args[@]}" 2>/dev/null
|
||||
else
|
||||
PGPASSWORD=$pass "${cmd[@]}" "${args[@]}" >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
########################
|
||||
# Start PostgreSQL and wait until it is ready
|
||||
# Globals:
|
||||
|
|
@ -1015,3 +965,288 @@ postgresql_remove_pghba_lines() {
|
|||
echo "$result" >"$POSTGRESQL_PGHBA_FILE"
|
||||
done
|
||||
}
|
||||
|
||||
########################
|
||||
# Return PostgreSQL major version
|
||||
# Globals:
|
||||
# POSTGRESQL_*
|
||||
# Arguments:
|
||||
# None
|
||||
# Returns:
|
||||
# String
|
||||
#########################
|
||||
postgresql_get_major_version() {
|
||||
psql --version | grep -oE "[0-9]+\.[0-9]+" | grep -oE "^[0-9]+"
|
||||
}
|
||||
|
||||
########################
|
||||
# Gets an environment variable name based on the suffix
|
||||
# Arguments:
|
||||
# $1 - environment variable suffix
|
||||
# Returns:
|
||||
# environment variable name
|
||||
#########################
|
||||
get_env_var_value() {
|
||||
local env_var_suffix="${1:?missing suffix}"
|
||||
local env_var_name
|
||||
for env_var_prefix in POSTGRESQL POSTGRESQL_CLIENT; do
|
||||
env_var_name="${env_var_prefix}_${env_var_suffix}"
|
||||
if [[ -n "${!env_var_name:-}" ]]; then
|
||||
echo "${!env_var_name}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
########################
|
||||
# Execute an arbitrary query/queries against the running PostgreSQL service and print the output
|
||||
# Stdin:
|
||||
# Query/queries to execute
|
||||
# Globals:
|
||||
# BITNAMI_DEBUG
|
||||
# POSTGRESQL_*
|
||||
# Arguments:
|
||||
# $1 - Database where to run the queries
|
||||
# $2 - User to run queries
|
||||
# $3 - Password
|
||||
# $4 - Extra options (eg. -tA)
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
postgresql_execute_print_output() {
|
||||
local -r db="${1:-}"
|
||||
local -r user="${2:-postgres}"
|
||||
local -r pass="${3:-}"
|
||||
local opts
|
||||
read -r -a opts <<< "${@:4}"
|
||||
|
||||
local args=("-U" "$user")
|
||||
[[ -n "$db" ]] && args+=("-d" "$db")
|
||||
[[ "${#opts[@]}" -gt 0 ]] && args+=( "${opts[@]}" )
|
||||
|
||||
# Obtain the command specified via stdin
|
||||
local sql_cmd
|
||||
sql_cmd="$(< /dev/stdin)"
|
||||
debug "Executing SQL command:\n$sql_cmd"
|
||||
PGPASSWORD=$pass psql "${args[@]}" <<< "$sql_cmd"
|
||||
}
|
||||
|
||||
########################
|
||||
# Execute an arbitrary query/queries against the running PostgreSQL service
|
||||
# Stdin:
|
||||
# Query/queries to execute
|
||||
# Globals:
|
||||
# BITNAMI_DEBUG
|
||||
# POSTGRESQL_*
|
||||
# Arguments:
|
||||
# $1 - Database where to run the queries
|
||||
# $2 - User to run queries
|
||||
# $3 - Password
|
||||
# $4 - Extra options (eg. -tA)
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
postgresql_execute() {
|
||||
if [[ "${BITNAMI_DEBUG:-false}" = true ]]; then
|
||||
"postgresql_execute_print_output" "$@"
|
||||
elif [[ "${NO_ERRORS:-false}" = true ]]; then
|
||||
"postgresql_execute_print_output" "$@" 2>/dev/null
|
||||
else
|
||||
"postgresql_execute_print_output" "$@" >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
########################
|
||||
# Execute an arbitrary query/queries against a remote PostgreSQL service and print to stdout
|
||||
# Stdin:
|
||||
# Query/queries to execute
|
||||
# Globals:
|
||||
# BITNAMI_DEBUG
|
||||
# DB_*
|
||||
# Arguments:
|
||||
# $1 - Remote PostgreSQL service hostname
|
||||
# $2 - Remote PostgreSQL service port
|
||||
# $3 - Database where to run the queries
|
||||
# $4 - User to run queries
|
||||
# $5 - Password
|
||||
# $6 - Extra options (eg. -tA)
|
||||
# Returns:
|
||||
# None
|
||||
postgresql_remote_execute_print_output() {
|
||||
local -r hostname="${1:?hostname is required}"
|
||||
local -r port="${2:?port is required}"
|
||||
local -a args=("-h" "$hostname" "-p" "$port")
|
||||
shift 2
|
||||
"postgresql_execute_print_output" "$@" "${args[@]}"
|
||||
}
|
||||
|
||||
########################
|
||||
# Execute an arbitrary query/queries against a remote PostgreSQL service
|
||||
# Stdin:
|
||||
# Query/queries to execute
|
||||
# Globals:
|
||||
# BITNAMI_DEBUG
|
||||
# DB_*
|
||||
# Arguments:
|
||||
# $1 - Remote PostgreSQL service hostname
|
||||
# $2 - Remote PostgreSQL service port
|
||||
# $3 - Database where to run the queries
|
||||
# $4 - User to run queries
|
||||
# $5 - Password
|
||||
# $6 - Extra options (eg. -tA)
|
||||
# Returns:
|
||||
# None
|
||||
postgresql_remote_execute() {
|
||||
if [[ "${BITNAMI_DEBUG:-false}" = true ]]; then
|
||||
"postgresql_remote_execute_print_output" "$@"
|
||||
elif [[ "${NO_ERRORS:-false}" = true ]]; then
|
||||
"postgresql_remote_execute_print_output" "$@" 2>/dev/null
|
||||
else
|
||||
"postgresql_remote_execute_print_output" "$@" >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
########################
|
||||
# Optionally create the given database user
|
||||
# Flags:
|
||||
# -p|--password - database password
|
||||
# --host - database host
|
||||
# --port - database port
|
||||
# Arguments:
|
||||
# $1 - user
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
postgresql_ensure_user_exists() {
|
||||
local -r user="${1:?user is missing}"
|
||||
local password=""
|
||||
# For accessing an external database
|
||||
local db_host=""
|
||||
local db_port=""
|
||||
|
||||
# Validate arguments
|
||||
shift 1
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
-p|--password)
|
||||
shift
|
||||
password="${1:?missing password}"
|
||||
;;
|
||||
--host)
|
||||
shift
|
||||
db_host="${1:?missing database host}"
|
||||
;;
|
||||
--port)
|
||||
shift
|
||||
db_port="${1:?missing database port}"
|
||||
;;
|
||||
*)
|
||||
echo "Invalid command line flag $1" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
local -a postgresql_execute_cmd=("postgresql_execute")
|
||||
[[ -n "$db_host" && -n "$db_port" ]] && postgresql_execute_cmd=("postgresql_remote_execute" "$db_host" "$db_port")
|
||||
local -a postgresql_execute_flags=("" "$(get_env_var_value POSTGRES_USER)" "$(get_env_var_value POSTGRES_PASSWORD)")
|
||||
|
||||
"${postgresql_execute_cmd[@]}" "${postgresql_execute_flags[@]}" <<EOF
|
||||
DO
|
||||
\$do\$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT FROM pg_catalog.pg_roles WHERE rolname = '${user}'
|
||||
) THEN
|
||||
CREATE ROLE "${user}" LOGIN PASSWORD '${password}';
|
||||
END IF;
|
||||
END
|
||||
\$do\$;
|
||||
EOF
|
||||
}
|
||||
|
||||
########################
|
||||
# Ensure a user has all privileges to access a database
|
||||
# Arguments:
|
||||
# $1 - database name
|
||||
# $2 - database user
|
||||
# $3 - database host (optional)
|
||||
# $4 - database port (optional)
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
postgresql_ensure_user_has_database_privileges() {
|
||||
local -r user="${1:?user is required}"
|
||||
local -r database="${2:?db is required}"
|
||||
local -r db_host="${3:-}"
|
||||
local -r db_port="${4:-}"
|
||||
|
||||
local -a postgresql_execute_cmd=("postgresql_execute")
|
||||
[[ -n "$db_host" && -n "$db_port" ]] && postgresql_execute_cmd=("postgresql_remote_execute" "$db_host" "$db_port")
|
||||
local -a postgresql_execute_flags=("" "$(get_env_var_value POSTGRES_USER)" "$(get_env_var_value POSTGRES_PASSWORD)")
|
||||
|
||||
debug "Providing privileges to username ${user} on database ${database}"
|
||||
"${postgresql_execute_cmd[@]}" "${postgresql_execute_flags[@]}" <<EOF
|
||||
GRANT ALL PRIVILEGES ON DATABASE "${database}" TO "${user}";
|
||||
EOF
|
||||
}
|
||||
|
||||
########################
|
||||
# Optionally create the given database, and then optionally give a user
|
||||
# full privileges on the database.
|
||||
# Flags:
|
||||
# -u|--user - database user
|
||||
# --host - database host
|
||||
# --port - database port
|
||||
# Arguments:
|
||||
# $1 - database name
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
postgresql_ensure_database_exists() {
|
||||
local -r database="${1:?database is missing}"
|
||||
local user=""
|
||||
# For accessing an external database
|
||||
local db_host=""
|
||||
local db_port=""
|
||||
|
||||
# Validate arguments
|
||||
shift 1
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
-u|--user)
|
||||
shift
|
||||
user="${1:?missing database user}"
|
||||
;;
|
||||
--host)
|
||||
shift
|
||||
db_host="${1:?missing database host}"
|
||||
;;
|
||||
--port)
|
||||
shift
|
||||
db_port="${1:?missing database port}"
|
||||
;;
|
||||
*)
|
||||
echo "Invalid command line flag $1" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
local -a postgresql_execute_cmd=("postgresql_execute")
|
||||
[[ -n "$db_host" && -n "$db_port" ]] && postgresql_execute_cmd=("postgresql_remote_execute" "$db_host" "$db_port")
|
||||
local -a postgresql_execute_flags=("" "$(get_env_var_value POSTGRES_USER)" "$(get_env_var_value POSTGRES_PASSWORD)")
|
||||
|
||||
"${postgresql_execute_cmd[@]}" "${postgresql_execute_flags[@]}" <<EOF
|
||||
SELECT 'CREATE DATABASE "${database}"'
|
||||
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '${database}')\gexec
|
||||
EOF
|
||||
if [[ -n "$user" ]]; then
|
||||
local -a grant_flags=("$user" "$database")
|
||||
[[ -n "$db_host" ]] && grant_flags+=("$db_host")
|
||||
[[ -n "$db_port" ]] && grant_flags+=("$db_port")
|
||||
postgresql_ensure_user_has_database_privileges "${grant_flags[@]}"
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ repmgr_get_upstream_node() {
|
|||
port="${port:-$REPMGR_PRIMARY_PORT}"
|
||||
debug "Checking node '$host:$port'..."
|
||||
local query="SELECT conninfo FROM repmgr.show_nodes WHERE (upstream_node_name IS NULL OR upstream_node_name = '') AND active=true"
|
||||
if ! primary_conninfo="$(echo "$query" | NO_ERRORS=true postgresql_execute "$REPMGR_DATABASE" "$REPMGR_USERNAME" "$REPMGR_PASSWORD" "$host" "$port" "-tA")"; then
|
||||
if ! primary_conninfo="$(echo "$query" | NO_ERRORS=true postgresql_remote_execute "$host" "$port" "$REPMGR_DATABASE" "$REPMGR_USERNAME" "$REPMGR_PASSWORD" "-tA")"; then
|
||||
debug "Skipping: failed to get primary from the node '$host:$port'!"
|
||||
continue
|
||||
elif [[ -z "$primary_conninfo" ]]; then
|
||||
|
|
@ -496,7 +496,7 @@ repmgr_wait_primary_node() {
|
|||
debug "Wait for schema $REPMGR_DATABASE.repmgr on '${REPMGR_CURRENT_PRIMARY_HOST}:${REPMGR_CURRENT_PRIMARY_PORT}', will try $max_tries times with $step delay seconds (TIMEOUT=$timeout)"
|
||||
for ((i = 0 ; i <= timeout ; i+=step )); do
|
||||
local query="SELECT 1 FROM information_schema.schemata WHERE catalog_name='$REPMGR_DATABASE' AND schema_name='repmgr'"
|
||||
if ! schemata="$(echo "$query" | NO_ERRORS=true postgresql_execute "$REPMGR_DATABASE" "$REPMGR_USERNAME" "$REPMGR_PASSWORD" "$REPMGR_CURRENT_PRIMARY_HOST" "$REPMGR_CURRENT_PRIMARY_PORT" "-tA")"; then
|
||||
if ! schemata="$(echo "$query" | NO_ERRORS=true postgresql_remote_execute "$REPMGR_CURRENT_PRIMARY_HOST" "$REPMGR_CURRENT_PRIMARY_PORT" "$REPMGR_DATABASE" "$REPMGR_USERNAME" "$REPMGR_PASSWORD" "-tA")"; then
|
||||
debug "Host '${REPMGR_CURRENT_PRIMARY_HOST}:${REPMGR_CURRENT_PRIMARY_PORT}' is not accessible"
|
||||
else
|
||||
if [[ $schemata -ne 1 ]]; then
|
||||
|
|
|
|||
|
|
@ -190,7 +190,6 @@ done
|
|||
unset postgresql_env_vars
|
||||
|
||||
# Paths
|
||||
export PATH="/opt/bitnami/postgresql/bin:/opt/bitnami/common/bin:$PATH"
|
||||
export POSTGRESQL_VOLUME_DIR="/bitnami/postgresql"
|
||||
export POSTGRESQL_BASE_DIR="/opt/bitnami/postgresql"
|
||||
POSTGRESQL_DATA_DIR="${POSTGRESQL_DATA_DIR:-"${POSTGRES_DATA_DIR:-}"}"
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ Bitnami containers can be used with [Kubeapps](https://kubeapps.com/) for deploy
|
|||
Learn more about the Bitnami tagging policy and the difference between rolling tags and immutable tags [in our documentation page](https://docs.bitnami.com/tutorials/understand-rolling-tags-containers/).
|
||||
|
||||
|
||||
* [`13`, `13-debian-10`, `13.2.0`, `13.2.0-debian-10-r39` (13/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql-repmgr/blob/13.2.0-debian-10-r39/13/debian-10/Dockerfile)
|
||||
* [`13`, `13-debian-10`, `13.2.0`, `13.2.0-debian-10-r40` (13/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql-repmgr/blob/13.2.0-debian-10-r40/13/debian-10/Dockerfile)
|
||||
* [`12`, `12-debian-10`, `12.6.0`, `12.6.0-debian-10-r41` (12/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql-repmgr/blob/12.6.0-debian-10-r41/12/debian-10/Dockerfile)
|
||||
* [`11`, `11-debian-10`, `11.11.0`, `11.11.0-debian-10-r40`, `latest` (11/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql-repmgr/blob/11.11.0-debian-10-r40/11/debian-10/Dockerfile)
|
||||
* [`10`, `10-debian-10`, `10.16.0`, `10.16.0-debian-10-r41` (10/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql-repmgr/blob/10.16.0-debian-10-r41/10/debian-10/Dockerfile)
|
||||
|
|
|
|||
Loading…
Reference in New Issue