10.13.0-debian-10-r33 release
This commit is contained in:
parent
6251bb264d
commit
027c1874a5
|
|
@ -22,7 +22,7 @@ RUN echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen && locale-gen
|
|||
COPY rootfs /
|
||||
RUN /opt/bitnami/scripts/postgresql/postunpack.sh
|
||||
ENV BITNAMI_APP_NAME="postgresql" \
|
||||
BITNAMI_IMAGE_VERSION="10.13.0-debian-10-r32" \
|
||||
BITNAMI_IMAGE_VERSION="10.13.0-debian-10-r33" \
|
||||
LANG="en_US.UTF-8" \
|
||||
LANGUAGE="en_US:en" \
|
||||
NSS_WRAPPER_LIB="/opt/bitnami/common/lib/libnss_wrapper.so" \
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
# Bitnami PostgreSQL library
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
# shellcheck disable=SC1090
|
||||
|
||||
# Load Generic Libraries
|
||||
. /opt/bitnami/scripts/libfile.sh
|
||||
|
|
@ -12,23 +13,6 @@
|
|||
. /opt/bitnami/scripts/libservice.sh
|
||||
. /opt/bitnami/scripts/libvalidations.sh
|
||||
|
||||
|
||||
########################
|
||||
# Overwrite info, debug, warn and error functions (liblog.sh)
|
||||
########################
|
||||
postgresql_info() {
|
||||
MODULE=postgresql info "${*}"
|
||||
}
|
||||
postgresql_debug() {
|
||||
MODULE=postgresql debug "${*}"
|
||||
}
|
||||
postgresql_warn() {
|
||||
MODULE=postgresql warn "${*}"
|
||||
}
|
||||
postgresql_error() {
|
||||
MODULE=postgresql error "${*}"
|
||||
}
|
||||
|
||||
########################
|
||||
# Configure libnss_wrapper so PostgreSQL commands work with a random user.
|
||||
# Globals:
|
||||
|
|
@ -40,7 +24,7 @@ postgresql_error() {
|
|||
#########################
|
||||
postgresql_enable_nss_wrapper() {
|
||||
if ! getent passwd "$(id -u)" &> /dev/null && [ -e "$NSS_WRAPPER_LIB" ]; then
|
||||
postgresql_debug "Configuring libnss_wrapper..."
|
||||
debug "Configuring libnss_wrapper..."
|
||||
export LD_PRELOAD="$NSS_WRAPPER_LIB"
|
||||
# shellcheck disable=SC2155
|
||||
export NSS_WRAPPER_PASSWD="$(mktemp)"
|
||||
|
|
@ -51,162 +35,6 @@ postgresql_enable_nss_wrapper() {
|
|||
fi
|
||||
}
|
||||
|
||||
########################
|
||||
# Load global variables used on PostgreSQL configuration.
|
||||
# Globals:
|
||||
# POSTGRESQL_*
|
||||
# Arguments:
|
||||
# None
|
||||
# Returns:
|
||||
# Series of exports to be used as 'eval' arguments
|
||||
#########################
|
||||
postgresql_env() {
|
||||
declare_env_alias() {
|
||||
local -r alias="${1:?missing environment variable alias}"
|
||||
local -r original="${2:?missing original environment variable}"
|
||||
|
||||
if printenv "${original}" > /dev/null; then
|
||||
cat << EOF
|
||||
export "${alias}"="\${${original}:-}"
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
# Alias created for official PostgreSQL image compatibility
|
||||
[[ -z "${POSTGRESQL_DATABASE:-}" ]] && declare_env_alias POSTGRESQL_DATABASE POSTGRES_DB
|
||||
[[ -z "${POSTGRESQL_USERNAME:-}" ]] && declare_env_alias POSTGRESQL_USERNAME POSTGRES_USER
|
||||
[[ -z "${POSTGRESQL_DATA_DIR:-}" ]] && declare_env_alias POSTGRESQL_DATA_DIR PGDATA
|
||||
|
||||
local -r suffixes=(
|
||||
"PASSWORD" "POSTGRES_PASSWORD" "INITDB_WAL_DIR" "INITDB_ARGS" "CLUSTER_APP_NAME"
|
||||
"MASTER_HOST" "MASTER_PORT_NUMBER" "NUM_SYNCHRONOUS_REPLICAS"
|
||||
"PORT_NUMBER" "REPLICATION_MODE" "REPLICATION_PASSWORD" "REPLICATION_USER" "FSYNC"
|
||||
"SYNCHRONOUS_COMMIT_MODE" "PASSWORD_FILE" "POSTGRES_PASSWORD_FILE"
|
||||
"REPLICATION_PASSWORD_FILE" "INIT_MAX_TIMEOUT"
|
||||
)
|
||||
for s in "${suffixes[@]}"; do
|
||||
declare_env_alias "POSTGRESQL_${s}" "POSTGRES_${s}"
|
||||
done
|
||||
|
||||
# Ensure the image is compatible with Helm chart 3.x.x series
|
||||
local -r postgresql_data="${POSTGRESQL_DATA_DIR:-${PGDATA:-}}"
|
||||
if [[ -n "${postgresql_data:-}" ]]; then
|
||||
if [[ -d "${postgresql_data}/data" ]] || [[ "${postgresql_data}" = "/bitnami/postgresql" ]]; then
|
||||
postgresql_warn "Data directory is set with a legacy value, adapting POSTGRESQL_DATA_DIR..."
|
||||
postgresql_warn "POSTGRESQL_DATA_DIR set to \"${postgresql_data}/data\"!!"
|
||||
cat << EOF
|
||||
export POSTGRESQL_DATA_DIR="${postgresql_data}/data"
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
cat <<"EOF"
|
||||
# Paths
|
||||
export POSTGRESQL_VOLUME_DIR="${POSTGRESQL_VOLUME_DIR:-/bitnami/postgresql}"
|
||||
export POSTGRESQL_DATA_DIR="${POSTGRESQL_DATA_DIR:-$POSTGRESQL_VOLUME_DIR/data}"
|
||||
export POSTGRESQL_BASE_DIR="/opt/bitnami/postgresql"
|
||||
export POSTGRESQL_CONF_DIR="$POSTGRESQL_BASE_DIR/conf"
|
||||
export POSTGRESQL_MOUNTED_CONF_DIR="/bitnami/postgresql/conf"
|
||||
export POSTGRESQL_CONF_FILE="$POSTGRESQL_CONF_DIR/postgresql.conf"
|
||||
export POSTGRESQL_PGHBA_FILE="$POSTGRESQL_CONF_DIR/pg_hba.conf"
|
||||
export POSTGRESQL_RECOVERY_FILE="$POSTGRESQL_DATA_DIR/recovery.conf"
|
||||
export POSTGRESQL_LOG_DIR="$POSTGRESQL_BASE_DIR/logs"
|
||||
export POSTGRESQL_LOG_FILE="$POSTGRESQL_LOG_DIR/postgresql.log"
|
||||
export POSTGRESQL_TMP_DIR="$POSTGRESQL_BASE_DIR/tmp"
|
||||
export POSTGRESQL_PID_FILE="$POSTGRESQL_TMP_DIR/postgresql.pid"
|
||||
export POSTGRESQL_BIN_DIR="$POSTGRESQL_BASE_DIR/bin"
|
||||
export POSTGRESQL_INITSCRIPTS_DIR=/docker-entrypoint-initdb.d
|
||||
export POSTGRESQL_PREINITSCRIPTS_DIR=/docker-entrypoint-preinitdb.d
|
||||
export PATH="$POSTGRESQL_BIN_DIR:$PATH"
|
||||
|
||||
# Users
|
||||
export POSTGRESQL_DAEMON_USER="postgresql"
|
||||
export POSTGRESQL_DAEMON_GROUP="postgresql"
|
||||
|
||||
# Version
|
||||
export POSTGRESQL_VERSION="$(echo "$BITNAMI_IMAGE_VERSION" | grep -oE "^[0-9]+\.[0-9]+\.[0-9]+")"
|
||||
export POSTGRESQL_MAJOR_VERSION="$(echo "$BITNAMI_IMAGE_VERSION" | grep -oE "^[0-9]+")"
|
||||
|
||||
# Settings
|
||||
export POSTGRESQL_INIT_MAX_TIMEOUT=${POSTGRESQL_INIT_MAX_TIMEOUT:-60}
|
||||
export POSTGRESQL_CLUSTER_APP_NAME=${POSTGRESQL_CLUSTER_APP_NAME:-walreceiver}
|
||||
export POSTGRESQL_DATABASE="${POSTGRESQL_DATABASE:-postgres}"
|
||||
export POSTGRESQL_INITDB_ARGS="${POSTGRESQL_INITDB_ARGS:-}"
|
||||
export ALLOW_EMPTY_PASSWORD="${ALLOW_EMPTY_PASSWORD:-no}"
|
||||
export POSTGRESQL_INITDB_WAL_DIR="${POSTGRESQL_INITDB_WAL_DIR:-}"
|
||||
export POSTGRESQL_MASTER_HOST="${POSTGRESQL_MASTER_HOST:-}"
|
||||
export POSTGRESQL_MASTER_PORT_NUMBER="${POSTGRESQL_MASTER_PORT_NUMBER:-5432}"
|
||||
export POSTGRESQL_NUM_SYNCHRONOUS_REPLICAS="${POSTGRESQL_NUM_SYNCHRONOUS_REPLICAS:-0}"
|
||||
export POSTGRESQL_PORT_NUMBER="${POSTGRESQL_PORT_NUMBER:-5432}"
|
||||
export POSTGRESQL_REPLICATION_MODE="${POSTGRESQL_REPLICATION_MODE:-master}"
|
||||
export POSTGRESQL_REPLICATION_USER="${POSTGRESQL_REPLICATION_USER:-}"
|
||||
export POSTGRESQL_SYNCHRONOUS_COMMIT_MODE="${POSTGRESQL_SYNCHRONOUS_COMMIT_MODE:-on}"
|
||||
export POSTGRESQL_FSYNC="${POSTGRESQL_FSYNC:-on}"
|
||||
export POSTGRESQL_USERNAME="${POSTGRESQL_USERNAME:-postgres}"
|
||||
export POSTGRESQL_ENABLE_LDAP="${POSTGRESQL_ENABLE_LDAP:-no}"
|
||||
export POSTGRESQL_LDAP_URL="${POSTGRESQL_LDAP_URL:-}"
|
||||
export POSTGRESQL_LDAP_PREFIX="${POSTGRESQL_LDAP_PREFIX:-}"
|
||||
export POSTGRESQL_LDAP_SUFFIX="${POSTGRESQL_LDAP_SUFFIX:-}"
|
||||
export POSTGRESQL_LDAP_SERVER="${POSTGRESQL_LDAP_SERVER:-}"
|
||||
export POSTGRESQL_LDAP_PORT="${POSTGRESQL_LDAP_PORT:-}"
|
||||
export POSTGRESQL_LDAP_SCHEME="${POSTGRESQL_LDAP_SCHEME:-}"
|
||||
export POSTGRESQL_LDAP_TLS="${POSTGRESQL_LDAP_TLS:-}"
|
||||
export POSTGRESQL_LDAP_BASE_DN="${POSTGRESQL_LDAP_BASE_DN:-}"
|
||||
export POSTGRESQL_LDAP_BIND_DN="${POSTGRESQL_LDAP_BIND_DN:-}"
|
||||
export POSTGRESQL_LDAP_BIND_PASSWORD="${POSTGRESQL_LDAP_BIND_PASSWORD:-}"
|
||||
export POSTGRESQL_LDAP_SEARCH_ATTR="${POSTGRESQL_LDAP_SEARCH_ATTR:-}"
|
||||
export POSTGRESQL_LDAP_SEARCH_FILTER="${POSTGRESQL_LDAP_SEARCH_FILTER:-}"
|
||||
|
||||
# Internal
|
||||
export POSTGRESQL_FIRST_BOOT="yes"
|
||||
EOF
|
||||
if [[ -z "${POSTGRESQL_INITSCRIPTS_USERNAME:-}" ]]; then
|
||||
cat <<"EOF"
|
||||
export POSTGRESQL_INITSCRIPTS_USERNAME="${POSTGRESQL_USERNAME}"
|
||||
EOF
|
||||
else
|
||||
cat <<"EOF"
|
||||
export POSTGRESQL_INITSCRIPTS_USERNAME="${POSTGRESQL_INITSCRIPTS_USERNAME}"
|
||||
EOF
|
||||
fi
|
||||
if [[ -f "${POSTGRESQL_PASSWORD_FILE:-}" ]]; then
|
||||
cat <<"EOF"
|
||||
export POSTGRESQL_PASSWORD="$(< "${POSTGRESQL_PASSWORD_FILE}")"
|
||||
EOF
|
||||
else
|
||||
cat <<"EOF"
|
||||
export POSTGRESQL_PASSWORD="${POSTGRESQL_PASSWORD:-}"
|
||||
EOF
|
||||
fi
|
||||
if [[ -f "${POSTGRESQL_REPLICATION_PASSWORD_FILE:-}" ]]; then
|
||||
cat <<"EOF"
|
||||
export POSTGRESQL_REPLICATION_PASSWORD="$(< "${POSTGRESQL_REPLICATION_PASSWORD_FILE}")"
|
||||
EOF
|
||||
else
|
||||
cat <<"EOF"
|
||||
export POSTGRESQL_REPLICATION_PASSWORD="${POSTGRESQL_REPLICATION_PASSWORD:-}"
|
||||
EOF
|
||||
fi
|
||||
if [[ -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
|
||||
if [[ -z "${POSTGRESQL_INITSCRIPTS_PASSWORD:-}" ]]; then
|
||||
cat <<"EOF"
|
||||
export POSTGRESQL_INITSCRIPTS_PASSWORD="${POSTGRESQL_PASSWORD:-}"
|
||||
EOF
|
||||
else
|
||||
cat <<"EOF"
|
||||
export POSTGRESQL_INITSCRIPTS_PASSWORD="${POSTGRESQL_INITSCRIPTS_PASSWORD:-}"
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
########################
|
||||
# Validate settings in POSTGRESQL_* environment variables
|
||||
# Globals:
|
||||
|
|
@ -217,17 +45,17 @@ EOF
|
|||
# None
|
||||
#########################
|
||||
postgresql_validate() {
|
||||
postgresql_info "Validating settings in POSTGRESQL_* env vars.."
|
||||
info "Validating settings in POSTGRESQL_* env vars.."
|
||||
local error_code=0
|
||||
|
||||
# Auxiliary functions
|
||||
print_validation_error() {
|
||||
postgresql_error "$1"
|
||||
error "$1"
|
||||
error_code=1
|
||||
}
|
||||
|
||||
empty_password_enabled_warn() {
|
||||
postgresql_warn "You set the environment variable ALLOW_EMPTY_PASSWORD=${ALLOW_EMPTY_PASSWORD}. For safety reasons, do not use this flag in a production environment."
|
||||
warn "You set the environment variable ALLOW_EMPTY_PASSWORD=${ALLOW_EMPTY_PASSWORD}. For safety reasons, do not use this flag in a production environment."
|
||||
}
|
||||
empty_password_error() {
|
||||
print_validation_error "The $1 environment variable is empty or not set. Set the environment variable ALLOW_EMPTY_PASSWORD=yes to allow the container to be started with blank passwords. This is recommended only for development."
|
||||
|
|
@ -301,12 +129,12 @@ postgresql_validate() {
|
|||
# None
|
||||
#########################
|
||||
postgresql_create_config() {
|
||||
postgresql_info "postgresql.conf file not detected. Generating it..."
|
||||
info "postgresql.conf file not detected. Generating it..."
|
||||
cp "$POSTGRESQL_BASE_DIR/share/postgresql.conf.sample" "$POSTGRESQL_CONF_FILE"
|
||||
# Update default value for 'include_dir' directive
|
||||
# ref: https://github.com/postgres/postgres/commit/fb9c475597c245562a28d1e916b575ac4ec5c19f#diff-f5544d9b6d218cc9677524b454b41c60
|
||||
if ! grep include_dir "$POSTGRESQL_CONF_FILE" > /dev/null; then
|
||||
postgresql_error "include_dir line is not present in $POSTGRESQL_CONF_FILE. This may be due to a changes in a new version of PostgreSQL. Please check"
|
||||
error "include_dir line is not present in $POSTGRESQL_CONF_FILE. This may be due to a changes in a new version of PostgreSQL. Please check"
|
||||
exit 1
|
||||
fi
|
||||
local psql_conf
|
||||
|
|
@ -325,7 +153,7 @@ postgresql_create_config() {
|
|||
# None
|
||||
#########################
|
||||
postgresql_ldap_auth_configuration() {
|
||||
postgresql_info "Generating LDAP authentication configuration"
|
||||
info "Generating LDAP authentication configuration"
|
||||
local ldap_configuration=""
|
||||
|
||||
if [[ -n "$POSTGRESQL_LDAP_URL" ]]; then
|
||||
|
|
@ -363,7 +191,7 @@ EOF
|
|||
# None
|
||||
#########################
|
||||
postgresql_password_auth_configuration() {
|
||||
postgresql_info "Generating local authentication configuration"
|
||||
info "Generating local authentication configuration"
|
||||
cat << EOF > "$POSTGRESQL_PGHBA_FILE"
|
||||
host all all 0.0.0.0/0 trust
|
||||
host all all ::/0 trust
|
||||
|
|
@ -380,7 +208,7 @@ EOF
|
|||
# None
|
||||
#########################
|
||||
postgresql_create_pghba() {
|
||||
postgresql_info "pg_hba.conf file not detected. Generating it..."
|
||||
info "pg_hba.conf file not detected. Generating it..."
|
||||
|
||||
if is_boolean_yes "$POSTGRESQL_ENABLE_LDAP"; then
|
||||
postgresql_ldap_auth_configuration
|
||||
|
|
@ -401,6 +229,8 @@ postgresql_create_pghba() {
|
|||
postgresql_allow_local_connection() {
|
||||
cat << EOF >> "$POSTGRESQL_PGHBA_FILE"
|
||||
local all all trust
|
||||
host all all 127.0.0.1/0 trust
|
||||
host all all ::1/128 trust
|
||||
EOF
|
||||
}
|
||||
|
||||
|
|
@ -470,7 +300,7 @@ postgresql_set_property() {
|
|||
#########################
|
||||
postgresql_create_replication_user() {
|
||||
local -r escaped_password="${POSTGRESQL_REPLICATION_PASSWORD//\'/\'\'}"
|
||||
postgresql_info "Creating replication user $POSTGRESQL_REPLICATION_USER"
|
||||
info "Creating replication user $POSTGRESQL_REPLICATION_USER"
|
||||
echo "CREATE ROLE \"$POSTGRESQL_REPLICATION_USER\" REPLICATION LOGIN ENCRYPTED PASSWORD '$escaped_password'" | postgresql_execute
|
||||
}
|
||||
|
||||
|
|
@ -484,7 +314,7 @@ postgresql_create_replication_user() {
|
|||
# None
|
||||
#########################
|
||||
postgresql_configure_replication_parameters() {
|
||||
postgresql_info "Configuring replication parameters"
|
||||
info "Configuring replication parameters"
|
||||
postgresql_set_property "wal_level" "hot_standby"
|
||||
postgresql_set_property "max_wal_size" "400MB"
|
||||
postgresql_set_property "max_wal_senders" "16"
|
||||
|
|
@ -506,7 +336,7 @@ postgresql_configure_replication_parameters() {
|
|||
# None
|
||||
#########################
|
||||
postgresql_configure_fsync() {
|
||||
postgresql_info "Configuring fsync"
|
||||
info "Configuring fsync"
|
||||
postgresql_set_property "fsync" "$POSTGRESQL_FSYNC"
|
||||
}
|
||||
|
||||
|
|
@ -521,7 +351,7 @@ postgresql_configure_fsync() {
|
|||
#########################
|
||||
postgresql_alter_postgres_user() {
|
||||
local -r escaped_password="${1//\'/\'\'}"
|
||||
postgresql_info "Changing password of postgres"
|
||||
info "Changing password of postgres"
|
||||
echo "ALTER ROLE postgres WITH PASSWORD '$escaped_password';" | postgresql_execute
|
||||
}
|
||||
|
||||
|
|
@ -536,9 +366,9 @@ postgresql_alter_postgres_user() {
|
|||
#########################
|
||||
postgresql_create_admin_user() {
|
||||
local -r escaped_password="${POSTGRESQL_PASSWORD//\'/\'\'}"
|
||||
postgresql_info "Creating user ${POSTGRESQL_USERNAME}"
|
||||
info "Creating user ${POSTGRESQL_USERNAME}"
|
||||
echo "CREATE ROLE \"${POSTGRESQL_USERNAME}\" WITH LOGIN CREATEDB PASSWORD '${escaped_password}';" | postgresql_execute
|
||||
postgresql_info "Granting access to \"${POSTGRESQL_USERNAME}\" to the database \"${POSTGRESQL_DATABASE}\""
|
||||
info "Granting access to \"${POSTGRESQL_USERNAME}\" to the database \"${POSTGRESQL_DATABASE}\""
|
||||
echo "GRANT ALL PRIVILEGES ON DATABASE \"${POSTGRESQL_DATABASE}\" TO \"${POSTGRESQL_USERNAME}\"\;" | postgresql_execute "" "postgres" "$POSTGRESQL_PASSWORD"
|
||||
}
|
||||
|
||||
|
|
@ -602,7 +432,7 @@ postgresql_clean_from_restart() {
|
|||
|
||||
for file in "${files[@]}"; do
|
||||
if [[ -f "$file" ]]; then
|
||||
postgresql_info "Cleaning stale $file file"
|
||||
info "Cleaning stale $file file"
|
||||
rm "$file"
|
||||
fi
|
||||
done
|
||||
|
|
@ -618,7 +448,7 @@ postgresql_clean_from_restart() {
|
|||
# None
|
||||
#########################
|
||||
postgresql_initialize() {
|
||||
postgresql_info "Initializing PostgreSQL database..."
|
||||
info "Initializing PostgreSQL database..."
|
||||
postgresql_clean_from_restart
|
||||
|
||||
# This fixes an issue where the trap would kill the entrypoint.sh, if a PID was left over from a previous run
|
||||
|
|
@ -627,36 +457,35 @@ postgresql_initialize() {
|
|||
|
||||
# User injected custom configuration
|
||||
if [[ -d "$POSTGRESQL_MOUNTED_CONF_DIR" ]] && compgen -G "$POSTGRESQL_MOUNTED_CONF_DIR"/* > /dev/null; then
|
||||
postgresql_debug "Copying files from $POSTGRESQL_MOUNTED_CONF_DIR to $POSTGRESQL_CONF_DIR"
|
||||
debug "Copying files from $POSTGRESQL_MOUNTED_CONF_DIR to $POSTGRESQL_CONF_DIR"
|
||||
cp -fr "$POSTGRESQL_MOUNTED_CONF_DIR"/. "$POSTGRESQL_CONF_DIR"
|
||||
fi
|
||||
local create_conf_file=yes
|
||||
local create_pghba_file=yes
|
||||
|
||||
if postgresql_is_file_external "postgresql.conf"; then
|
||||
postgresql_info "Custom configuration $POSTGRESQL_CONF_FILE detected"
|
||||
info "Custom configuration $POSTGRESQL_CONF_FILE detected"
|
||||
create_conf_file=no
|
||||
fi
|
||||
|
||||
if postgresql_is_file_external "pg_hba.conf"; then
|
||||
postgresql_info "Custom configuration $POSTGRESQL_PGHBA_FILE detected"
|
||||
info "Custom configuration $POSTGRESQL_PGHBA_FILE detected"
|
||||
create_pghba_file=no
|
||||
fi
|
||||
|
||||
postgresql_debug "Ensuring expected directories/files exist..."
|
||||
debug "Ensuring expected directories/files exist..."
|
||||
for dir in "$POSTGRESQL_TMP_DIR" "$POSTGRESQL_LOG_DIR" "$POSTGRESQL_DATA_DIR"; do
|
||||
ensure_dir_exists "$dir"
|
||||
am_i_root && chown "$POSTGRESQL_DAEMON_USER:$POSTGRESQL_DAEMON_GROUP" "$dir"
|
||||
done
|
||||
am_i_root && find "$POSTGRESQL_DATA_DIR" -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" -exec chown -R "$POSTGRESQL_DAEMON_USER:$POSTGRESQL_DAEMON_GROUP" {} \;
|
||||
chmod u+rwx "$POSTGRESQL_DATA_DIR" || postgresql_warn "Lack of permissions on data directory!"
|
||||
chmod go-rwx "$POSTGRESQL_DATA_DIR" || postgresql_warn "Lack of permissions on data directory!"
|
||||
chmod u+rwx "$POSTGRESQL_DATA_DIR" || warn "Lack of permissions on data directory!"
|
||||
chmod go-rwx "$POSTGRESQL_DATA_DIR" || warn "Lack of permissions on data directory!"
|
||||
|
||||
is_boolean_yes "$create_conf_file" && postgresql_create_config
|
||||
is_boolean_yes "$create_pghba_file" && postgresql_create_pghba && postgresql_allow_local_connection
|
||||
is_boolean_yes "$POSTGRESQL_ALLOW_REMOTE_CONNECTIONS" && is_boolean_yes "$create_pghba_file" && postgresql_create_pghba && postgresql_allow_local_connection
|
||||
|
||||
if ! is_dir_empty "$POSTGRESQL_DATA_DIR"; then
|
||||
postgresql_info "Deploying PostgreSQL with persisted data..."
|
||||
info "Deploying PostgreSQL with persisted data..."
|
||||
export POSTGRESQL_FIRST_BOOT="no"
|
||||
is_boolean_yes "$create_pghba_file" && postgresql_restrict_pghba
|
||||
is_boolean_yes "$create_conf_file" && postgresql_configure_replication_parameters
|
||||
|
|
@ -705,7 +534,7 @@ postgresql_initialize() {
|
|||
#########################
|
||||
postgresql_custom_pre_init_scripts() {
|
||||
info "Loading custom pre-init scripts..."
|
||||
if [[ -n $(find "$POSTGRESQL_PREINITSCRIPTS_DIR/" -type f -name "*.sh") ]]; then
|
||||
if [[ -d "$POSTGRESQL_PREINITSCRIPTS_DIR" ]] && [[ -n $(find "$POSTGRESQL_PREINITSCRIPTS_DIR/" -type f -name "*.sh") ]]; then
|
||||
info "Loading user's custom files from $POSTGRESQL_PREINITSCRIPTS_DIR ...";
|
||||
find "$POSTGRESQL_PREINITSCRIPTS_DIR/" -type f -name "*.sh" | sort | while read -r f; do
|
||||
if [[ -x "$f" ]]; then
|
||||
|
|
@ -727,22 +556,22 @@ postgresql_custom_pre_init_scripts() {
|
|||
# None
|
||||
#########################
|
||||
postgresql_custom_init_scripts() {
|
||||
postgresql_info "Loading custom scripts..."
|
||||
if [[ -n $(find "$POSTGRESQL_INITSCRIPTS_DIR/" -type f -regex ".*\.\(sh\|sql\|sql.gz\)") ]] && [[ ! -f "$POSTGRESQL_VOLUME_DIR/.user_scripts_initialized" ]] ; then
|
||||
postgresql_info "Loading user's custom files from $POSTGRESQL_INITSCRIPTS_DIR ...";
|
||||
info "Loading custom scripts..."
|
||||
if [[ -d "$POSTGRESQL_INITSCRIPTS_DIR" ]] && [[ -n $(find "$POSTGRESQL_INITSCRIPTS_DIR/" -type f -regex ".*\.\(sh\|sql\|sql.gz\)") ]] && [[ ! -f "$POSTGRESQL_VOLUME_DIR/.user_scripts_initialized" ]] ; then
|
||||
info "Loading user's custom files from $POSTGRESQL_INITSCRIPTS_DIR ...";
|
||||
postgresql_start_bg
|
||||
find "$POSTGRESQL_INITSCRIPTS_DIR/" -type f -regex ".*\.\(sh\|sql\|sql.gz\)" | sort | while read -r f; do
|
||||
case "$f" in
|
||||
*.sh)
|
||||
if [[ -x "$f" ]]; then
|
||||
postgresql_debug "Executing $f"; "$f"
|
||||
debug "Executing $f"; "$f"
|
||||
else
|
||||
postgresql_debug "Sourcing $f"; . "$f"
|
||||
debug "Sourcing $f"; . "$f"
|
||||
fi
|
||||
;;
|
||||
*.sql) postgresql_debug "Executing $f"; postgresql_execute "$POSTGRESQL_DATABASE" "$POSTGRESQL_INITSCRIPTS_USERNAME" "$POSTGRESQL_INITSCRIPTS_PASSWORD" < "$f";;
|
||||
*.sql.gz) postgresql_debug "Executing $f"; gunzip -c "$f" | postgresql_execute "$POSTGRESQL_DATABASE" "$POSTGRESQL_INITSCRIPTS_USERNAME" "$POSTGRESQL_INITSCRIPTS_PASSWORD";;
|
||||
*) postgresql_debug "Ignoring $f" ;;
|
||||
*.sql) debug "Executing $f"; postgresql_execute "$POSTGRESQL_DATABASE" "$POSTGRESQL_INITSCRIPTS_USERNAME" "$POSTGRESQL_INITSCRIPTS_PASSWORD" < "$f";;
|
||||
*.sql.gz) debug "Executing $f"; gunzip -c "$f" | postgresql_execute "$POSTGRESQL_DATABASE" "$POSTGRESQL_INITSCRIPTS_USERNAME" "$POSTGRESQL_INITSCRIPTS_PASSWORD";;
|
||||
*) debug "Ignoring $f" ;;
|
||||
esac
|
||||
done
|
||||
touch "$POSTGRESQL_VOLUME_DIR"/.user_scripts_initialized
|
||||
|
|
@ -759,7 +588,7 @@ postgresql_custom_init_scripts() {
|
|||
# None
|
||||
#########################
|
||||
postgresql_stop() {
|
||||
postgresql_info "Stopping PostgreSQL..."
|
||||
info "Stopping PostgreSQL..."
|
||||
stop_service_using_pid "$POSTGRESQL_PID_FILE"
|
||||
}
|
||||
|
||||
|
|
@ -811,7 +640,7 @@ postgresql_execute() {
|
|||
#########################
|
||||
postgresql_start_bg() {
|
||||
local -r pg_ctl_flags=("-w" "-D" "$POSTGRESQL_DATA_DIR" "-l" "$POSTGRESQL_LOG_FILE" "-o" "--config-file=$POSTGRESQL_CONF_FILE --external_pid_file=$POSTGRESQL_PID_FILE --hba_file=$POSTGRESQL_PGHBA_FILE")
|
||||
postgresql_info "Starting PostgreSQL in background..."
|
||||
info "Starting PostgreSQL in background..."
|
||||
is_postgresql_running && return
|
||||
local pg_ctl_cmd=()
|
||||
if am_i_root; then
|
||||
|
|
@ -829,7 +658,7 @@ postgresql_start_bg() {
|
|||
sleep 1
|
||||
counter=$((counter - 1 ))
|
||||
if (( counter <= 0 )); then
|
||||
postgresql_error "PostgreSQL is not ready after $POSTGRESQL_INIT_MAX_TIMEOUT seconds"
|
||||
error "PostgreSQL is not ready after $POSTGRESQL_INIT_MAX_TIMEOUT seconds"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
|
@ -855,6 +684,20 @@ is_postgresql_running() {
|
|||
fi
|
||||
}
|
||||
|
||||
|
||||
########################
|
||||
# Check if PostgreSQL is not running
|
||||
# Globals:
|
||||
# POSTGRESQL_*
|
||||
# Arguments:
|
||||
# None
|
||||
# Returns:
|
||||
# Boolean
|
||||
#########################
|
||||
is_postgresql_not_running() {
|
||||
! is_postgresql_running
|
||||
}
|
||||
|
||||
########################
|
||||
# Initialize master node database by running initdb
|
||||
# Globals:
|
||||
|
|
@ -882,7 +725,7 @@ postgresql_master_init_db() {
|
|||
fi
|
||||
initdb_cmd+=("$POSTGRESQL_BIN_DIR/initdb")
|
||||
if [[ -n "${initdb_args[*]:-}" ]]; then
|
||||
postgresql_info "Initializing PostgreSQL with ${initdb_args[*]} extra initdb arguments"
|
||||
info "Initializing PostgreSQL with ${initdb_args[*]} extra initdb arguments"
|
||||
if [[ "${BITNAMI_DEBUG:-false}" = true ]]; then
|
||||
"${initdb_cmd[@]}" -E UTF8 -D "$POSTGRESQL_DATA_DIR" -U "postgres" "${initdb_args[@]}"
|
||||
else
|
||||
|
|
@ -905,7 +748,7 @@ postgresql_master_init_db() {
|
|||
# Boolean
|
||||
#########################
|
||||
postgresql_slave_init_db() {
|
||||
postgresql_info "Waiting for replication master to accept connections (${POSTGRESQL_INIT_MAX_TIMEOUT} timeout)..."
|
||||
info "Waiting for replication master to accept connections (${POSTGRESQL_INIT_MAX_TIMEOUT} timeout)..."
|
||||
local -r check_args=("-U" "$POSTGRESQL_REPLICATION_USER" "-h" "$POSTGRESQL_MASTER_HOST" "-p" "$POSTGRESQL_MASTER_PORT_NUMBER" "-d" "postgres")
|
||||
local check_cmd=()
|
||||
if am_i_root; then
|
||||
|
|
@ -918,12 +761,12 @@ postgresql_slave_init_db() {
|
|||
sleep 1
|
||||
ready_counter=$(( ready_counter - 1 ))
|
||||
if (( ready_counter <= 0 )); then
|
||||
postgresql_error "PostgreSQL master is not ready after $POSTGRESQL_INIT_MAX_TIMEOUT seconds"
|
||||
error "PostgreSQL master is not ready after $POSTGRESQL_INIT_MAX_TIMEOUT seconds"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
done
|
||||
postgresql_info "Replicating the initial database"
|
||||
info "Replicating the initial database"
|
||||
local -r backup_args=("-D" "$POSTGRESQL_DATA_DIR" "-U" "$POSTGRESQL_REPLICATION_USER" "-h" "$POSTGRESQL_MASTER_HOST" "-p" "$POSTGRESQL_MASTER_PORT_NUMBER" "-X" "stream" "-w" "-v" "-P")
|
||||
local backup_cmd=()
|
||||
if am_i_root; then
|
||||
|
|
@ -932,16 +775,29 @@ postgresql_slave_init_db() {
|
|||
backup_cmd+=("$POSTGRESQL_BIN_DIR"/pg_basebackup)
|
||||
local replication_counter=$POSTGRESQL_INIT_MAX_TIMEOUT
|
||||
while ! PGPASSWORD=$POSTGRESQL_REPLICATION_PASSWORD "${backup_cmd[@]}" "${backup_args[@]}";do
|
||||
postgresql_debug "Backup command failed. Sleeping and trying again"
|
||||
debug "Backup command failed. Sleeping and trying again"
|
||||
sleep 1
|
||||
replication_counter=$(( replication_counter - 1 ))
|
||||
if (( replication_counter <= 0 )); then
|
||||
postgresql_error "Slave replication failed after trying for $POSTGRESQL_INIT_MAX_TIMEOUT seconds"
|
||||
error "Slave replication failed after trying for $POSTGRESQL_INIT_MAX_TIMEOUT seconds"
|
||||
exit 1
|
||||
fi
|
||||
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]+"
|
||||
}
|
||||
|
||||
########################
|
||||
# Create recovery.conf in slave node
|
||||
# Globals:
|
||||
|
|
@ -952,8 +808,9 @@ postgresql_slave_init_db() {
|
|||
# Boolean
|
||||
#########################
|
||||
postgresql_configure_recovery() {
|
||||
postgresql_info "Setting up streaming replication slave..."
|
||||
if (( POSTGRESQL_MAJOR_VERSION >= 12 )); then
|
||||
info "Setting up streaming replication slave..."
|
||||
local -r psql_major_version="$(postgresql_get_major_version)"
|
||||
if (( psql_major_version >= 12 )); then
|
||||
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_CONF_FILE"
|
||||
postgresql_set_property "promote_trigger_file" "/tmp/postgresql.trigger.${POSTGRESQL_MASTER_PORT_NUMBER}" "$POSTGRESQL_CONF_FILE"
|
||||
touch "$POSTGRESQL_DATA_DIR"/standby.signal
|
||||
|
|
|
|||
|
|
@ -0,0 +1,200 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Environment configuration for postgresql
|
||||
|
||||
# The values for all environment variables will be set in the below order of precedence
|
||||
# 1. Custom environment variables defined below after Bitnami defaults
|
||||
# 2. Constants defined in this file (environment variables with no default), i.e. BITNAMI_ROOT_DIR
|
||||
# 3. Environment variables overridden via external files using *_FILE variables (see below)
|
||||
# 4. Environment variables set externally (i.e. current Bash context/Dockerfile/userdata)
|
||||
|
||||
export BITNAMI_ROOT_DIR="/opt/bitnami"
|
||||
export BITNAMI_VOLUME_DIR="/bitnami"
|
||||
|
||||
# Logging configuration
|
||||
export MODULE="${MODULE:-postgresql}"
|
||||
export BITNAMI_DEBUG="${BITNAMI_DEBUG:-false}"
|
||||
|
||||
# By setting an environment variable matching *_FILE to a file path, the prefixed environment
|
||||
# variable will be overridden with the value specified in that file
|
||||
postgresql_env_vars=(
|
||||
POSTGRESQL_DATA_DIR
|
||||
POSTGRESQL_INIT_MAX_TIMEOUT
|
||||
POSTGRESQL_CLUSTER_APP_NAME
|
||||
POSTGRESQL_DATABASE
|
||||
POSTGRESQL_INITDB_ARGS
|
||||
ALLOW_EMPTY_PASSWORD
|
||||
POSTGRESQL_INITDB_WAL_DIR
|
||||
POSTGRESQL_MASTER_HOST
|
||||
POSTGRESQL_MASTER_PORT_NUMBER
|
||||
POSTGRESQL_NUM_SYNCHRONOUS_REPLICAS
|
||||
POSTGRESQL_PORT_NUMBER
|
||||
POSTGRESQL_ALLOW_REMOTE_CONNECTIONS
|
||||
POSTGRESQL_REPLICATION_MODE
|
||||
POSTGRESQL_REPLICATION_USER
|
||||
POSTGRESQL_SYNCHRONOUS_COMMIT_MODE
|
||||
POSTGRESQL_FSYNC
|
||||
POSTGRESQL_USERNAME
|
||||
POSTGRESQL_ENABLE_LDAP
|
||||
POSTGRESQL_LDAP_URL
|
||||
POSTGRESQL_LDAP_PREFIX
|
||||
POSTGRESQL_LDAP_SUFFIX
|
||||
POSTGRESQL_LDAP_SERVER
|
||||
POSTGRESQL_LDAP_PORT
|
||||
POSTGRESQL_LDAP_SCHEME
|
||||
POSTGRESQL_LDAP_TLS
|
||||
POSTGRESQL_LDAP_BASE_DN
|
||||
POSTGRESQL_LDAP_BIND_DN
|
||||
POSTGRESQL_LDAP_BIND_PASSWORD
|
||||
POSTGRESQL_LDAP_SEARCH_ATTR
|
||||
POSTGRESQL_LDAP_SEARCH_FILTER
|
||||
POSTGRESQL_INITSCRIPTS_USERNAME
|
||||
POSTGRESQL_PASSWORD
|
||||
POSTGRESQL_POSTGRES_PASSWORD
|
||||
POSTGRESQL_REPLICATION_PASSWORD
|
||||
POSTGRESQL_INITSCRIPTS_PASSWORD
|
||||
|
||||
)
|
||||
for env_var in "${postgresql_env_vars[@]}"; do
|
||||
file_env_var="${env_var}_FILE"
|
||||
if [[ -n "${!file_env_var:-}" ]]; then
|
||||
export "${env_var}=$(< "${!file_env_var}")"
|
||||
unset "${file_env_var}"
|
||||
fi
|
||||
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"
|
||||
|
||||
export POSTGRESQL_DATA_DIR="${POSTGRESQL_DATA_DIR:-"${POSTGRES_DATA_DIR:-}"}"
|
||||
export POSTGRESQL_DATA_DIR="${POSTGRESQL_DATA_DIR:-"${PGDATA:-}"}"
|
||||
export POSTGRESQL_DATA_DIR="${POSTGRESQL_DATA_DIR:-${POSTGRESQL_VOLUME_DIR}/postgresql/data}"
|
||||
export POSTGRESQL_CONF_DIR="$POSTGRESQL_BASE_DIR/conf"
|
||||
export POSTGRESQL_MOUNTED_CONF_DIR="$POSTGRESQL_VOLUME_DIR/conf"
|
||||
export POSTGRESQL_CONF_FILE="$POSTGRESQL_CONF_DIR/postgresql.conf"
|
||||
export POSTGRESQL_PGHBA_FILE="$POSTGRESQL_CONF_DIR/pg_hba.conf"
|
||||
export POSTGRESQL_RECOVERY_FILE="$POSTGRESQL_DATA_DIR/recovery.conf"
|
||||
export POSTGRESQL_LOG_DIR="$POSTGRESQL_BASE_DIR/logs"
|
||||
export POSTGRESQL_LOG_FILE="$POSTGRESQL_LOG_DIR/postgresql.log"
|
||||
export POSTGRESQL_TMP_DIR="$POSTGRESQL_BASE_DIR/tmp"
|
||||
export POSTGRESQL_PID_FILE="$POSTGRESQL_TMP_DIR/postgresql.pid"
|
||||
export POSTGRESQL_BIN_DIR="$POSTGRESQL_BASE_DIR/bin"
|
||||
export POSTGRESQL_INITSCRIPTS_DIR="/docker-entrypoint-initdb.d"
|
||||
export POSTGRESQL_PREINITSCRIPTS_DIR="/docker-entrypoint-preinitdb.d"
|
||||
export PATH="${POSTGRESQL_BIN_DIR}:${BITNAMI_ROOT_DIR}/common/bin:${PATH}"
|
||||
|
||||
# System users (when running with a privileged user)
|
||||
export POSTGRESQL_DAEMON_USER="postgres"
|
||||
export POSTGRESQL_DAEMON_GROUP="postgres"
|
||||
|
||||
# PostgreSQL settings
|
||||
export POSTGRESQL_INIT_MAX_TIMEOUT="${POSTGRESQL_INIT_MAX_TIMEOUT:-60}"
|
||||
|
||||
export POSTGRESQL_CLUSTER_APP_NAME="${POSTGRESQL_CLUSTER_APP_NAME:-"${POSTGRES_CLUSTER_APP_NAME:-}"}"
|
||||
export POSTGRESQL_CLUSTER_APP_NAME="${POSTGRESQL_CLUSTER_APP_NAME:-walreceiver}"
|
||||
|
||||
export POSTGRESQL_DATABASE="${POSTGRESQL_DATABASE:-"${POSTGRES_DATABASE:-}"}"
|
||||
export POSTGRESQL_DATABASE="${POSTGRESQL_DATABASE:-"${POSTGRES_DB:-}"}"
|
||||
export POSTGRESQL_DATABASE="${POSTGRESQL_DATABASE:-postgres}"
|
||||
|
||||
export POSTGRESQL_INITDB_ARGS="${POSTGRESQL_INITDB_ARGS:-"${POSTGRES_INITDB_ARGS:-}"}"
|
||||
export POSTGRESQL_INITDB_ARGS="${POSTGRESQL_INITDB_ARGS:-}"
|
||||
export ALLOW_EMPTY_PASSWORD="${ALLOW_EMPTY_PASSWORD:-no}"
|
||||
|
||||
export POSTGRESQL_INITDB_WAL_DIR="${POSTGRESQL_INITDB_WAL_DIR:-"${POSTGRES_INITDB_WAL_DIR:-}"}"
|
||||
export POSTGRESQL_INITDB_WAL_DIR="${POSTGRESQL_INITDB_WAL_DIR:-}"
|
||||
|
||||
export POSTGRESQL_MASTER_HOST="${POSTGRESQL_MASTER_HOST:-"${POSTGRES_MASTER_HOST:-}"}"
|
||||
export POSTGRESQL_MASTER_HOST="${POSTGRESQL_MASTER_HOST:-}"
|
||||
|
||||
export POSTGRESQL_MASTER_PORT_NUMBER="${POSTGRESQL_MASTER_PORT_NUMBER:-"${POSTGRES_MASTER_PORT_NUMBER:-}"}"
|
||||
export POSTGRESQL_MASTER_PORT_NUMBER="${POSTGRESQL_MASTER_PORT_NUMBER:-5432}"
|
||||
|
||||
export POSTGRESQL_NUM_SYNCHRONOUS_REPLICAS="${POSTGRESQL_NUM_SYNCHRONOUS_REPLICAS:-"${POSTGRES_NUM_SYNCHRONOUS_REPLICAS:-}"}"
|
||||
export POSTGRESQL_NUM_SYNCHRONOUS_REPLICAS="${POSTGRESQL_NUM_SYNCHRONOUS_REPLICAS:-0}"
|
||||
|
||||
export POSTGRESQL_PORT_NUMBER="${POSTGRESQL_PORT_NUMBER:-"${POSTGRES_PORT_NUMBER:-}"}"
|
||||
export POSTGRESQL_PORT_NUMBER="${POSTGRESQL_PORT_NUMBER:-5432}"
|
||||
|
||||
export POSTGRESQL_ALLOW_REMOTE_CONNECTIONS="${POSTGRESQL_ALLOW_REMOTE_CONNECTIONS:-"${POSTGRES_ALLOW_REMOTE_CONNECTIONS:-}"}"
|
||||
export POSTGRESQL_ALLOW_REMOTE_CONNECTIONS="${POSTGRESQL_ALLOW_REMOTE_CONNECTIONS:-yes}"
|
||||
|
||||
export POSTGRESQL_REPLICATION_MODE="${POSTGRESQL_REPLICATION_MODE:-"${POSTGRES_REPLICATION_MODE:-}"}"
|
||||
export POSTGRESQL_REPLICATION_MODE="${POSTGRESQL_REPLICATION_MODE:-master}"
|
||||
|
||||
export POSTGRESQL_REPLICATION_USER="${POSTGRESQL_REPLICATION_USER:-"${POSTGRES_REPLICATION_USER:-}"}"
|
||||
export POSTGRESQL_REPLICATION_USER="${POSTGRESQL_REPLICATION_USER:-}"
|
||||
|
||||
export POSTGRESQL_SYNCHRONOUS_COMMIT_MODE="${POSTGRESQL_SYNCHRONOUS_COMMIT_MODE:-"${POSTGRES_SYNCHRONOUS_COMMIT_MODE:-}"}"
|
||||
export POSTGRESQL_SYNCHRONOUS_COMMIT_MODE="${POSTGRESQL_SYNCHRONOUS_COMMIT_MODE:-on}"
|
||||
|
||||
export POSTGRESQL_FSYNC="${POSTGRESQL_FSYNC:-"${POSTGRES_FSYNC:-}"}"
|
||||
export POSTGRESQL_FSYNC="${POSTGRESQL_FSYNC:-on}"
|
||||
|
||||
export POSTGRESQL_USERNAME="${POSTGRESQL_USERNAME:-"${POSTGRES_USERNAME:-}"}"
|
||||
export POSTGRESQL_USERNAME="${POSTGRESQL_USERNAME:-"${POSTGRES_USER:-}"}"
|
||||
export POSTGRESQL_USERNAME="${POSTGRESQL_USERNAME:-"${POSTGRESQL_USER:-}"}"
|
||||
export POSTGRESQL_USERNAME="${POSTGRESQL_USERNAME:-postgres}"
|
||||
|
||||
export POSTGRESQL_ENABLE_LDAP="${POSTGRESQL_ENABLE_LDAP:-"${POSTGRES_ENABLE_LDAP:-}"}"
|
||||
export POSTGRESQL_ENABLE_LDAP="${POSTGRESQL_ENABLE_LDAP:-no}"
|
||||
|
||||
export POSTGRESQL_LDAP_URL="${POSTGRESQL_LDAP_URL:-"${POSTGRES_LDAP_URL:-}"}"
|
||||
export POSTGRESQL_LDAP_URL="${POSTGRESQL_LDAP_URL:-}"
|
||||
|
||||
export POSTGRESQL_LDAP_PREFIX="${POSTGRESQL_LDAP_PREFIX:-"${POSTGRES_LDAP_PREFIX:-}"}"
|
||||
export POSTGRESQL_LDAP_PREFIX="${POSTGRESQL_LDAP_PREFIX:-}"
|
||||
|
||||
export POSTGRESQL_LDAP_SUFFIX="${POSTGRESQL_LDAP_SUFFIX:-"${POSTGRES_LDAP_SUFFIX:-}"}"
|
||||
export POSTGRESQL_LDAP_SUFFIX="${POSTGRESQL_LDAP_SUFFIX:-}"
|
||||
|
||||
export POSTGRESQL_LDAP_SERVER="${POSTGRESQL_LDAP_SERVER:-"${POSTGRES_LDAP_SERVER:-}"}"
|
||||
export POSTGRESQL_LDAP_SERVER="${POSTGRESQL_LDAP_SERVER:-}"
|
||||
|
||||
export POSTGRESQL_LDAP_PORT="${POSTGRESQL_LDAP_PORT:-"${POSTGRES_LDAP_PORT:-}"}"
|
||||
export POSTGRESQL_LDAP_PORT="${POSTGRESQL_LDAP_PORT:-}"
|
||||
|
||||
export POSTGRESQL_LDAP_SCHEME="${POSTGRESQL_LDAP_SCHEME:-"${POSTGRES_LDAP_SCHEME:-}"}"
|
||||
export POSTGRESQL_LDAP_SCHEME="${POSTGRESQL_LDAP_SCHEME:-}"
|
||||
|
||||
export POSTGRESQL_LDAP_TLS="${POSTGRESQL_LDAP_TLS:-"${POSTGRES_LDAP_TLS:-}"}"
|
||||
export POSTGRESQL_LDAP_TLS="${POSTGRESQL_LDAP_TLS:-}"
|
||||
|
||||
export POSTGRESQL_LDAP_BASE_DN="${POSTGRESQL_LDAP_BASE_DN:-"${POSTGRES_LDAP_BASE_DN:-}"}"
|
||||
export POSTGRESQL_LDAP_BASE_DN="${POSTGRESQL_LDAP_BASE_DN:-}"
|
||||
|
||||
export POSTGRESQL_LDAP_BIND_DN="${POSTGRESQL_LDAP_BIND_DN:-"${POSTGRES_LDAP_BIND_DN:-}"}"
|
||||
export POSTGRESQL_LDAP_BIND_DN="${POSTGRESQL_LDAP_BIND_DN:-}"
|
||||
|
||||
export POSTGRESQL_LDAP_BIND_PASSWORD="${POSTGRESQL_LDAP_BIND_PASSWORD:-"${POSTGRES_LDAP_BIND_PASSWORD:-}"}"
|
||||
export POSTGRESQL_LDAP_BIND_PASSWORD="${POSTGRESQL_LDAP_BIND_PASSWORD:-}"
|
||||
|
||||
export POSTGRESQL_LDAP_SEARCH_ATTR="${POSTGRESQL_LDAP_SEARCH_ATTR:-"${POSTGRES_LDAP_SEARCH_ATTR:-}"}"
|
||||
export POSTGRESQL_LDAP_SEARCH_ATTR="${POSTGRESQL_LDAP_SEARCH_ATTR:-}"
|
||||
|
||||
export POSTGRESQL_LDAP_SEARCH_FILTER="${POSTGRESQL_LDAP_SEARCH_FILTER:-"${POSTGRES_LDAP_SEARCH_FILTER:-}"}"
|
||||
export POSTGRESQL_LDAP_SEARCH_FILTER="${POSTGRESQL_LDAP_SEARCH_FILTER:-}"
|
||||
|
||||
export POSTGRESQL_INITSCRIPTS_USERNAME="${POSTGRESQL_INITSCRIPTS_USERNAME:-"${POSTGRES_INITSCRIPTS_USERNAME:-}"}"
|
||||
export POSTGRESQL_INITSCRIPTS_USERNAME="${POSTGRESQL_INITSCRIPTS_USERNAME:-$POSTGRESQL_USERNAME}"
|
||||
|
||||
export POSTGRESQL_PASSWORD="${POSTGRESQL_PASSWORD:-"${POSTGRES_PASSWORD:-}"}"
|
||||
export POSTGRESQL_PASSWORD="${POSTGRESQL_PASSWORD:-}"
|
||||
|
||||
export POSTGRESQL_POSTGRES_PASSWORD="${POSTGRESQL_POSTGRES_PASSWORD:-"${POSTGRES_POSTGRES_PASSWORD:-}"}"
|
||||
export POSTGRESQL_POSTGRES_PASSWORD="${POSTGRESQL_POSTGRES_PASSWORD:-}"
|
||||
|
||||
export POSTGRESQL_REPLICATION_PASSWORD="${POSTGRESQL_REPLICATION_PASSWORD:-"${POSTGRES_REPLICATION_PASSWORD:-}"}"
|
||||
export POSTGRESQL_REPLICATION_PASSWORD="${POSTGRESQL_REPLICATION_PASSWORD:-}"
|
||||
|
||||
export POSTGRESQL_INITSCRIPTS_PASSWORD="${POSTGRESQL_INITSCRIPTS_PASSWORD:-"${POSTGRES_INITSCRIPTS_PASSWORD:-}"}"
|
||||
export POSTGRESQL_INITSCRIPTS_PASSWORD="${POSTGRESQL_INITSCRIPTS_PASSWORD:-}"
|
||||
|
||||
# Internal
|
||||
export POSTGRESQL_FIRST_BOOT="yes"
|
||||
export NSS_WRAPPER_LIB="/opt/bitnami/common/lib/libnss_wrapper.so"
|
||||
|
||||
# Custom environment variables may be defined below
|
||||
|
|
@ -12,8 +12,7 @@ set -o pipefail
|
|||
. /opt/bitnami/scripts/libpostgresql.sh
|
||||
|
||||
# Load PostgreSQL environment variables
|
||||
eval "$(postgresql_env)"
|
||||
export MODULE=postgresql
|
||||
. /opt/bitnami/scripts/postgresql-env.sh
|
||||
|
||||
print_welcome_page
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,17 @@
|
|||
. /opt/bitnami/scripts/libpostgresql.sh
|
||||
|
||||
# Load PostgreSQL environment variables
|
||||
eval "$(postgresql_env)"
|
||||
. /opt/bitnami/scripts/postgresql-env.sh
|
||||
|
||||
for dir in "$POSTGRESQL_INITSCRIPTS_DIR" "$POSTGRESQL_TMP_DIR" "$POSTGRESQL_LOG_DIR" "$POSTGRESQL_CONF_DIR" "${POSTGRESQL_CONF_DIR}/conf.d" "${POSTGRESQL_MOUNTED_CONF_DIR}" "${POSTGRESQL_MOUNTED_CONF_DIR}/conf.d" "$POSTGRESQL_VOLUME_DIR"; do
|
||||
ensure_dir_exists "$dir"
|
||||
done
|
||||
|
||||
# Create basic pg_hba.conf for local connections
|
||||
postgresql_allow_local_connection
|
||||
# Create basic postgresql.conf
|
||||
postgresql_create_config
|
||||
|
||||
chmod -R g+rwX "$POSTGRESQL_INITSCRIPTS_DIR" "$POSTGRESQL_TMP_DIR" "$POSTGRESQL_LOG_DIR" "$POSTGRESQL_CONF_DIR" "${POSTGRESQL_CONF_DIR}/conf.d" "${POSTGRESQL_MOUNTED_CONF_DIR}" "${POSTGRESQL_MOUNTED_CONF_DIR}/conf.d" "$POSTGRESQL_VOLUME_DIR"
|
||||
|
||||
# Redirect all logging to stdout
|
||||
|
|
|
|||
|
|
@ -12,9 +12,10 @@ set -o pipefail
|
|||
. /opt/bitnami/scripts/libos.sh
|
||||
|
||||
# Load PostgreSQL environment variables
|
||||
eval "$(postgresql_env)"
|
||||
readonly flags=("-D" "$POSTGRESQL_DATA_DIR" "--config-file=$POSTGRESQL_CONF_FILE" "--external_pid_file=$POSTGRESQL_PID_FILE" "--hba_file=$POSTGRESQL_PGHBA_FILE")
|
||||
readonly cmd=$(command -v postgres)
|
||||
. /opt/bitnami/scripts/postgresql-env.sh
|
||||
|
||||
flags=("-D" "$POSTGRESQL_DATA_DIR" "--config-file=$POSTGRESQL_CONF_FILE" "--external_pid_file=$POSTGRESQL_PID_FILE" "--hba_file=$POSTGRESQL_PGHBA_FILE")
|
||||
cmd=$(command -v postgres)
|
||||
|
||||
info "** Starting PostgreSQL **"
|
||||
if am_i_root; then
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ set -o pipefail
|
|||
. /opt/bitnami/scripts/libpostgresql.sh
|
||||
|
||||
# Load PostgreSQL environment variables
|
||||
eval "$(postgresql_env)"
|
||||
. /opt/bitnami/scripts/postgresql-env.sh
|
||||
|
||||
# Ensure PostgreSQL environment variables settings are valid
|
||||
postgresql_validate
|
||||
|
|
@ -33,7 +33,7 @@ postgresql_initialize
|
|||
postgresql_custom_init_scripts
|
||||
|
||||
# Allow remote connections once the initialization is finished
|
||||
if ! postgresql_is_file_external "postgresql.conf"; then
|
||||
if ! postgresql_is_file_external "postgresql.conf" && is_boolean_yes "$POSTGRESQL_ALLOW_REMOTE_CONNECTIONS"; then
|
||||
info "Enabling remote connections"
|
||||
postgresql_enable_remote_connections
|
||||
postgresql_set_property "port" "$POSTGRESQL_PORT_NUMBER"
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ Learn more about the Bitnami tagging policy and the difference between rolling t
|
|||
|
||||
* [`12-debian-10`, `12.3.0-debian-10-r32`, `12`, `12.3.0` (12/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/12.3.0-debian-10-r32/12/debian-10/Dockerfile)
|
||||
* [`11-debian-10`, `11.8.0-debian-10-r34`, `11`, `11.8.0`, `latest` (11/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/11.8.0-debian-10-r34/11/debian-10/Dockerfile)
|
||||
* [`10-debian-10`, `10.13.0-debian-10-r32`, `10`, `10.13.0` (10/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/10.13.0-debian-10-r32/10/debian-10/Dockerfile)
|
||||
* [`10-debian-10`, `10.13.0-debian-10-r33`, `10`, `10.13.0` (10/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/10.13.0-debian-10-r33/10/debian-10/Dockerfile)
|
||||
* [`9.6-debian-10`, `9.6.18-debian-10-r33`, `9.6`, `9.6.18` (9.6/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-postgresql/blob/9.6.18-debian-10-r33/9.6/debian-10/Dockerfile)
|
||||
|
||||
Subscribe to project updates by watching the [bitnami/postgresql GitHub repo](https://github.com/bitnami/bitnami-docker-postgresql).
|
||||
|
|
|
|||
Loading…
Reference in New Issue