diff --git a/conf/logrotate b/conf/logrotate new file mode 100644 index 0000000..97da905 --- /dev/null +++ b/conf/logrotate @@ -0,0 +1,31 @@ + +LOGTOCHANGE/*.log { + +# Rotate if the logfile exceeds 100Mo + size 10M + +# From https://stash.z-hub.io/projects/ZP/repos/z-push/browse/config/z-push.lr + create www-data www-data + +# Keep 12 old log maximum + rotate 10 + +# Compress the logs with gzip + compress + +# Compress the log at the next cycle. So keep always 2 non compressed logs + delaycompress + +# Copy and truncate the log to allow to continue write on it. Instead of move the log. + copytruncate + +# Do not do an error if the log is missing + missingok + +# Not rotate if the log is empty + notifempty + +# Keep old logs in the same dir + noolddir + +} diff --git a/scripts/backup b/scripts/backup index 509bc33..8041e9e 100755 --- a/scripts/backup +++ b/scripts/backup @@ -29,6 +29,7 @@ ynh_backup "$final_path" "sources" # Backup logs ynh_backup "$final_logpath" "logs" +ynh_backup "/etc/logrotate.d/$app" "logrotate" # Copy NGINX configuration ynh_backup "$final_nginxconf" "nginx.conf" diff --git a/scripts/install b/scripts/install index 30b635b..9d4ee00 100755 --- a/scripts/install +++ b/scripts/install @@ -108,6 +108,7 @@ sudo cp -R ../sources/$SFILE/* $final_path sed -i "s^define('TIMEZONE', .*^define('TIMEZONE', '$(cat /etc/timezone)');^" ../conf/config.php sed -i "s@ALIASTOCHANGE@$final_path@g" ../conf/config.php sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/config.php +sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/logrotate # Enable caldav carddav support if sudo yunohost app list --installed -f baikal | grep -q id ; then @@ -151,6 +152,11 @@ sudo mkdir -p $final_logpath sudo chmod 750 $final_logpath sudo chown www-data:www-data $final_logpath +# Activate logrotate +sudo cp ../conf/logrotate /etc/logrotate.d/$app +sudo chmod 644 /etc/logrotate.d/$app +sudo chown root:root /etc/logrotate.d/$app + #Copy XMLElement.php sudo ln -s /usr/share/awl/inc/XML* /var/www/$app/include/ diff --git a/scripts/remove b/scripts/remove index 7ed0c96..538e6f1 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,6 +12,7 @@ sudo rm -rf /var/www/$app sudo rm -rf /var/log/$app sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf sudo rm -f /etc/php5/fpm/pool.d/$app.conf +sudo rm -f /etc/logrotate.d/$app # Restart of services sudo service php5-fpm reload diff --git a/scripts/restore b/scripts/restore index 33dd5d5..6f21da3 100755 --- a/scripts/restore +++ b/scripts/restore @@ -23,6 +23,11 @@ sudo mkdir -p $final_logpath sudo cp -a ./logs/* $final_logpath/ sudo chown -R www-data:www-data $final_logpath +# Restore logrotate +sudo cp -a ./logrotate /etc/logrotate.d/$app +sudo chmod 644 /etc/logrotate.d/$app +sudo chown root:root /etc/logrotate.d/$app + # Restore NGINX configuration sudo cp -a ./nginx.conf $final_nginxconf diff --git a/scripts/upgrade b/scripts/upgrade index b9c5be4..a895e84 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -54,6 +54,7 @@ sudo rm -rf $final_path sudo rm -rf $final_logpath sudo rm -f $final_nginxconf sudo rm -f $final_phpconf +sudo rm -f /etc/logrotate.d/$app # Copy files to the right place sudo mkdir -p $final_path @@ -69,6 +70,7 @@ sudo cp -R ../sources/$SFILE/* $final_path sed -i "s^define('TIMEZONE', .*^define('TIMEZONE', '$(cat /etc/timezone)');^" ../conf/config.php sed -i "s@ALIASTOCHANGE@$final_path@g" ../conf/config.php sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/config.php +sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/logrotate # Enable caldav carddav support if sudo yunohost app list --installed -f baikal | grep -q id ; then @@ -112,6 +114,11 @@ sudo mkdir -p $final_logpath sudo chmod 750 $final_logpath sudo chown www-data:www-data $final_logpath +# Activate logrotate +sudo cp ../conf/logrotate /etc/logrotate.d/$app +sudo chmod 644 /etc/logrotate.d/$app +sudo chown root:root /etc/logrotate.d/$app + #Copy XMLElement.php sudo ln -s /usr/share/awl/inc/XML* /var/www/z-push/include/