diff --git a/bitnami/postgresql-repmgr/11/debian-10/Dockerfile b/bitnami/postgresql-repmgr/11/debian-10/Dockerfile index c6d383938376..6f13317b26e3 100644 --- a/bitnami/postgresql-repmgr/11/debian-10/Dockerfile +++ b/bitnami/postgresql-repmgr/11/debian-10/Dockerfile @@ -9,7 +9,7 @@ ENV HOME="/" \ COPY prebuildfs / # Install required system packages and dependencies RUN install_packages acl ca-certificates curl gzip libbsd0 libc6 libedit2 libffi6 libgcc1 libgmp10 libgnutls30 libhogweed4 libicu63 libidn2-0 libldap-2.4-2 liblzma5 libnettle6 libp11-kit0 libpcre3 libreadline7 libsasl2-2 libsqlite3-0 libssl1.1 libstdc++6 libtasn1-6 libtinfo6 libunistring2 libuuid1 libxml2 libxslt1.1 locales procps tar zlib1g -RUN . /opt/bitnami/scripts/libcomponent.sh && component_unpack "postgresql-repmgr" "11.13.0-5" --checksum 8fe2dc798f4a3b31cd9fb29f2b5ff8a0f1b86021608fa0134e6117f3acbe7417 +RUN . /opt/bitnami/scripts/libcomponent.sh && component_unpack "postgresql-repmgr" "11.14.0-0" --checksum 5a7139378a9a21a9d9bbd8c382991b067705fdf4d88191eb423f04a694963688 RUN . /opt/bitnami/scripts/libcomponent.sh && component_unpack "gosu" "1.14.0-0" --checksum 3e6fc37ca073b10a73a804d39c2f0c028947a1a596382a4f8ebe43dfbaa3a25e RUN chmod g+rwX /opt/bitnami RUN localedef -c -f UTF-8 -i en_US en_US.UTF-8 @@ -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="11.13.0-debian-10-r58" \ + BITNAMI_IMAGE_VERSION="11.14.0-debian-10-r0" \ LANG="en_US.UTF-8" \ LANGUAGE="en_US:en" \ NSS_WRAPPER_LIB="/opt/bitnami/common/lib/libnss_wrapper.so" \ diff --git a/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/.bitnami_components.json b/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/.bitnami_components.json index 779cff0f7a8e..ca8debbdd2a2 100644 --- a/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/.bitnami_components.json +++ b/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/.bitnami_components.json @@ -8,9 +8,9 @@ }, "postgresql-repmgr": { "arch": "amd64", - "digest": "8fe2dc798f4a3b31cd9fb29f2b5ff8a0f1b86021608fa0134e6117f3acbe7417", + "digest": "5a7139378a9a21a9d9bbd8c382991b067705fdf4d88191eb423f04a694963688", "distro": "debian-10", "type": "NAMI", - "version": "11.13.0-5" + "version": "11.14.0-0" } } \ No newline at end of file diff --git a/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/scripts/libfs.sh b/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/scripts/libfs.sh index ae5e2459c377..b438c913341d 100644 --- a/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/scripts/libfs.sh +++ b/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/scripts/libfs.sh @@ -50,8 +50,9 @@ ensure_dir_exists() { # boolean ######################### is_dir_empty() { - local dir="${1:?missing directory}" - + local -r path="${1:?missing directory}" + # Calculate real path in order to avoid issues with symlinks + local -r dir="$(realpath "$path")" if [[ ! -e "$dir" ]] || [[ -z "$(ls -A "$dir")" ]]; then true else @@ -88,7 +89,7 @@ is_file_writable() { local dir dir="$(dirname "$file")" - if [[ ( -f "$file" && -w "$file" ) || ( ! -f "$file" && -d "$dir" && -w "$dir" ) ]]; then + if [[ (-f "$file" && -w "$file") || (! -f "$file" && -d "$dir" && -w "$dir") ]]; then true else false @@ -136,31 +137,31 @@ configure_permissions_ownership() { shift 1 while [ "$#" -gt 0 ]; do case "$1" in - -f|--file-mode) - shift - file_mode="${1:?missing mode for files}" - ;; - -d|--dir-mode) - shift - dir_mode="${1:?missing mode for directories}" - ;; - -u|--user) - shift - user="${1:?missing user}" - ;; - -g|--group) - shift - group="${1:?missing group}" - ;; - *) - echo "Invalid command line flag $1" >&2 - return 1 - ;; + -f | --file-mode) + shift + file_mode="${1:?missing mode for files}" + ;; + -d | --dir-mode) + shift + dir_mode="${1:?missing mode for directories}" + ;; + -u | --user) + shift + user="${1:?missing user}" + ;; + -g | --group) + shift + group="${1:?missing group}" + ;; + *) + echo "Invalid command line flag $1" >&2 + return 1 + ;; esac shift done - read -r -a filepaths <<< "$paths" + read -r -a filepaths <<<"$paths" for p in "${filepaths[@]}"; do if [[ -e "$p" ]]; then if [[ -n $dir_mode ]]; then diff --git a/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/scripts/libnet.sh b/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/scripts/libnet.sh index 4391dacc7853..8bbf165e3e2a 100644 --- a/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/scripts/libnet.sh +++ b/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/scripts/libnet.sh @@ -140,3 +140,24 @@ parse_uri() { esac [[ "$uri" =~ $URI_REGEX ]] && echo "${BASH_REMATCH[${index}]}" } + +######################## +# Wait for a HTTP connection to succeed +# Globals: +# * +# Arguments: +# $1 - URL to wait for +# $2 - Maximum amount of retries (optional) +# $3 - Time between retries (optional) +# Returns: +# true if the HTTP connection succeeded, false otherwise +######################### +wait_for_http_connection() { + local url="${1:?missing url}" + local retries="${2:-}" + local sleep_time="${3:-}" + if ! retry_while "debug_execute curl --silent ${url}" "$retries" "$sleep_time"; then + error "Could not connect to ${url}" + return 1 + fi +} diff --git a/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/scripts/libservice.sh b/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/scripts/libservice.sh index 0b96a0be09e0..a713bd108e15 100644 --- a/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/scripts/libservice.sh +++ b/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/scripts/libservice.sh @@ -158,7 +158,7 @@ remove_cron_conf() { # $3 - Start command # $4 - Stop command # Flags: -# --disabled - Whether to disable the monit configuration +# --disable - Whether to disable the monit configuration # Returns: # None ######################### @@ -174,9 +174,8 @@ generate_monit_conf() { shift 4 while [[ "$#" -gt 0 ]]; do case "$1" in - --disabled) - shift - disabled="$1" + --disable) + disabled="yes" ;; *) echo "Invalid command line flag ${1}" >&2 diff --git a/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/scripts/libwebserver.sh b/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/scripts/libwebserver.sh index dc322c377b1b..459f99c7d1cd 100644 --- a/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/scripts/libwebserver.sh +++ b/bitnami/postgresql-repmgr/11/debian-10/prebuildfs/opt/bitnami/scripts/libwebserver.sh @@ -164,24 +164,27 @@ web_server_reload() { # Arguments: # $1 - App name # Flags: -# --hosts - Hosts to enable # --type - Application type, which has an effect on which configuration template to use +# --hosts - Host listen addresses +# --server-name - Server name +# --server-aliases - Server aliases # --allow-remote-connections - Whether to allow remote connections or to require local connections -# --disabled - Whether to render the file with a .disabled prefix -# --enable-https - Enable app configuration on HTTPS port +# --disable - Whether to render server configurations with a .disabled prefix +# --disable-http - Whether to render the app's HTTP server configuration with a .disabled prefix +# --disable-https - Whether to render the app's HTTPS server configuration with a .disabled prefix # --http-port - HTTP port number # --https-port - HTTPS port number # --document-root - Path to document root directory # Apache-specific flags: # --apache-additional-configuration - Additional vhost configuration (no default) # --apache-before-vhost-configuration - Configuration to add before the directive (no default) -# --apache-allow-override - Whether to allow .htaccess files (only allowed when --move-htaccess is set to 'no') +# --apache-allow-override - Whether to allow .htaccess files (only allowed when --move-htaccess is set to 'no' and type is not defined) # --apache-extra-directory-configuration - Extra configuration for the document root directory # --apache-proxy-address - Address where to proxy requests # --apache-proxy-configuration - Extra configuration for the proxy # --apache-proxy-http-configuration - Extra configuration for the proxy HTTP vhost # --apache-proxy-https-configuration - Extra configuration for the proxy HTTPS vhost -# --apache-move-htaccess - Move .htaccess files to a common place so they can be loaded during Apache startup +# --apache-move-htaccess - Move .htaccess files to a common place so they can be loaded during Apache startup (only allowed when type is not defined) # NGINX-specific flags: # --nginx-additional-configuration - Additional server block configuration (no default) # --nginx-external-configuration - Configuration external to server block (no default) @@ -198,11 +201,18 @@ ensure_web_server_app_configuration_exists() { while [[ "$#" -gt 0 ]]; do case "$1" in # Common flags + --disable \ + | --disable-http \ + | --disable-https \ + ) + apache_args+=("$1") + nginx_args+=("$1") + ;; --hosts \ + | --server-name \ + | --server-aliases \ | --type \ | --allow-remote-connections \ - | --disabled \ - | --enable-https \ | --http-port \ | --https-port \ | --document-root \ @@ -347,8 +357,13 @@ ensure_web_server_prefix_configuration_exists() { # Arguments: # $1 - App name # Flags: -# --hosts - Hosts to enable -# --enable-https - Update HTTPS app configuration +# --hosts - Host listen addresses +# --server-name - Server name +# --server-aliases - Server aliases +# --enable-http - Enable HTTP app configuration (if not enabled already) +# --enable-https - Enable HTTPS app configuration (if not enabled already) +# --disable-http - Disable HTTP app configuration (if not disabled already) +# --disable-https - Disable HTTPS app configuration (if not disabled already) # --http-port - HTTP port number # --https-port - HTTPS port number # Returns: @@ -363,8 +378,20 @@ web_server_update_app_configuration() { while [[ "$#" -gt 0 ]]; do case "$1" in # Common flags - --hosts \ + --enable-http \ | --enable-https \ + | --disable-http \ + | --disable-https \ + ) + args+=("$1") + ;; + --hosts \ + | --server-name \ + | --server-aliases \ + | --enable-http \ + | --enable-https \ + | --disable-http \ + | --disable-https \ | --http-port \ | --https-port \ ) diff --git a/bitnami/postgresql-repmgr/11/debian-10/rootfs/opt/bitnami/scripts/libpostgresql.sh b/bitnami/postgresql-repmgr/11/debian-10/rootfs/opt/bitnami/scripts/libpostgresql.sh index 2a4f52aa35e6..45b1377ee5c2 100644 --- a/bitnami/postgresql-repmgr/11/debian-10/rootfs/opt/bitnami/scripts/libpostgresql.sh +++ b/bitnami/postgresql-repmgr/11/debian-10/rootfs/opt/bitnami/scripts/libpostgresql.sh @@ -897,6 +897,7 @@ postgresql_configure_recovery() { else cp -f "$POSTGRESQL_BASE_DIR/share/recovery.conf.sample" "$POSTGRESQL_RECOVERY_FILE" chmod 600 "$POSTGRESQL_RECOVERY_FILE" + am_i_root && chown "$POSTGRESQL_DAEMON_USER:$POSTGRESQL_DAEMON_GROUP" "$POSTGRESQL_RECOVERY_FILE" postgresql_set_property "standby_mode" "on" "$POSTGRESQL_RECOVERY_FILE" postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} password=${POSTGRESQL_REPLICATION_PASSWORD} application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_RECOVERY_FILE" postgresql_set_property "trigger_file" "/tmp/postgresql.trigger.${POSTGRESQL_MASTER_PORT_NUMBER}" "$POSTGRESQL_RECOVERY_FILE" @@ -1255,6 +1256,7 @@ EOF fi } + ######################## # Retrieves the WAL directory in use by PostgreSQL / to use if not initialized yet # Globals: @@ -1265,8 +1267,8 @@ EOF # the path to the WAL directory, or empty if not set ######################### postgresql_get_waldir() { - if [[ -L "$POSTGRESQL_DATA_DIR/pg_wal" && -d "$POSTGRESQL_DATA_DIR/pg_wal" ]]; then - readlink -f "$POSTGRESQL_DATA_DIR/pg_wal" + if [[ -L "${POSTGRESQL_DATA_DIR}/pg_wal" && -d "${POSTGRESQL_DATA_DIR}/pg_wal" ]]; then + readlink -f "${POSTGRESQL_DATA_DIR}/pg_wal" else # Uninitialized - using value from $POSTGRESQL_INITDB_WAL_DIR if set echo "$POSTGRESQL_INITDB_WAL_DIR" diff --git a/bitnami/postgresql-repmgr/11/debian-10/rootfs/opt/bitnami/scripts/librepmgr.sh b/bitnami/postgresql-repmgr/11/debian-10/rootfs/opt/bitnami/scripts/librepmgr.sh index 267d38d257af..ef7d50169c7c 100644 --- a/bitnami/postgresql-repmgr/11/debian-10/rootfs/opt/bitnami/scripts/librepmgr.sh +++ b/bitnami/postgresql-repmgr/11/debian-10/rootfs/opt/bitnami/scripts/librepmgr.sh @@ -400,6 +400,24 @@ local all all trust EOF } +######################## +# Check if a given configuration file was mounted externally +# Globals: +# REPMGR_MOUNTED_CONF_DIR +# Arguments: +# $1 - Filename +# Returns: +# 1 if the file was mounted externally, 0 otherwise +######################### +repmgr_is_file_external() { + local -r filename=$1 + if [[ -d "$REPMGR_MOUNTED_CONF_DIR" ]] && [[ -f "$REPMGR_MOUNTED_CONF_DIR"/"$filename" ]]; then + return 0 + else + return 1 + fi +} + ######################## # Prepare PostgreSQL default configuration # Globals: @@ -418,12 +436,12 @@ repmgr_postgresql_configuration() { debug "User injected custom configuration detected!" fi ensure_dir_exists "$POSTGRESQL_MOUNTED_CONF_DIR" - if [[ -f "${REPMGR_MOUNTED_CONF_DIR}/postgresql.conf" ]]; then + if repmgr_is_file_external "postgresql.conf"; then cp "${REPMGR_MOUNTED_CONF_DIR}/postgresql.conf" "${POSTGRESQL_MOUNTED_CONF_DIR}/postgresql.conf" else repmgr_inject_postgresql_configuration fi - if [[ -f "${REPMGR_MOUNTED_CONF_DIR}/pg_hba.conf" ]]; then + if repmgr_is_file_external "pg_hba.conf"; then cp "${REPMGR_MOUNTED_CONF_DIR}/pg_hba.conf" "${POSTGRESQL_MOUNTED_CONF_DIR}/pg_hba.conf" else repmgr_inject_pghba_configuration @@ -447,7 +465,7 @@ repmgr_postgresql_configuration() { repmgr_generate_repmgr_config() { info "Preparing repmgr configuration..." - # If using a distinct WAL directory ($POSTGRESQL_DATA_DIR/pg_wal is a symlink to an existing dir or $POSTGRESQL_INITDB_WAL_DIR when not initialized), + # If using a distinct WAL directory (${POSTGRESQL_DATA_DIR}/pg_wal is a symlink to an existing dir or $POSTGRESQL_INITDB_WAL_DIR is set a custom value during 1st boot), # set the "--waldir" option accordingly local -r waldir=$(postgresql_get_waldir) local -r waldir_option=$([[ -n "$waldir" ]] && echo "--waldir=$waldir") @@ -683,7 +701,7 @@ repmgr_initialize() { fi fi postgresql_initialize - if ! postgresql_is_file_external "postgresql.conf"; then + if ! repmgr_is_file_external "postgresql.conf"; then # Allow remote connections, required to register primary and standby nodes postgresql_enable_remote_connections # Configure port and restrict access to PostgreSQL (MD5) @@ -692,7 +710,7 @@ repmgr_initialize() { postgresql_configure_replication_parameters postgresql_configure_fsync fi - if ! postgresql_is_file_external "pg_hba.conf"; then + if ! repmgr_is_file_external "pg_hba.conf"; then is_boolean_yes "$REPMGR_PGHBA_TRUST_ALL" || postgresql_restrict_pghba fi if [[ "$REPMGR_ROLE" = "primary" ]]; then diff --git a/bitnami/postgresql-repmgr/README.md b/bitnami/postgresql-repmgr/README.md index 2e8f1fdc1f68..5fe495ba4316 100644 --- a/bitnami/postgresql-repmgr/README.md +++ b/bitnami/postgresql-repmgr/README.md @@ -50,7 +50,7 @@ Learn more about the Bitnami tagging policy and the difference between rolling t * [`14`, `14-debian-10`, `14.1.0`, `14.1.0-debian-10-r2` (14/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql-repmgr/blob/14.1.0-debian-10-r2/14/debian-10/Dockerfile) * [`13`, `13-debian-10`, `13.5.0`, `13.5.0-debian-10-r2` (13/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql-repmgr/blob/13.5.0-debian-10-r2/13/debian-10/Dockerfile) * [`12`, `12-debian-10`, `12.9.0`, `12.9.0-debian-10-r3` (12/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql-repmgr/blob/12.9.0-debian-10-r3/12/debian-10/Dockerfile) -* [`11`, `11-debian-10`, `11.14.0`, `11.14.0-debian-10-r-1`, `latest` (11/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql-repmgr/blob/11.14.0-debian-10-r-1/11/debian-10/Dockerfile) +* [`11`, `11-debian-10`, `11.14.0`, `11.14.0-debian-10-r0`, `latest` (11/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql-repmgr/blob/11.14.0-debian-10-r0/11/debian-10/Dockerfile) * [`10`, `10-debian-10`, `10.19.0`, `10.19.0-debian-10-r3` (10/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql-repmgr/blob/10.19.0-debian-10-r3/10/debian-10/Dockerfile) * [`9.6`, `9.6-debian-10`, `9.6.24`, `9.6.24-debian-10-r3` (9.6/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql-repmgr/blob/9.6.24-debian-10-r3/9.6/debian-10/Dockerfile)