apt install -y software-properties-common
apt install -y sudo

apt-get update
apt install -y default-jdk

# Import the repository signing key:
sudo apt install -y curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc

# Create the repository configuration file:
. /etc/os-release
sudo sh -c "echo 'deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $VERSION_CODENAME-pgdg main' > /etc/apt/sources.list.d/pgdg.list"

# Update the package lists:
apt-get update

# Install PostgreSQL
apt-get install -y postgresql-18 postgresql-client-18 postgresql-contrib-18

# Allow trust connection from localhost
sed -i 's/scram-sha-256/trust/g' /etc/postgresql/18/main/pg_hba.conf
su - postgres -c "/usr/lib/postgresql/18/bin/pg_ctl reload -D /var/lib/postgresql/18/main"

# Import lsFusion GPG Key
sudo mkdir -m 0755 -p /etc/apt/keyrings/
sudo curl -o /etc/apt/keyrings/lsfusion.asc --fail https://download.lsfusion.org/apt-snap/GPG-KEY-lsfusion

# Install lsFusion repo
sudo sh -c 'echo "deb [signed-by=/etc/apt/keyrings/lsfusion.asc] https://download.lsfusion.org/apt-snap all main" > /etc/apt/sources.list.d/lsfusion.list'
apt-get update

# Install lsFusion server and client
apt-get install -y lsfusion6-server lsfusion6-client
