dnf install -y java-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 postgresql16-server

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

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

systemctl enable postgresql-16
systemctl start postgresql-16

# Autostart PostgreSQL
systemctl enable postgresql-16

# Run PostgreSQL
systemctl start postgresql-16

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

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

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

# Autostart lsFusion server and client
systemctl enable lsfusion6-server
systemctl enable lsfusion6-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 lsfusion6-server
systemctl start lsfusion6-client
