| 1 |
#!/usr/bin/env bash |
| 2 |
set -eux |
| 3 |
|
| 4 |
if [[ "${PGVERSION-}" =~ ^[0-9.]+$ ]] |
| 5 |
then |
| 6 |
sudo apt-get remove -y --purge postgresql libpq-dev libpq5 postgresql-client-common postgresql-common |
| 7 |
sudo rm -rf /var/lib/postgresql |
| 8 |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - |
| 9 |
sudo sh -c "echo deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main $PGVERSION >> /etc/apt/sources.list.d/postgresql.list" |
| 10 |
sudo apt-get update -qq |
| 11 |
sudo apt-get -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::="--force-confnew" install postgresql-$PGVERSION postgresql-server-dev-$PGVERSION postgresql-contrib-$PGVERSION |
| 12 |
sudo chmod 777 /etc/postgresql/$PGVERSION/main/pg_hba.conf |
| 13 |
echo "local all postgres trust" > /etc/postgresql/$PGVERSION/main/pg_hba.conf |
| 14 |
echo "local all all trust" >> /etc/postgresql/$PGVERSION/main/pg_hba.conf |
| 15 |
echo "host all pgx_md5 127.0.0.1/32 md5" >> /etc/postgresql/$PGVERSION/main/pg_hba.conf |
| 16 |
echo "host all pgx_pw 127.0.0.1/32 password" >> /etc/postgresql/$PGVERSION/main/pg_hba.conf |
| 17 |
echo "hostssl all pgx_ssl 127.0.0.1/32 md5" >> /etc/postgresql/$PGVERSION/main/pg_hba.conf |
| 18 |
echo "host replication pgx_replication 127.0.0.1/32 md5" >> /etc/postgresql/$PGVERSION/main/pg_hba.conf |
| 19 |
echo "host pgx_test pgx_replication 127.0.0.1/32 md5" >> /etc/postgresql/$PGVERSION/main/pg_hba.conf |
| 20 |
sudo chmod 777 /etc/postgresql/$PGVERSION/main/postgresql.conf |
| 21 |
if $(dpkg --compare-versions $PGVERSION ge 9.6) ; then |
| 22 |
echo "wal_level='logical'" >> /etc/postgresql/$PGVERSION/main/postgresql.conf |
| 23 |
echo "max_wal_senders=5" >> /etc/postgresql/$PGVERSION/main/postgresql.conf |
| 24 |
echo "max_replication_slots=5" >> /etc/postgresql/$PGVERSION/main/postgresql.conf |
| 25 |
fi |
| 26 |
sudo /etc/init.d/postgresql restart |
| 27 |
|
| 28 |
# The tricky test user, below, has to actually exist so that it can be used in a test |
| 29 |
# of aclitem formatting. It turns out aclitems cannot contain non-existing users/roles. |
| 30 |
psql -U postgres -c 'create database pgx_test' |
| 31 |
psql -U postgres pgx_test -c 'create extension hstore' |
| 32 |
psql -U postgres pgx_test -c 'create domain uint64 as numeric(20,0)' |
| 33 |
psql -U postgres -c "create user pgx_ssl SUPERUSER PASSWORD 'secret'" |
| 34 |
psql -U postgres -c "create user pgx_md5 SUPERUSER PASSWORD 'secret'" |
| 35 |
psql -U postgres -c "create user pgx_pw SUPERUSER PASSWORD 'secret'" |
| 36 |
psql -U postgres -c "create user `whoami`" |
| 37 |
psql -U postgres -c "create user pgx_replication with replication password 'secret'" |
| 38 |
psql -U postgres -c "create user \" tricky, ' } \"\" \\ test user \" superuser password 'secret'" |
| 39 |
fi |
| 40 |
|
| 41 |
if [[ "${PGVERSION-}" =~ ^cockroach ]] |
| 42 |
then |
| 43 |
wget -qO- https://binaries.cockroachdb.com/cockroach-v22.1.8.linux-amd64.tgz | tar xvz |
| 44 |
sudo mv cockroach-v22.1.8.linux-amd64/cockroach /usr/local/bin/ |
| 45 |
cockroach start-single-node --insecure --background --listen-addr=localhost |
| 46 |
cockroach sql --insecure -e 'create database pgx_test' |
| 47 |
fi |
| 48 |
|
| 49 |
if [ "${CRATEVERSION-}" != "" ] |
| 50 |
then |
| 51 |
docker run \ |
| 52 |
-p "6543:5432" \ |
| 53 |
-d \ |
| 54 |
crate:"$CRATEVERSION" \ |
| 55 |
crate \ |
| 56 |
-Cnetwork.host=0.0.0.0 \ |
| 57 |
-Ctransport.host=localhost \ |
| 58 |
-Clicense.enterprise=false |
| 59 |
fi |