freedombone/src/freedombone-logging

98 lines
3.5 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
# =======
#
2016-10-31 17:24:49 +01:00
# Copyright (C) 2015-2016 Bob Mottram <bob@freedombone.net>
2015-10-31 23:55:09 +01:00
#
# This program is free software: you can redistribute it and/or modify
2016-02-13 23:09:27 +01:00
# it under the terms of the GNU Affero General Public License as published by
2015-10-31 23:55:09 +01:00
# 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
2016-02-13 23:09:27 +01:00
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
2015-10-31 23:55:09 +01:00
#
2016-02-13 23:09:27 +01:00
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2015-10-31 23:55:09 +01:00
2015-11-27 12:42:16 +01:00
PROJECT_NAME='freedombone'
2015-11-27 17:52:23 +01:00
export TEXTDOMAIN=${PROJECT_NAME}-logging
2015-11-27 12:42:16 +01:00
export TEXTDOMAINDIR="/usr/share/locale"
2015-11-16 13:05:07 +01:00
WEBSERVER_LOG_LEVEL='warn'
2015-10-31 23:55:09 +01:00
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}')
2015-11-01 00:18:35 +01:00
sed -i "s|access_log.*|access_log /var/log/nginx/$filename_domain.access.log;|g" $filename
2015-11-16 13:05:07 +01:00
sed -i "s|error_log.*|error_log /var/log/nginx/$filename_domain.err.log $WEBSERVER_LOG_LEVEL;|g" $filename
2015-10-31 23:55:09 +01:00
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
2015-11-01 00:15:30 +01:00
sed -i 's|info = "/dev/null";|info = "/var/log/prosody/prosody.log";|g' /etc/prosody/prosody.cfg.lua
sed -i 's|error = "/dev/null";|error = "/var/log/prosody/prosody.err";|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 = 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
2015-11-16 14:28:17 +01:00
shred -zu /var/log/nginx/*
2015-10-31 23:55:09 +01:00
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-11-16 14:28:17 +01:00
shred -zu /var/log/prosody/prosody.log
shred -zu /var/log/prosody/prosody.err
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
2015-11-01 00:14:28 +01:00
if [ -d /etc/prosody ]; then
service prosody restart
fi
2015-11-01 00:20:41 +01:00
if [ -d /etc/exim4 ]; then
service exim4 restart
fi
2015-10-31 23:55:09 +01:00
exit 0