Browse Source

matrix logging

Bob Mottram 8 years ago
parent
commit
c945b7d402
2 changed files with 17 additions and 4 deletions
  1. 1
    0
      src/freedombone-app-matrix
  2. 16
    4
      src/freedombone-logging

+ 1
- 0
src/freedombone-app-matrix View File

228
     sed -i "s|media_store_path:.*|media_store_path: \"${MATRIX_DATA_DIR}/media_store\"|g" "${filepath}"
228
     sed -i "s|media_store_path:.*|media_store_path: \"${MATRIX_DATA_DIR}/media_store\"|g" "${filepath}"
229
     sed -i "s|pid_file:.*|pid_file: \"${MATRIX_DATA_DIR}/homeserver.pid\"|g" "${filepath}"
229
     sed -i "s|pid_file:.*|pid_file: \"${MATRIX_DATA_DIR}/homeserver.pid\"|g" "${filepath}"
230
     sed -i "s|log_file:.*|log_file: \"/dev/null\"|g" "${filepath}"
230
     sed -i "s|log_file:.*|log_file: \"/dev/null\"|g" "${filepath}"
231
+    sed -i "s|log_config:|#log_config:|g" "${filepath}"
231
     sed -i 's|bind_address:.*|bind_address: 127.0.0.1|g' "${filepath}"
232
     sed -i 's|bind_address:.*|bind_address: 127.0.0.1|g' "${filepath}"
232
     sed -i "s|bind_addresses:.*|bind_addresses: ['127.0.0.1']|g" "${filepath}"
233
     sed -i "s|bind_addresses:.*|bind_addresses: ['127.0.0.1']|g" "${filepath}"
233
     sed -i 's|x_forwarded:.*|x_forwarded: false|g' "${filepath}"
234
     sed -i 's|x_forwarded:.*|x_forwarded: false|g' "${filepath}"

+ 16
- 4
src/freedombone-logging View File

78
 fi
78
 fi
79
 
79
 
80
 if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then
80
 if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then
81
+    if [ -f /var/lib/matrix/homeserver.yaml ]; then
82
+        sed -i 's|log_file:.*|log_file: /etc/matrix/homeserver.log|g' /var/lib/matrix/homeserver.yaml
83
+        if ! grep -q "#log_config:" /var/lib/matrix/homeserver.yaml; then
84
+            sed -i 's|log_config:|#log_config:|g' /var/lib/matrix/homeserver.yaml
85
+        fi
86
+    fi
81
     if [ -f /etc/fail2ban/fail2ban.conf ]; then
87
     if [ -f /etc/fail2ban/fail2ban.conf ]; then
82
         sed -i 's|loglevel.*|loglevel = 3|g' /etc/fail2ban/fail2ban.conf
88
         sed -i 's|loglevel.*|loglevel = 3|g' /etc/fail2ban/fail2ban.conf
83
         sed -i 's|logtarget.*|logtarget = /var/log/fail2ban.log|g' /etc/fail2ban/fail2ban.conf
89
         sed -i 's|logtarget.*|logtarget = /var/log/fail2ban.log|g' /etc/fail2ban/fail2ban.conf
84
     fi
90
     fi
85
-    if [ -f /var/lib/matrix/homeserver.yaml ]; then
86
-        sed -i 's|log_file:.*|log_file: /var/lib/matrix/homeserver.log|g' /var/lib/matrix/homeserver.yaml
87
-    fi
88
     if [ -d /etc/tor ]; then
91
     if [ -d /etc/tor ]; then
89
         if [ ! -f /var/log/tor.log ]; then
92
         if [ ! -f /var/log/tor.log ]; then
90
             touch /var/log/tor.log
93
             touch /var/log/tor.log
148
 else
151
 else
149
     if [ -f /var/lib/matrix/homeserver.yaml ]; then
152
     if [ -f /var/lib/matrix/homeserver.yaml ]; then
150
         sed -i 's|log_file:.*|log_file: /dev/null|g' /var/lib/matrix/homeserver.yaml
153
         sed -i 's|log_file:.*|log_file: /dev/null|g' /var/lib/matrix/homeserver.yaml
154
+        if ! grep -q "#log_config:" /var/lib/matrix/homeserver.yaml; then
155
+            sed -i 's|log_config:|#log_config:|g' /var/lib/matrix/homeserver.yaml
156
+        fi
157
+        if [ -f /etc/matrix/homeserver.log ]; then
158
+            shred -zu /etc/matrix/homeserver.log
159
+        fi
160
+        if [ -f /etc/matrix/homeserver.log.1 ]; then
161
+            shred -zu /etc/matrix/homeserver.log.1
162
+        fi
151
     fi
163
     fi
152
     if [ -d /etc/tor ]; then
164
     if [ -d /etc/tor ]; then
153
         sed -i 's|#Log notice file.*|Log notice file /dev/null|g' /etc/tor/torrc
165
         sed -i 's|#Log notice file.*|Log notice file /dev/null|g' /etc/tor/torrc
261
 if [ -d /etc/fail2ban ]; then
273
 if [ -d /etc/fail2ban ]; then
262
     systemctl restart fail2ban
274
     systemctl restart fail2ban
263
 fi
275
 fi
264
-if [ -f /var/lib/matrix/homeserver.yaml ]; then
276
+if [ -d /etc/matrix ]; then
265
     systemctl restart matrix
277
     systemctl restart matrix
266
 fi
278
 fi
267
 
279