add-apt-repository -y ppa:openjdk-r/ppa
apt-get update
apt install -y default-jdk

# Create the file repository configuration:
sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

# Import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

# Update the package lists:
apt-get update

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

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

# Import lsFusion GPG Key
wget --quiet -O - https://download.lsfusion.org/apt/GPG-KEY-lsfusion | sudo apt-key add -

# Install lsFusion repo
echo deb https://download.lsfusion.org/apt all main > /etc/apt/sources.list.d/lsfusion.list
apt-get update

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