From 5e8a2104ab28e3a2793d35db47244a99b28d056d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 3 Oct 2022 00:00:06 +0200 Subject: [PATCH] Move logs in /var/log --- conf/freshrss.cron | 2 +- scripts/backup | 6 ++++++ scripts/install | 9 +++++++++ scripts/remove | 3 +++ scripts/restore | 8 ++++++++ scripts/upgrade | 15 ++++++++++++++- 6 files changed, 41 insertions(+), 2 deletions(-) diff --git a/conf/freshrss.cron b/conf/freshrss.cron index f8a5098..1d1112f 100644 --- a/conf/freshrss.cron +++ b/conf/freshrss.cron @@ -1,2 +1,2 @@ MAILTO="root" -*/10 * * * * __APP__ /usr/bin/php__PHPVERSION__ __FINALPATH__/app/actualize_script.php >/var/www/__APP__/__APP__.log 2>&1 +*/10 * * * * __APP__ /usr/bin/php__PHPVERSION__ __FINALPATH__/app/actualize_script.php >/var/log/__APP__/__APP__.log 2>&1 diff --git a/scripts/backup b/scripts/backup index 89da2d0..337664a 100755 --- a/scripts/backup +++ b/scripts/backup @@ -57,6 +57,12 @@ ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= # SPECIFIC BACKUP +#================================================= +# BACKUP LOGROTATE +#================================================= + +ynh_backup --src_path="/etc/logrotate.d/$app" + #================================================= # BACKUP VARIOUS FILES #================================================= diff --git a/scripts/install b/scripts/install index 0bf9216..567d0a1 100755 --- a/scripts/install +++ b/scripts/install @@ -140,6 +140,15 @@ chmod 644 "/etc/cron.d/$app" #================================================= # GENERIC FINALIZATION +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Configuring log rotation..." --weight=1 + +mkdir -p "/var/log/$app" +# Use logrotate to manage application logfile(s) +ynh_use_logrotate + #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/remove b/scripts/remove index 5f47cf3..aeaf6e3 100755 --- a/scripts/remove +++ b/scripts/remove @@ -73,6 +73,9 @@ ynh_script_progression --message="Removing various files..." --weight=1 # Remove a cron file ynh_secure_remove --file="/etc/cron.d/$app" +# Remove the log files +ynh_secure_remove --file="/var/log/$app" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 4d7ed8a..1f98301 100644 --- a/scripts/restore +++ b/scripts/restore @@ -103,6 +103,14 @@ ynh_script_progression --message="Restoring various files..." --weight=1 ynh_restore_file --origin_path="/etc/cron.d/$app" +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 + +mkdir -p "/var/log/$app" +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index e0f5f4e..6e16b9f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -153,11 +153,24 @@ chown root: "/etc/cron.d/$app" chmod 644 "/etc/cron.d/$app" if [ -f /tmp/FreshRSS.log ]; then - ynh_secure_remove /tmp/FreshRSS.log + ynh_secure_remove --file="/tmp/FreshRSS.log" +fi + +if [ -f /var/www/$app/$app.log ]; then + ynh_secure_remove --file="/var/www/$app/$app.log" fi #================================================= # GENERIC FINALIZATION +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 + +mkdir -p "/var/log/$app" +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --non-append + #================================================= # RELOAD NGINX #=================================================