From f3b18c1f1bcb4067aae6ca6a51d4768ddc98ebb6 Mon Sep 17 00:00:00 2001 From: Sameer Naik Date: Mon, 23 Nov 2015 20:46:11 +0530 Subject: [PATCH] avoid duplicate entries in configuration files. Refer #40 --- entrypoint.sh | 59 +++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index af449a8..669acda 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -77,15 +77,11 @@ if [[ ! -d ${PG_DATADIR} ]]; then PGPASSWORD=$REPLICATION_PASS ${PG_BINDIR}/pg_basebackup -D ${PG_DATADIR} \ -h ${REPLICATION_HOST} -p ${REPLICATION_PORT} -U ${REPLICATION_USER} -X stream -w -v -P echo "Setting up hot standby configuration..." - cat >> ${PG_CONFDIR}/postgresql.conf <> ${PG_DATADIR}/recovery.conf < ${PG_DATADIR}/recovery.conf fi else @@ -129,54 +125,51 @@ if [[ -n ${PG_OLD_VERSION} ]]; then fi if [[ ${PSQL_SSLMODE} == disable ]]; then - sed 's/ssl = true/#ssl = true/' -i ${PG_CONFDIR}/postgresql.conf + sudo -Hu ${PG_USER} sed -i "s|^[#]*[ ]*ssl = .*|ssl = false|" ${PG_CONFDIR}/postgresql.conf +else + sudo -Hu ${PG_USER} sed -i "s|^[#]*[ ]*ssl = .*|ssl = true|" ${PG_CONFDIR}/postgresql.conf fi # Change DSM from `posix' to `sysv' if we are inside an lx-brand container if [[ $(uname -v) == "BrandZ virtual linux" ]]; then - sed 's/\(dynamic_shared_memory_type = \)posix/\1sysv/' \ - -i ${PG_CONFDIR}/postgresql.conf + sed 's/\(dynamic_shared_memory_type = \)posix/\1sysv/' -i ${PG_CONFDIR}/postgresql.conf fi # listen on all interfaces -cat >> ${PG_CONFDIR}/postgresql.conf <> ${PG_CONFDIR}/pg_hba.conf <> ${PG_CONFDIR}/pg_hba.conf + fi fi # allow remote connections to postgresql database -cat >> ${PG_CONFDIR}/pg_hba.conf <> ${PG_CONFDIR}/pg_hba.conf +fi # allow replication connections to the database if [[ -n ${REPLICATION_USER} ]]; then if [[ ${PSQL_SSLMODE} == disable ]]; then - cat >> ${PG_CONFDIR}/pg_hba.conf <> ${PG_CONFDIR}/pg_hba.conf + fi else - cat >> ${PG_CONFDIR}/pg_hba.conf <> ${PG_CONFDIR}/pg_hba.conf + fi fi fi if [[ ${PSQL_MODE} == master ]]; then if [[ -n ${REPLICATION_USER} ]]; then echo "Supporting hot standby..." - cat >> ${PG_CONFDIR}/postgresql.conf <