#!/usr/bin/env bash source /scripts/env-data.sh SETUP_LOCKFILE="${ROOT_CONF}/.postgresql.conf.lock" if [ -f "${SETUP_LOCKFILE}" ]; then return 0 fi list=(`echo ${POSTGRES_DBNAME} | tr ',' ' '`) arr=(${list}) SINGLE_DB=${arr[0]} # This script will setup necessary configuration to enable replications # Refresh configuration in case environment settings changed. cat $CONF.template > $CONF # Reflect DATADIR loaction # Delete any data_dir declarations sed -i '/data_directory/d' $CONF echo "data_directory = '${DATADIR}'" >> $CONF # This script will setup necessary configuration to optimise for PostGIS and to enable replications cat >> $CONF <> "$CONF" <> "$CONF" <> $CONF # Optimise PostgreSQL shared memory for PostGIS # shmall units are pages and shmmax units are bytes(?) equivalent to the desired shared_buffer size set in setup_conf.sh - in this case 500MB echo "kernel.shmmax=543252480" >> /etc/sysctl.conf echo "kernel.shmall=2097152" >> /etc/sysctl.conf # Put lock file to make sure conf was not reinitialized touch ${SETUP_LOCKFILE}