dnf install -y java-11-openjdk

dnf install -y dnf-utils

# Install the repository RPM:
dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm

# Disable the built-in PostgreSQL module:
dnf -qy module disable postgresql

# Install PostgreSQL:
dnf install -y postgresql15-server

/usr/pgsql-15/bin/postgresql-15-setup initdb

# Allow trust connection from localhost
sed -i 's/scram-sha-256/trust/g' /var/lib/pgsql/15/data/pg_hba.conf

systemctl enable postgresql-15
systemctl start postgresql-15

# Autostart PostgreSQL
systemctl enable postgresql-15

# Run PostgreSQL
systemctl start postgresql-15

# Install lsFusion repo
dnf config-manager --add-repo https://download.lsfusion.org/yum

# Import lsFusion GPG Key
update-crypto-policies --set DEFAULT:SHA1
rpm --import https://download.lsfusion.org/yum/GPG-KEY-lsfusion

# Install lsFusion server and client
dnf install -y lsfusion5-server lsfusion5-client

# Autostart lsFusion server and client
systemctl enable lsfusion5-server
systemctl enable lsfusion5-client

#Allow connections to server 
firewall-cmd --permanent --add-port=8080/tcp
firewall-cmd --permanent --add-port=7652/tcp
firewall-cmd --reload

# Run lsFusion server and client
systemctl start lsfusion5-server
systemctl start lsfusion5-client
