From c945b7d402ab44197e36a04406303bbcd79fa20c Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 13 May 2017 10:12:16 +0100 Subject: [PATCH] matrix logging --- src/freedombone-app-matrix | 1 + src/freedombone-logging | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/freedombone-app-matrix b/src/freedombone-app-matrix index ed68d25e..14956bf2 100755 --- a/src/freedombone-app-matrix +++ b/src/freedombone-app-matrix @@ -228,6 +228,7 @@ function matrix_configure_homeserver_yaml { sed -i "s|media_store_path:.*|media_store_path: \"${MATRIX_DATA_DIR}/media_store\"|g" "${filepath}" sed -i "s|pid_file:.*|pid_file: \"${MATRIX_DATA_DIR}/homeserver.pid\"|g" "${filepath}" sed -i "s|log_file:.*|log_file: \"/dev/null\"|g" "${filepath}" + sed -i "s|log_config:|#log_config:|g" "${filepath}" sed -i 's|bind_address:.*|bind_address: 127.0.0.1|g' "${filepath}" sed -i "s|bind_addresses:.*|bind_addresses: ['127.0.0.1']|g" "${filepath}" sed -i 's|x_forwarded:.*|x_forwarded: false|g' "${filepath}" diff --git a/src/freedombone-logging b/src/freedombone-logging index 3004a73b..4e2f4bb4 100755 --- a/src/freedombone-logging +++ b/src/freedombone-logging @@ -78,13 +78,16 @@ if [ ! "$1" ]; then fi if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then + if [ -f /var/lib/matrix/homeserver.yaml ]; then + sed -i 's|log_file:.*|log_file: /etc/matrix/homeserver.log|g' /var/lib/matrix/homeserver.yaml + if ! grep -q "#log_config:" /var/lib/matrix/homeserver.yaml; then + sed -i 's|log_config:|#log_config:|g' /var/lib/matrix/homeserver.yaml + fi + fi if [ -f /etc/fail2ban/fail2ban.conf ]; then sed -i 's|loglevel.*|loglevel = 3|g' /etc/fail2ban/fail2ban.conf sed -i 's|logtarget.*|logtarget = /var/log/fail2ban.log|g' /etc/fail2ban/fail2ban.conf fi - if [ -f /var/lib/matrix/homeserver.yaml ]; then - sed -i 's|log_file:.*|log_file: /var/lib/matrix/homeserver.log|g' /var/lib/matrix/homeserver.yaml - fi if [ -d /etc/tor ]; then if [ ! -f /var/log/tor.log ]; then touch /var/log/tor.log @@ -148,6 +151,15 @@ if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then else if [ -f /var/lib/matrix/homeserver.yaml ]; then sed -i 's|log_file:.*|log_file: /dev/null|g' /var/lib/matrix/homeserver.yaml + if ! grep -q "#log_config:" /var/lib/matrix/homeserver.yaml; then + sed -i 's|log_config:|#log_config:|g' /var/lib/matrix/homeserver.yaml + fi + if [ -f /etc/matrix/homeserver.log ]; then + shred -zu /etc/matrix/homeserver.log + fi + if [ -f /etc/matrix/homeserver.log.1 ]; then + shred -zu /etc/matrix/homeserver.log.1 + fi fi if [ -d /etc/tor ]; then sed -i 's|#Log notice file.*|Log notice file /dev/null|g' /etc/tor/torrc @@ -261,7 +273,7 @@ fi if [ -d /etc/fail2ban ]; then systemctl restart fail2ban fi -if [ -f /var/lib/matrix/homeserver.yaml ]; then +if [ -d /etc/matrix ]; then systemctl restart matrix fi