tweak the way postgresql.conf defines listen_addresses
[plcapi.git] / plc.d / postgresql
index defab86..7e340f0 100755 (executable)
@@ -1,6 +1,4 @@
 #!/bin/bash
-# $Id$
-# $URL$
 #
 # priority: 700
 #
@@ -82,14 +80,12 @@ case "$1" in
        fi
 
        # Enable DB server. PostgreSQL >=8.0 defines listen_addresses,
-       # PostgreSQL 7.x uses tcpip_socket.
-       if grep -q listen_addresses $postgresql_conf ; then
-           sed -i -e '/^listen_addresses/d' $postgresql_conf
-           echo "listen_addresses = '*'" >>$postgresql_conf
-       elif grep -q tcpip_socket $postgresql_conf ; then
-           sed -i -e '/^tcpip_socket/d' $postgresql_conf
-           echo "tcpip_socket = true" >>$postgresql_conf
-       fi
+       # when run within a vserver, this may require localhost to be specified explicitly
+       sed -i -e '/^listen_addresses/d' $postgresql_conf
+       echo "listen_addresses = '${PLC_DB_HOST},localhost'" >> $postgresql_conf
+       # tweak timezone to be 'UTC'
+       sed -i -e '/^timezone=/d' $postgresql_conf
+       echo "timezone='UTC'" >> $postgresql_conf
 
        # Disable access to all DBs from all hosts
        sed -i -e '/^\(host\|local\)/d' $pghba_conf