mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-11-04 18:32:51 +00:00
PosgreSQL: Add version choice (#8103)
* Add version choice * Update * Update
This commit is contained in:
@@ -46,6 +46,10 @@
|
|||||||
{
|
{
|
||||||
"text": "Set a password after installation for postgres user by running `echo \"ALTER USER postgres with encrypted password 'your_password';\" | sudo -u postgres psql`",
|
"text": "Set a password after installation for postgres user by running `echo \"ALTER USER postgres with encrypted password 'your_password';\" | sudo -u postgres psql`",
|
||||||
"type": "info"
|
"type": "info"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "Debian script offers versions `15, 16, 17, 18`, while Alpine script offers versions `15, 16, 17`.",
|
||||||
|
"type": "info"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,12 @@ setting_up_container
|
|||||||
network_check
|
network_check
|
||||||
update_os
|
update_os
|
||||||
|
|
||||||
msg_info "Installing PostgreSQL"
|
read -r -p "${TAB3}Enter PostgreSQL version (15/16/17): " ver
|
||||||
$STD apk add --no-cache postgresql16 postgresql16-contrib postgresql16-openrc sudo
|
[[ $ver =~ ^(15|16|17)$ ]] || { echo "Invalid version"; exit 1; }
|
||||||
msg_ok "Installed PostgreSQL"
|
|
||||||
|
msg_info "Installing PostgreSQL ${ver}"
|
||||||
|
$STD apk add --no-cache postgresql${ver} postgresql${ver}-contrib postgresql${ver}-openrc sudo
|
||||||
|
msg_ok "Installed PostgreSQL ${ver}"
|
||||||
|
|
||||||
msg_info "Enabling PostgreSQL Service"
|
msg_info "Enabling PostgreSQL Service"
|
||||||
$STD rc-update add postgresql default
|
$STD rc-update add postgresql default
|
||||||
@@ -26,8 +29,8 @@ $STD rc-service postgresql start
|
|||||||
msg_ok "Started PostgreSQL"
|
msg_ok "Started PostgreSQL"
|
||||||
|
|
||||||
msg_info "Configuring PostgreSQL for External Access"
|
msg_info "Configuring PostgreSQL for External Access"
|
||||||
conf_file="/etc/postgresql16/postgresql.conf"
|
conf_file="/etc/postgresql${ver}/postgresql.conf"
|
||||||
hba_file="/etc/postgresql16/pg_hba.conf"
|
hba_file="/etc/postgresql${ver}/pg_hba.conf"
|
||||||
sed -i 's/^#listen_addresses =.*/listen_addresses = '\''*'\''/' "$conf_file"
|
sed -i 's/^#listen_addresses =.*/listen_addresses = '\''*'\''/' "$conf_file"
|
||||||
sed -i '/^host\s\+all\s\+all\s\+127.0.0.1\/32\s\+md5/ s/.*/host all all 0.0.0.0\/0 md5/' "$hba_file"
|
sed -i '/^host\s\+all\s\+all\s\+127.0.0.1\/32\s\+md5/ s/.*/host all all 0.0.0.0\/0 md5/' "$hba_file"
|
||||||
$STD rc-service postgresql restart
|
$STD rc-service postgresql restart
|
||||||
|
|||||||
@@ -13,9 +13,11 @@ setting_up_container
|
|||||||
network_check
|
network_check
|
||||||
update_os
|
update_os
|
||||||
|
|
||||||
PG_VERSION="17" setup_postgresql
|
read -r -p "${TAB3}Enter PostgreSQL version (15/16/17/18): " ver
|
||||||
|
[[ $ver =~ ^(15|16|17|18)$ ]] || { echo "Invalid version"; exit 1; }
|
||||||
|
PG_VERSION=$ver setup_postgresql
|
||||||
|
|
||||||
cat <<EOF >/etc/postgresql/17/main/pg_hba.conf
|
cat <<EOF >/etc/postgresql/$ver/main/pg_hba.conf
|
||||||
# PostgreSQL Client Authentication Configuration File
|
# PostgreSQL Client Authentication Configuration File
|
||||||
local all postgres peer
|
local all postgres peer
|
||||||
# TYPE DATABASE USER ADDRESS METHOD
|
# TYPE DATABASE USER ADDRESS METHOD
|
||||||
@@ -34,7 +36,7 @@ host replication all 127.0.0.1/32 scram-sha-256
|
|||||||
host replication all ::1/128 scram-sha-256
|
host replication all ::1/128 scram-sha-256
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat <<EOF >/etc/postgresql/17/main/postgresql.conf
|
cat <<EOF >/etc/postgresql/$ver/main/postgresql.conf
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# PostgreSQL configuration file
|
# PostgreSQL configuration file
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
@@ -43,10 +45,10 @@ cat <<EOF >/etc/postgresql/17/main/postgresql.conf
|
|||||||
# FILE LOCATIONS
|
# FILE LOCATIONS
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
data_directory = '/var/lib/postgresql/17/main'
|
data_directory = '/var/lib/postgresql/$ver/main'
|
||||||
hba_file = '/etc/postgresql/17/main/pg_hba.conf'
|
hba_file = '/etc/postgresql/$ver/main/pg_hba.conf'
|
||||||
ident_file = '/etc/postgresql/17/main/pg_ident.conf'
|
ident_file = '/etc/postgresql/$ver/main/pg_ident.conf'
|
||||||
external_pid_file = '/var/run/postgresql/17-main.pid'
|
external_pid_file = '/var/run/postgresql/$ver-main.pid'
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# CONNECTIONS AND AUTHENTICATION
|
# CONNECTIONS AND AUTHENTICATION
|
||||||
@@ -92,7 +94,7 @@ log_timezone = 'Etc/UTC'
|
|||||||
# PROCESS TITLE
|
# PROCESS TITLE
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
cluster_name = '17/main'
|
cluster_name = '$ver/main'
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# CLIENT CONNECTION DEFAULTS
|
# CLIENT CONNECTION DEFAULTS
|
||||||
|
|||||||
Reference in New Issue
Block a user