From 42754613df138c9b38165e113f9f99e87a4f83e9 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 5 Aug 2017 23:30:38 +0100 Subject: [PATCH] xmpp logging conditions --- src/freedombone-app-xmpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/freedombone-app-xmpp b/src/freedombone-app-xmpp index 2ae11a3b..832cf9d9 100755 --- a/src/freedombone-app-xmpp +++ b/src/freedombone-app-xmpp @@ -65,19 +65,23 @@ function logging_on_xmpp { mkdir /var/log/prosody chown root:adm /var/log/prosody fi - sed -i 's|info = "/dev/null";|info = "/var/log/prosody/prosody.log";|g' /etc/prosody/prosody.cfg.lua - sed -i 's|error = "/dev/null";|error = "/var/log/prosody/prosody.err";|g' /etc/prosody/prosody.cfg.lua - sed -i 's|levels = { "error" }; to = "/dev/null";|levels = { "error" }; to = "syslog";|g' /etc/prosody/prosody.cfg.lua + if ! grep -q "/var/log/prosody/prosody.log" /etc/prosody/prosody.cfg.lua; then + sed -i 's|info = "/dev/null";|info = "/var/log/prosody/prosody.log";|g' /etc/prosody/prosody.cfg.lua + sed -i 's|error = "/dev/null";|error = "/var/log/prosody/prosody.err";|g' /etc/prosody/prosody.cfg.lua + sed -i 's|levels = { "error" }; to = "/dev/null";|levels = { "error" }; to = "syslog";|g' /etc/prosody/prosody.cfg.lua + fi fi } function logging_off_xmpp { if [ -d /etc/prosody ]; then - sed -i 's|info = "/var/log/prosody/prosody.log";|info = "/dev/null";|g' /etc/prosody/prosody.cfg.lua - sed -i 's|error = "/var/log/prosody/prosody.err";|error = "/dev/null";|g' /etc/prosody/prosody.cfg.lua - sed -i 's|levels = { "error" }; to = "syslog";|levels = { "error" }; to = "/dev/null";|g' /etc/prosody/prosody.cfg.lua - $REMOVE_FILES_COMMAND /var/log/prosody/* - rm -rf /var/log/prosody + if grep -q "/var/log/prosody/prosody.log" /etc/prosody/prosody.cfg.lua; then + sed -i 's|info = "/var/log/prosody/prosody.log";|info = "/dev/null";|g' /etc/prosody/prosody.cfg.lua + sed -i 's|error = "/var/log/prosody/prosody.err";|error = "/dev/null";|g' /etc/prosody/prosody.cfg.lua + sed -i 's|levels = { "error" }; to = "syslog";|levels = { "error" }; to = "/dev/null";|g' /etc/prosody/prosody.cfg.lua + $REMOVE_FILES_COMMAND /var/log/prosody/* + rm -rf /var/log/prosody + fi fi }