Turn off postgresql logging

This commit is contained in:
Bob Mottram 2018-04-19 11:07:11 +01:00
parent b33deeb016
commit be74c3040a
1 changed files with 21 additions and 0 deletions

View File

@ -90,6 +90,22 @@ function turn_logging_off {
done done
} }
function turn_off_postgresql_logging {
if [ ! -f /etc/postgresql/9.6/main/postgresql.conf ]; then
return
fi
sed -i 's|#log_destination|log_destination|g' /etc/postgresql/9.6/main/postgresql.conf
sed -i "s|log_destination.*|log_destination = 'syslog'|g" /etc/postgresql/9.6/main/postgresql.conf
}
function turn_on_postgresql_logging {
if [ ! -f /etc/postgresql/9.6/main/postgresql.conf ]; then
return
fi
sed -i 's|log_destination|#log_destination|g' /etc/postgresql/9.6/main/postgresql.conf
sed -i "s|log_destination.*|log_destination = 'stderr'|g" /etc/postgresql/9.6/main/postgresql.conf
}
function turn_off_rsys_logging { function turn_off_rsys_logging {
if ! grep -q '/var/log/auth.log' /etc/rsyslog.conf; then if ! grep -q '/var/log/auth.log' /etc/rsyslog.conf; then
return return
@ -199,6 +215,7 @@ if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then
fi fi
fi fi
turn_on_rsys_logging turn_on_rsys_logging
turn_on_postgresql_logging
else else
turn_logging_off turn_logging_off
@ -256,6 +273,7 @@ else
fi fi
fi fi
turn_off_rsys_logging turn_off_rsys_logging
turn_off_postgresql_logging
fi fi
if [ -d /etc/exim4 ]; then if [ -d /etc/exim4 ]; then
@ -301,5 +319,8 @@ fi
if [ -d /etc/matrix ]; then if [ -d /etc/matrix ]; then
systemctl restart matrix systemctl restart matrix
fi fi
if [ -d /etc/postgresql ]; then
systemctl restart postgresql
fi
exit 0 exit 0