Keycloak insatll script
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

26 lines
1.2 KiB

#! /bin/bash
if [ "$(whoami)" != "root" ]; then
SUDO=sudo
fi
${SUDO} apt install -y postgresql pwgen
RAND_PASS=`pwgen -s1 16`
POSTGRES_VERSION=`${SUDO} apt show postgresql | grep Version | cut -d" " -f2 | cut -d"+" -f1`
read -p "Postgres replica ip: " -ei '' REPLICA_IP
read -p "Postgres replica user: " -ei 'replica_user' REPLICA_USER
read -p "Postgres replica password: " -ei "$RAND_PASS" REPLICA_PASS
${SUDO} echo $REPLICA_PASS > /usr/local/src/postgres_replica_password
${SUDO} echo "Password is stored in /usr/local/src/postgres_replica_password"
sudo -u postgres pg_conftool set listen_addresses 0.0.0.0
sudo -u postgres pg_conftool set log_destination syslog
sudo -u postgres pg_conftool set max_wall_senders 3
sudo -u postgres pg_conftool set wal_keep_size 1GB
sudo -u postgres pg_conftool set wal_level replica
sudo -u postgres pg_conftool set wal_log_hints on
sudo -u postgres psql -c "CREATE USER '$REPLICA_USER' REPLICATION LOGIN CONNECTION LIMIT 3 ENCRYPTED PASSWORD '$REPLICA_PASS';"
${SUDO} echo "host replication $REPLICA_USER $REPLICA_IP/24 trust" >> /etc/postgresql/$POSTGRES_VERSION/main/pg_hba.conf
${SUDO} systemctl restart postgresql