matrix logging

This commit is contained in:
Bob Mottram 2017-05-13 10:12:16 +01:00
parent 86371327cf
commit c945b7d402
2 changed files with 17 additions and 4 deletions

View File

@ -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|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|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_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_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|bind_addresses:.*|bind_addresses: ['127.0.0.1']|g" "${filepath}"
sed -i 's|x_forwarded:.*|x_forwarded: false|g' "${filepath}" sed -i 's|x_forwarded:.*|x_forwarded: false|g' "${filepath}"

View File

@ -78,13 +78,16 @@ if [ ! "$1" ]; then
fi fi
if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then 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 if [ -f /etc/fail2ban/fail2ban.conf ]; then
sed -i 's|loglevel.*|loglevel = 3|g' /etc/fail2ban/fail2ban.conf 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 sed -i 's|logtarget.*|logtarget = /var/log/fail2ban.log|g' /etc/fail2ban/fail2ban.conf
fi 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 [ -d /etc/tor ]; then
if [ ! -f /var/log/tor.log ]; then if [ ! -f /var/log/tor.log ]; then
touch /var/log/tor.log touch /var/log/tor.log
@ -148,6 +151,15 @@ if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then
else else
if [ -f /var/lib/matrix/homeserver.yaml ]; then if [ -f /var/lib/matrix/homeserver.yaml ]; then
sed -i 's|log_file:.*|log_file: /dev/null|g' /var/lib/matrix/homeserver.yaml 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 fi
if [ -d /etc/tor ]; then if [ -d /etc/tor ]; then
sed -i 's|#Log notice file.*|Log notice file /dev/null|g' /etc/tor/torrc 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 if [ -d /etc/fail2ban ]; then
systemctl restart fail2ban systemctl restart fail2ban
fi fi
if [ -f /var/lib/matrix/homeserver.yaml ]; then if [ -d /etc/matrix ]; then
systemctl restart matrix systemctl restart matrix
fi fi