Skip to content

Commit e39dd5f

Browse files
authored
PosgreSQL: Add version choice (#8103)
* Add version choice * Update * Update
1 parent aded2cb commit e39dd5f

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

frontend/public/json/postgresql.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
{
4747
"text": "Set a password after installation for postgres user by running `echo \"ALTER USER postgres with encrypted password 'your_password';\" | sudo -u postgres psql`",
4848
"type": "info"
49+
},
50+
{
51+
"text": "Debian script offers versions `15, 16, 17, 18`, while Alpine script offers versions `15, 16, 17`.",
52+
"type": "info"
4953
}
5054
]
5155
}

install/alpine-postgresql-install.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ setting_up_container
1313
network_check
1414
update_os
1515

16-
msg_info "Installing PostgreSQL"
17-
$STD apk add --no-cache postgresql16 postgresql16-contrib postgresql16-openrc sudo
18-
msg_ok "Installed PostgreSQL"
16+
read -r -p "${TAB3}Enter PostgreSQL version (15/16/17): " ver
17+
[[ $ver =~ ^(15|16|17)$ ]] || { echo "Invalid version"; exit 1; }
18+
19+
msg_info "Installing PostgreSQL ${ver}"
20+
$STD apk add --no-cache postgresql${ver} postgresql${ver}-contrib postgresql${ver}-openrc sudo
21+
msg_ok "Installed PostgreSQL ${ver}"
1922

2023
msg_info "Enabling PostgreSQL Service"
2124
$STD rc-update add postgresql default
@@ -26,8 +29,8 @@ $STD rc-service postgresql start
2629
msg_ok "Started PostgreSQL"
2730

2831
msg_info "Configuring PostgreSQL for External Access"
29-
conf_file="/etc/postgresql16/postgresql.conf"
30-
hba_file="/etc/postgresql16/pg_hba.conf"
32+
conf_file="/etc/postgresql${ver}/postgresql.conf"
33+
hba_file="/etc/postgresql${ver}/pg_hba.conf"
3134
sed -i 's/^#listen_addresses =.*/listen_addresses = '\''*'\''/' "$conf_file"
3235
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"
3336
$STD rc-service postgresql restart

install/postgresql-install.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ setting_up_container
1313
network_check
1414
update_os
1515

16-
PG_VERSION="17" setup_postgresql
16+
read -r -p "${TAB3}Enter PostgreSQL version (15/16/17/18): " ver
17+
[[ $ver =~ ^(15|16|17|18)$ ]] || { echo "Invalid version"; exit 1; }
18+
PG_VERSION=$ver setup_postgresql
1719

18-
cat <<EOF >/etc/postgresql/17/main/pg_hba.conf
20+
cat <<EOF >/etc/postgresql/$ver/main/pg_hba.conf
1921
# PostgreSQL Client Authentication Configuration File
2022
local all postgres peer
2123
# TYPE DATABASE USER ADDRESS METHOD
@@ -34,7 +36,7 @@ host replication all 127.0.0.1/32 scram-sha-256
3436
host replication all ::1/128 scram-sha-256
3537
EOF
3638

37-
cat <<EOF >/etc/postgresql/17/main/postgresql.conf
39+
cat <<EOF >/etc/postgresql/$ver/main/postgresql.conf
3840
# -----------------------------
3941
# PostgreSQL configuration file
4042
# -----------------------------
@@ -43,10 +45,10 @@ cat <<EOF >/etc/postgresql/17/main/postgresql.conf
4345
# FILE LOCATIONS
4446
#------------------------------------------------------------------------------
4547
46-
data_directory = '/var/lib/postgresql/17/main'
47-
hba_file = '/etc/postgresql/17/main/pg_hba.conf'
48-
ident_file = '/etc/postgresql/17/main/pg_ident.conf'
49-
external_pid_file = '/var/run/postgresql/17-main.pid'
48+
data_directory = '/var/lib/postgresql/$ver/main'
49+
hba_file = '/etc/postgresql/$ver/main/pg_hba.conf'
50+
ident_file = '/etc/postgresql/$ver/main/pg_ident.conf'
51+
external_pid_file = '/var/run/postgresql/$ver-main.pid'
5052
5153
#------------------------------------------------------------------------------
5254
# CONNECTIONS AND AUTHENTICATION
@@ -92,7 +94,7 @@ log_timezone = 'Etc/UTC'
9294
# PROCESS TITLE
9395
#------------------------------------------------------------------------------
9496
95-
cluster_name = '17/main'
97+
cluster_name = '$ver/main'
9698
9799
#------------------------------------------------------------------------------
98100
# CLIENT CONNECTION DEFAULTS

0 commit comments

Comments
 (0)