pointcloud/.github/scripts/postgresql_postgis.sh
Regina Obe 35fb903c0f Add Test for PG16
Note other changes needed to be made for this:

 - Add new postgres16, it's misnamed as moment, cause it doesn't have
   postgis yet
    - Change postgresql_postgis.sh to:

       - Use trusted instead of apt-key which is deprecated
       - Added a condition to postgresql_postgis.sh to skip PostGIS
	 install if no PostGIS version is specified
         Since PostGIS is not yet available in
	 apt.postgresql.org repo for PG16
       - Use pgdg-snapshot instead of main
	 repo except for PG12
	 (it has all stable branches and main)
       - For PG12, jsut continue to use main repo,
         since PostGIS 2.5 is not carried in snapshot
2023-08-13 17:06:28 -04:00

38 lines
1.5 KiB
Bash
Executable File

#! /bin/bash
set -e
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null
if ["$POSTGRESQL_VERSION" = "12"];
then
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main $POSTGRESQL_VERSION" |sudo tee /etc/apt/sources.list.d/pgdg.list
else
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg-snapshot main $POSTGRESQL_VERSION" |sudo tee /etc/apt/sources.list.d/pgdg.list
fi
# RAISE priority of pgdg
cat << EOF >> ./pgdg.pref
Package: *
Pin: release o=apt.postgresql.org
Pin-Priority: 600
EOF
sudo mv ./pgdg.pref /etc/apt/preferences.d/
sudo apt update
sudo apt-get update
sudo apt-get purge postgresql-*
sudo apt-get install -q postgresql-$POSTGRESQL_VERSION postgresql-server-dev-$POSTGRESQL_VERSION postgresql-client-$POSTGRESQL_VERSION libcunit1-dev valgrind g++
if [ -z "$POSTGIS_VERSION" ]
then
echo "No PostGIS version specified, skipping install of PostGIS"
else
sudo apt-get install postgresql-$POSTGRESQL_VERSION-postgis-$POSTGIS_VERSION
fi
sudo pg_dropcluster --stop $POSTGRESQL_VERSION main
sudo rm -rf /etc/postgresql/$POSTGRESQL_VERSION /var/lib/postgresql/$POSTGRESQL_VERSION
sudo pg_createcluster -u postgres $POSTGRESQL_VERSION main --start -- --auth-local trust --auth-host trust
sudo /etc/init.d/postgresql start $POSTGRESQL_VERSION || sudo journalctl -xe
sudo -iu postgres psql -c 'CREATE ROLE runner SUPERUSER LOGIN CREATEDB;'