Improve handling of logs

This commit is contained in:
Bob Mottram 2016-11-18 14:43:19 +00:00
parent 1f5173d13d
commit 23f40d14a1
7 changed files with 152 additions and 44 deletions

View File

@ -731,6 +731,9 @@ function install_gnusocial_main {
echo "\$config['ostatus']['hub_retries'] = 3;" >> $gnusocial_config_file echo "\$config['ostatus']['hub_retries'] = 3;" >> $gnusocial_config_file
fi fi
# turn off logging
echo "\$config['site']['logfile'] = /dev/null;" >> $gnusocial_config_file
# This improves performance # This improves performance
sed -i "s|//\$config\['db'\]\['schemacheck'\].*|\$config\['db'\]\['schemacheck'\] = 'script';|g" $gnusocial_config_file sed -i "s|//\$config\['db'\]\['schemacheck'\].*|\$config\['db'\]\['schemacheck'\] = 'script';|g" $gnusocial_config_file

View File

@ -265,6 +265,9 @@ function install_mumble {
MUMBLE_ONION_HOSTNAME=$(add_onion_service mumble ${MUMBLE_PORT} ${MUMBLE_PORT}) MUMBLE_ONION_HOSTNAME=$(add_onion_service mumble ${MUMBLE_PORT} ${MUMBLE_PORT})
# turn off logs by default
sed -i 's|logfile=.*|logfile=/dev/null|g' /etc/mumble-server.ini
update_default_domain update_default_domain
systemctl restart mumble-server systemctl restart mumble-server

View File

@ -430,7 +430,7 @@ function install_radicale {
echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME} echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
echo ' access_log /dev/null;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME} echo ' access_log /dev/null;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
echo ' error_log /var/log/radicale/radicale.log warn;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME} echo ' error_log /dev/null;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME} echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
echo ' location /radicale {' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME} echo ' location /radicale {' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
echo ' auth_basic "Radicale";' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME} echo ' auth_basic "Radicale";' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
@ -449,7 +449,7 @@ function install_radicale {
echo " server_name ${RADICALE_ONION_HOSTNAME};" >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME} echo " server_name ${RADICALE_ONION_HOSTNAME};" >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME} echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
echo ' access_log /dev/null;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME} echo ' access_log /dev/null;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
echo ' error_log /var/log/radicale/radicale.log warn;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME} echo ' error_log /dev/null;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME} echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
echo ' location /radicale {' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME} echo ' location /radicale {' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
echo ' auth_basic "Radicale";' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME} echo ' auth_basic "Radicale";' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}

View File

@ -1348,6 +1348,16 @@ function configure_imap {
if [ -f /etc/systemd/system/sockets.target.wants/dovecot.socket ]; then if [ -f /etc/systemd/system/sockets.target.wants/dovecot.socket ]; then
rm /etc/systemd/system/sockets.target.wants/dovecot.socket rm /etc/systemd/system/sockets.target.wants/dovecot.socket
fi fi
# Separate logging, otherwise syslog is used
if ! grep "# logging" /etc/dovecot/dovecot.conf; then
echo '' >> /etc/dovecot/dovecot.conf
echo '# logging' >> /etc/dovecot/dovecot.conf
echo 'log_path = /var/log/dovecot.log' >> /etc/dovecot/dovecot.conf
echo 'info_log_path = /var/log/dovecot-info.log' >> /etc/dovecot/dovecot.conf
echo 'debug_log_path = /var/log/dovecot-debug.log' >> /etc/dovecot/dovecot.conf
fi
systemctl restart dovecot systemctl restart dovecot
mark_completed $FUNCNAME mark_completed $FUNCNAME
} }

View File

@ -40,58 +40,141 @@ if [ ! "$1" ]; then
fi fi
if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then
if [ -d /etc/nginx ]; then if [ -d /etc/tor ]; then
for filename in /etc/nginx/sites-available/* ; do sed -i 's|#Log notice file.*|Log notice file /var/log/tor.log|g' /etc/tor/torrc
filename_domain=$(echo "$filename" | awk -F '/' '{print $5}') sed -i 's|Log notice file.*|Log notice file /var/log/tor.log|g' /etc/tor/torrc
sed -i "s|access_log.*|access_log /var/log/nginx/$filename_domain.access.log;|g" $filename fi
sed -i "s|error_log.*|error_log /var/log/nginx/$filename_domain.err.log $WEBSERVER_LOG_LEVEL;|g" $filename if [ -f /etc/mumble-server.ini ]; then
done sed -i 's|logfile=.*|logfile=/var/log/mumble-server.log|g' /etc/mumble-server.ini
fi fi
if [ -f /etc/init.d/spamassassin ]; then if [ -f /etc/php5/fpm/php-fpm.conf ]; then
sed -i 's|DOPTIONS="-s null -d --pidfile=$PIDFILE"|DOPTIONS="-d --pidfile=$PIDFILE"|g' /etc/init.d/spamassassin sed -i 's|error_log =.*|error_log = /var/log/php5-fpm.log|g' /etc/php5/fpm/php-fpm.conf
fi fi
if [ -d /etc/prosody ]; then if [ -d /etc/nginx ]; then
sed -i 's|info = "/dev/null";|info = "/var/log/prosody/prosody.log";|g' /etc/prosody/prosody.cfg.lua if [ ! -d /var/log/nginx ]; then
sed -i 's|error = "/dev/null";|error = "/var/log/prosody/prosody.err";|g' /etc/prosody/prosody.cfg.lua mkdir /var/log/nginx
fi fi
if [ -d /etc/exim4 ]; then for filename in /etc/nginx/sites-available/* ; do
sed -i 's|log_selector =.*|log_selector = MAIN_LOG_SELECTOR|g' /etc/exim4/conf.d/main/90_exim4-config_log_selector filename_domain=$(echo "$filename" | awk -F '/' '{print $5}')
fi sed -i "s|access_log.*|access_log /var/log/nginx/$filename_domain.access.log;|g" $filename
sed -i "s|error_log.*|error_log /var/log/nginx/$filename_domain.err.log $WEBSERVER_LOG_LEVEL;|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
if [ ! -d /var/log/prosody ]; then
mkdir /var/log/prosody
fi
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
fi
if [ -d /etc/exim4 ]; then
if [ ! -d /var/log/exim4 ]; then
mkdir /var/log/exim4
fi
sed -i 's|log_selector =.*|log_selector = MAIN_LOG_SELECTOR|g' /etc/exim4/conf.d/main/90_exim4-config_log_selector
fi
if [ -f /etc/dovecot/dovecot.conf ]; then
sed -i 's|log_path =.*|log_path = /var/log/dovecot.log|g' /etc/dovecot/dovecot.conf
sed -i 's|info_log_path =.*|info_log_path = /var/log/dovecot-info.log|g' /etc/dovecot/dovecot.conf
sed -i 's|debug_log_path =.*|debug_log_path = /var/log/dovecot-debug.log|g' /etc/dovecot/dovecot.conf
fi
if [ -d /etc/mysql ]; then
if [ ! -d /var/log/mysql ]; then
mkdir /var/log/mysql
fi
sed -i 's|log_error =.*|log_error = /var/log/mysql/error.log|g' /etc/mysql/my.cnf
fi
else else
if [ -d /etc/nginx ]; then if [ -d /etc/tor ]; then
for filename in /etc/nginx/sites-available/* ; do sed -i 's|#Log notice file.*|Log notice file /dev/null|g' /etc/tor/torrc
sed -i 's|access_log.*|access_log /dev/null;|g' $filename sed -i 's|Log notice file.*|Log notice file /dev/null|g' /etc/tor/torrc
sed -i 's|warn_log.*|warn_log /dev/null;|g' $filename if [ -d /var/log/tor ]; then
sed -i 's|error_log.*|error_log /dev/null;|g' $filename shred -zu /var/log/tor/*
done rm -rf /var/log/tor
shred -zu /var/log/nginx/* fi
fi fi
if [ -f /etc/init.d/spamassassin ]; then if [ -f /etc/mumble-server.ini ]; then
sed -i 's|DOPTIONS="-d --pidfile=$PIDFILE"|DOPTIONS="-s null -d --pidfile=$PIDFILE"|g' /etc/init.d/spamassassin sed -i 's|logfile=.*|logfile=/dev/null|g' /etc/mumble-server.ini
fi if [ -d /var/log/mumble-server ]; then
if [ -d /etc/prosody ]; then shred -zu /var/log/mumble-server/*
sed -i 's|info = "/var/log/prosody/prosody.log";|info = "/dev/null";|g' /etc/prosody/prosody.cfg.lua rm -rf /var/log/mumble-server
sed -i 's|error = "/var/log/prosody/prosody.err";|error = "/dev/null";|g' /etc/prosody/prosody.cfg.lua fi
shred -zu /var/log/prosody/prosody.log fi
shred -zu /var/log/prosody/prosody.err if [ -d /var/log/radicale ]; then
fi shred -zu /var/log/radicale/*
if [ -d /etc/exim4 ]; then rm -rf /var/log/radicale
sed -i 's|log_selector =.*|log_selector = -all|g' /etc/exim4/conf.d/main/90_exim4-config_log_selector fi
fi if [ -f /etc/php5/fpm/php-fpm.conf ]; then
sed -i 's|error_log =.*|error_log = /dev/null|g' /etc/php5/fpm/php-fpm.conf
fi
if [ -d /etc/nginx ]; then
for filename in /etc/nginx/sites-available/* ; do
sed -i 's|access_log.*|access_log /dev/null;|g' $filename
sed -i 's|warn_log.*|warn_log /dev/null;|g' $filename
sed -i 's|error_log.*|error_log /dev/null;|g' $filename
done
shred -zu /var/log/nginx/*
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
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
shred -zu /var/log/prosody/prosody.log
shred -zu /var/log/prosody/prosody.err
fi
if [ -d /etc/exim4 ]; then
sed -i 's|log_selector =.*|log_selector = -all|g' /etc/exim4/conf.d/main/90_exim4-config_log_selector
shred -zu /var/log/exim4/*
fi
if [ -f /etc/dovecot/dovecot.conf ]; then
sed -i 's|log_path =.*|log_path = /dev/null|g' /etc/dovecot/dovecot.conf
sed -i 's|info_log_path =.*|info_log_path = /dev/null|g' /etc/dovecot/dovecot.conf
sed -i 's|debug_log_path =.*|debug_log_path = /dev/null|g' /etc/dovecot/dovecot.conf
shred -zu /var/log/mail.*
fi
if [ -d /etc/mysql ]; then
if [ -d /var/log/mysql ]; then
shred -zu /var/log/mysql/*
fi
if [ -f /var/log/mysql.err ]; then
shred -zu /var/log/mysql.err
fi
if [ -f /var/log/mysql.log ]; then
shred -zu /var/log/mysql.log
fi
sed -i 's|log_error =.*|log_error = /dev/null|g' /etc/mysql/my.cnf
fi
fi fi
if [ -d /etc/nginx ]; then if [ -d /etc/nginx ]; then
service php5-fpm restart systemctl restart php5-fpm
service nginx restart systemctl restart nginx
fi fi
if [ -f /etc/init.d/spamassassin ]; then if [ -f /etc/init.d/spamassassin ]; then
service spamassassin restart systemctl restart spamassassin
fi fi
if [ -d /etc/prosody ]; then if [ -d /etc/prosody ]; then
service prosody restart systemctl restart prosody
fi fi
if [ -d /etc/exim4 ]; then if [ -d /etc/exim4 ]; then
service exim4 restart systemctl restart exim4
fi
if [ -d /etc/dovecot ]; then
systemctl restart dovecot
fi
if [ -d /etc/tor ]; then
systemctl reload tor
fi
if [ -f /etc/mumble-server.ini ]; then
systemctl restart mumble-server
fi
if [ -d /var/www/radicale ]; then
systemctl restart radicale
fi fi
exit 0 exit 0

View File

@ -39,6 +39,10 @@ function install_final {
fi fi
function_check split_gpg_key_into_fragments function_check split_gpg_key_into_fragments
split_gpg_key_into_fragments split_gpg_key_into_fragments
# turn logging off by default
${PROJECT_NAME}-logging off
mark_completed $FUNCNAME mark_completed $FUNCNAME
clear clear
echo '' echo ''

View File

@ -241,6 +241,11 @@ function install_tor {
echo 'Tor failed to install' echo 'Tor failed to install'
exit 38259 exit 38259
fi fi
# turn off logging
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
mark_completed $FUNCNAME mark_completed $FUNCNAME
} }