freedombone/src/freedombone-logging

83 lines
3.1 KiB
Plaintext
Raw Normal View History

2015-10-31 23:55:09 +01:00
#!/bin/bash
#
# .---. . .
# | | |
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
#
# Freedom in the Cloud
#
# Turn logging on or off
# License
# =======
#
# Copyright (C) 2015 Bob Mottram <bob@robotics.uk.to>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if [ ! "$1" ]; then
exit 1
fi
if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then
if [ -d /etc/nginx ]; then
for filename in /etc/nginx/sites-available/* ; do
filename_domain=$(echo "$filename" | awk -F '/' '{print $5}')
sed -i 's|access_log.*|access_log /var/log/nginx/$filename_domain.access.log;|g' $filename
sed -i 's|warn_log.*|warn_log /var/log/nginx/$filename_domain.warn.log;|g' $filename
sed -i "s|error_log.*|error_log /var/log/nginx/$filename_domain.err.log;|g" $filename
done
fi
if [ -f /etc/init.d/spamassassin ]; then
sed -i 's|DOPTIONS="-s null -d --pidfile=$PIDFILE"|DOPTIONS="-d --pidfile=$PIDFILE"|g' /etc/init.d/spamassassin
fi
if [ -d /etc/prosody ]; then
sed -i 's|info = "/dev/null";|info = "/var/log/prosody/prosody.log";|g' /etc/prosofy/prosody.cfg.lua
sed -i 's|error = "/dev/null";|error = "/var/log/prosody/prosody.err";|g' /etc/prosofy/prosody.cfg.lua
fi
2015-11-01 00:05:01 +01:00
if [ -d /etc/exim4 ]; then
sed -i 's|log_selector =.*|log_selector = MAIN_LOG_SELECTOR|g' /etc/exim4/conf.d/main/90_exim4-config_log_selector
fi
2015-10-31 23:55:09 +01:00
else
if [ -d /etc/nginx ]; then
for filename in /etc/nginx/sites-available/* ; do
sed -i 's|access_log.*|access_log off;|g' $filename
sed -i 's|warn_log.*|warn_log off;|g' $filename
sed -i 's|error_log.*|error_log off;|g' $filename
done
fi
if [ -f /etc/init.d/spamassassin ]; then
sed -i 's|DOPTIONS="-d --pidfile=$PIDFILE"|DOPTIONS="-s null -d --pidfile=$PIDFILE"|g' /etc/init.d/spamassassin
fi
if [ -d /etc/prosody ]; then
2015-11-01 00:12:07 +01:00
sed -i 's|info = "/var/log/prosody/prosody.log";|info = "/dev/null";|g' /etc/prosody/prosody.cfg.lua
sed -i 's|error = "/var/log/prosody/prosody.err";|error = "/dev/null";|g' /etc/prosody/prosody.cfg.lua
2015-10-31 23:55:09 +01:00
fi
2015-11-01 00:05:01 +01:00
if [ -d /etc/exim4 ]; then
sed -i 's|log_selector =.*|log_selector = -all|g' /etc/exim4/conf.d/main/90_exim4-config_log_selector
fi
2015-10-31 23:55:09 +01:00
fi
if [ -d /etc/nginx ]; then
service php5-fpm restart
service nginx restart
fi
if [ -f /etc/init.d/spamassassin ]; then
service spamassassin restart
fi
exit 0