1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| #!/bin/sh
set -e
export PGUSER="$POSTGRES_USER"
psql -c "ALTER SYSTEM SET max_connections = '150';" psql -c "ALTER SYSTEM SET shared_buffers = '1GB';" psql -c "ALTER SYSTEM SET effective_cache_size = '3GB';" psql -c "ALTER SYSTEM SET maintenance_work_mem = '256MB';" psql -c "ALTER SYSTEM SET checkpoint_completion_target = '0.7';" psql -c "ALTER SYSTEM SET wal_buffers = '16MB';" psql -c "ALTER SYSTEM SET default_statistics_target = '100';" psql -c "ALTER SYSTEM SET random_page_cost = '1.1';" psql -c "ALTER SYSTEM SET effective_io_concurrency = '200';" psql -c "ALTER SYSTEM SET work_mem = '6990kB';" psql -c "ALTER SYSTEM SET min_wal_size = '1GB';" psql -c "ALTER SYSTEM SET max_wal_size = '2GB';" psql -c "ALTER SYSTEM SET max_worker_processes = '2';" psql -c "ALTER SYSTEM SET max_parallel_workers_per_gather = '1';" psql -c "ALTER SYSTEM SET max_parallel_workers = '2';"
psql -c "CREATE USER sampleuser WITH PASSWORD 'samplepassword';"
psql -c "CREATE DATABASE gis;"
psql gis -c "CREATE EXTENSION IF NOT EXISTS postgis;" psql gis -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;" psql gis -c "CREATE EXTENSION IF NOT EXISTS addressing_dictionary;"
if [ -f /opt/backups/restore.dump ]; then echo "Restoring backup..." pg_restore -d gis --clean --if-exists /opt/backups/restore.dump fi
|