Compare commits

...

2 Commits

Author SHA1 Message Date
rootzoll
be01bee97f #4893 explizit change locales 2024-12-19 16:19:50 +01:00
rootzoll
f38b3834ff #4893 make sure to create postgres with locale en_US.UTF-8 2024-12-19 14:47:41 +01:00

View File

@@ -62,7 +62,7 @@ if [ "$command" = "1" ] || [ "$command" = "on" ]; then
sudo chown -R postgres:postgres $postgres_datadir sudo chown -R postgres:postgres $postgres_datadir
echo "# Create cluster" echo "# Create cluster"
sudo pg_createcluster $PG_VERSION main sudo pg_createcluster --locale en_US.UTF-8 $PG_VERSION main
sudo pg_ctlcluster $PG_VERSION main start sudo pg_ctlcluster $PG_VERSION main start
elif [ -d /mnt/hdd/app-data/postgresql/$PG_VERSION/main ]; then elif [ -d /mnt/hdd/app-data/postgresql/$PG_VERSION/main ]; then
@@ -79,12 +79,12 @@ if [ "$command" = "1" ] || [ "$command" = "on" ]; then
echo "# Create $PG_VERSION config" echo "# Create $PG_VERSION config"
sudo mkdir -p $postgres_datadir/$PG_VERSION/main sudo mkdir -p $postgres_datadir/$PG_VERSION/main
sudo chown -R postgres:postgres $postgres_datadir sudo chown -R postgres:postgres $postgres_datadir
sudo pg_createcluster $PG_VERSION main sudo pg_createcluster --locale en_US.UTF-8 $PG_VERSION main
sudo pg_ctlcluster $PG_VERSION main start sudo pg_ctlcluster $PG_VERSION main start
echo "Setting default password for postgres user" echo "Setting default password for postgres user"
# start cluster temporarily # start cluster temporarily
sudo systemctl start postgresql sudo systemctl start postgresql
sudo pg_createcluster $PG_VERSION main sudo pg_createcluster --locale en_US.UTF-8 $PG_VERSION main
sudo pg_ctlcluster $PG_VERSION main start sudo pg_ctlcluster $PG_VERSION main start
echo "Setting default password for postgres user" echo "Setting default password for postgres user"
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres';" sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres';"
@@ -108,7 +108,7 @@ if [ "$command" = "1" ] || [ "$command" = "on" ]; then
sudo chown -R postgres:postgres $postgres_datadir sudo chown -R postgres:postgres $postgres_datadir
sudo systemctl start postgresql sudo systemctl start postgresql
sudo systemctl start postgresql@13-main sudo systemctl start postgresql@13-main
sudo pg_createcluster $PG_VERSION main sudo pg_createcluster --locale en_US.UTF-8 $PG_VERSION main
sudo pg_ctlcluster $PG_VERSION main start sudo pg_ctlcluster $PG_VERSION main start
elif [ -d /mnt/hdd/app-data/postgresql/13/main ]; then elif [ -d /mnt/hdd/app-data/postgresql/13/main ]; then
@@ -130,7 +130,7 @@ if [ "$command" = "1" ] || [ "$command" = "on" ]; then
sudo chown -R postgres:postgres $postgres_datadir sudo chown -R postgres:postgres $postgres_datadir
# start cluster temporarily # start cluster temporarily
sudo systemctl start postgresql sudo systemctl start postgresql
sudo pg_createcluster 13 main sudo pg_createcluster --locale en_US.UTF-8 13 main
sudo pg_ctlcluster 13 main start sudo pg_ctlcluster 13 main start
echo "# Setting default password for postgres user" echo "# Setting default password for postgres user"
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres';" sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres';"
@@ -154,7 +154,7 @@ if [ "$command" = "1" ] || [ "$command" = "on" ]; then
sudo chown -R postgres:postgres $postgres_datadir sudo chown -R postgres:postgres $postgres_datadir
sudo systemctl start postgresql sudo systemctl start postgresql
sudo systemctl start postgresql@13-main sudo systemctl start postgresql@13-main
sudo pg_createcluster 13 main sudo pg_createcluster --locale en_US.UTF-8 13 main
sudo pg_ctlcluster 13 main start sudo pg_ctlcluster 13 main start
if [ -d /mnt/hdd/app-data/postgresql/$PG_VERSION ] || pg_lsclusters | grep -q "$PG_VERSION main"; then if [ -d /mnt/hdd/app-data/postgresql/$PG_VERSION ] || pg_lsclusters | grep -q "$PG_VERSION main"; then
@@ -185,6 +185,24 @@ if [ "$command" = "1" ] || [ "$command" = "on" ]; then
fi fi
fi fi
# Setting PostgreSQL locale settings
LOCALE_SETTINGS=(
"lc_messages = 'en_US.UTF-8'"
"lc_monetary = 'en_US.UTF-8'"
"lc_numeric = 'en_US.UTF-8'"
"lc_time = 'en_US.UTF-8'"
)
for setting in "${LOCALE_SETTINGS[@]}"; do
key=$(echo "$setting" | cut -d= -f1 | tr -d ' ')
if ! sudo grep -q "^${key}" /etc/postgresql/$PG_VERSION/main/postgresql.conf; then
echo "# Adding $setting"
echo "$setting" | sudo tee -a /etc/postgresql/$PG_VERSION/main/postgresql.conf
else
echo "# Updating $setting"
sudo sed -i "s|^${key}.*|${setting}|" /etc/postgresql/$PG_VERSION/main/postgresql.conf
fi
done
# start cluster # start cluster
sudo systemctl enable postgresql sudo systemctl enable postgresql
sudo systemctl start postgresql sudo systemctl start postgresql