#! /bin/bash . /usr/src/m2/framework/bash_functions.sh . /usr/src/m2/framework/settings.sh #read_m2_settings #mysql_connect_data_v3 # ---- VARS ----- VERSION="1.0.1" SCRIPT_NAME="PostgreSQL 12 install" TEST=0 # 1 - do not execute changes # ---- FUNCTIONS ----- # ---- MAIN ----- k_start if [ "$TEST" == "1" ]; then report "***** TEST MODE ON. Changes will not be applied *****" 8 fi _centos_version if (( centos_version != 8 )); then report "Centos 8 is necessary. Current: $centos_version" 1 k_exit 1 fi report "Starting PostgresSQL 12 install" 3 dnf -y module enable postgresql:12 dnf -y install postgresql-server postgresql-setup --initdb systemctl start postgresql systemctl enable postgresql if postgres -V | grep -q 12; then report "PostgreSQL 12 installed" 0 else report "Failed to install PostgreSQL 12" 1 k_exit 1 fi report "Configuring postgres user" 3 sudo -u postgres psql -U postgres -d postgres -c "alter user postgres with password 'postgres';" > /dev/null 2>&1 # actions by hand: # user: postgres psw: postgres #su -l postgres #psql #\password #\q #exit report "Sane location for configs" 3 mkdir -p /etc/postgresql ln -s /var/lib/pgsql/data/pg_hba.conf /etc/postgresql/pg_hba.conf ln -s /var/lib/pgsql/data/postgresql.conf /etc/postgresql/postgresql.conf report "Configuring permissions" 3 sed -i "s|127.0.0.1\/32 ident\+|127.0.0.1\/32 password|g" /var/lib/pgsql/data/pg_hba.conf sed -i "s|::1\/128 ident\+|::1\/128 password|g" /var/lib/pgsql/data/pg_hba.conf systemctl restart postgresql k_exit 0