2017-12-19 19:22:36 +01:00
|
|
|
#!/bin/sh
|
2018-07-15 21:55:35 +02:00
|
|
|
set -e
|
2017-12-15 16:20:09 +01:00
|
|
|
|
2018-10-26 15:02:11 +02:00
|
|
|
cd $(realpath $(dirname "${0}"))/install
|
2017-12-15 16:20:09 +01:00
|
|
|
|
|
|
|
# Create Postgres instance
|
2018-01-27 14:44:44 +01:00
|
|
|
mkdir -p /srv/postgres/data
|
|
|
|
chown -R 5432:5432 /srv/postgres/data
|
|
|
|
chmod 700 /srv/postgres/data
|
2018-09-13 16:21:16 +02:00
|
|
|
lxc-execute -n postgres -- initdb -D /var/lib/postgresql
|
2017-12-15 16:20:09 +01:00
|
|
|
|
|
|
|
# Configure Postgres
|
2018-10-25 22:22:36 +02:00
|
|
|
cp srv/postgres/data/postgresql.conf /srv/postgres/data/postgresql.conf
|
|
|
|
cp srv/postgres/data/pg_hba.conf /srv/postgres/data/pg_hba.conf
|
2018-09-14 15:58:10 +02:00
|
|
|
|
2017-12-15 16:20:09 +01:00
|
|
|
# Enable query logging. Only if the DEBUG environment variable is set
|
|
|
|
if [ ${DEBUG:-0} -eq 1 ]; then
|
2018-01-27 14:44:44 +01:00
|
|
|
sed -i 's/^#log_destination/log_destination/' /srv/postgres/data/postgresql.conf
|
|
|
|
sed -i 's/^#log_statement/log_statement/' /srv/postgres/data/postgresql.conf
|
2017-12-15 16:20:09 +01:00
|
|
|
fi
|
2018-09-05 22:20:24 +02:00
|
|
|
|
|
|
|
# Install service
|
2018-10-25 22:22:36 +02:00
|
|
|
cp etc/init.d/postgres /etc/init.d/postgres
|
2018-09-05 22:20:24 +02:00
|
|
|
rc-update -u
|