From be74c3040a459bdd133f78a9a0396de9a2e08732 Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@robotics.uk.to>
Date: Thu, 19 Apr 2018 11:07:11 +0100
Subject: [PATCH] Turn off postgresql logging

---
 src/freedombone-logging | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/freedombone-logging b/src/freedombone-logging
index 617109f53..4edc7c699 100755
--- a/src/freedombone-logging
+++ b/src/freedombone-logging
@@ -90,6 +90,22 @@ function turn_logging_off {
     done
 }
 
+function turn_off_postgresql_logging {
+    if [ ! -f /etc/postgresql/9.6/main/postgresql.conf ]; then
+        return
+    fi
+    sed -i 's|#log_destination|log_destination|g' /etc/postgresql/9.6/main/postgresql.conf
+    sed -i "s|log_destination.*|log_destination = 'syslog'|g" /etc/postgresql/9.6/main/postgresql.conf
+}
+
+function turn_on_postgresql_logging {
+    if [ ! -f /etc/postgresql/9.6/main/postgresql.conf ]; then
+        return
+    fi
+    sed -i 's|log_destination|#log_destination|g' /etc/postgresql/9.6/main/postgresql.conf
+    sed -i "s|log_destination.*|log_destination = 'stderr'|g" /etc/postgresql/9.6/main/postgresql.conf
+}
+
 function turn_off_rsys_logging {
     if ! grep -q '/var/log/auth.log' /etc/rsyslog.conf; then
         return
@@ -199,6 +215,7 @@ if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then
         fi
     fi
     turn_on_rsys_logging
+    turn_on_postgresql_logging
 else
     turn_logging_off
 
@@ -256,6 +273,7 @@ else
         fi
     fi
     turn_off_rsys_logging
+    turn_off_postgresql_logging
 fi
 
 if [ -d /etc/exim4 ]; then
@@ -301,5 +319,8 @@ fi
 if [ -d /etc/matrix ]; then
     systemctl restart matrix
 fi
+if [ -d /etc/postgresql ]; then
+    systemctl restart postgresql
+fi
 
 exit 0
-- 
GitLab