From edc3a83531e9fbc51dc9c0e13641663b82860606 Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Wed, 21 Nov 2018 11:01:01 +0000
Subject: [PATCH] Logging only if installed

---
 src/freedombone-app-turtl | 6 ++++++
 src/freedombone-app-xmpp  | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/src/freedombone-app-turtl b/src/freedombone-app-turtl
index f5909c484..87d200f1b 100755
--- a/src/freedombone-app-turtl
+++ b/src/freedombone-app-turtl
@@ -74,11 +74,17 @@ function turtl_setting_registration {
 }
 
 function logging_on_turtl {
+    if [ ! -d /etc/turtl ]; then
+        return
+    fi
     sed -i "s|loglevel:.*|loglevel: 'debug'|g" /etc/turtl/config/config.yaml
     systemctl restart turtl
 }
 
 function logging_off_turtl {
+    if [ ! -d /etc/turtl ]; then
+        return
+    fi
     sed -i "s|loglevel:.*|loglevel: 'error'|g" /etc/turtl/config/config.yaml
     systemctl restart turtl
 }
diff --git a/src/freedombone-app-xmpp b/src/freedombone-app-xmpp
index aa0f2f710..1eff54f0f 100755
--- a/src/freedombone-app-xmpp
+++ b/src/freedombone-app-xmpp
@@ -165,6 +165,10 @@ function xmpp_update_e2e_policy {
 }
 
 function logging_on_xmpp {
+    if [ ! -d /etc/prosody ]; then
+        return
+    fi
+
     if ! grep -q 'info = "/var/log/prosody/prosody.log";' /etc/prosody/prosody.cfg.lua; then
         if [ -d /etc/prosody ]; then
             if [ ! -d /var/log/prosody ]; then
@@ -186,6 +190,10 @@ function logging_on_xmpp {
 }
 
 function logging_off_xmpp {
+    if [ ! -d /etc/prosody ]; then
+        return
+    fi
+
     if ! grep -q '/dev/null' /etc/prosody/prosody.cfg.lua; then
         if [ -d /etc/prosody ]; then
             if grep -q "/var/log/prosody/prosody.log" /etc/prosody/prosody.cfg.lua; then
-- 
GitLab