From e1fc588ab9214aaedce509dff35c99ae8c0ac762 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 3 Mar 2020 20:23:09 +0100 Subject: [PATCH] Clean up expired files --- conf/cron | 4 ++++ manifest.json | 2 +- scripts/backup | 7 +++++++ scripts/install | 9 +++++++++ scripts/remove | 7 +++++++ scripts/restore | 7 +++++++ scripts/upgrade | 9 +++++++++ 7 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 conf/cron diff --git a/conf/cron b/conf/cron new file mode 100644 index 0000000..cb5bdea --- /dev/null +++ b/conf/cron @@ -0,0 +1,4 @@ +# https://gitlab.com/mojo42/Jirafeau/#how-can-i-automatize-the-cleaning-of-old-expired-files + +12 3 * * * __APP__ php7.0 __FINALPATH__/admin.php clean_expired +16 3 * * * __APP__ php7.0 __FINALPATH__/admin.php clean_async diff --git a/manifest.json b/manifest.json index 2a347ff..77e2bc9 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Upload a file in a simple way and give a unique link to it", "fr": "Hébergez simplement un fichier et partagez-le avec un lien unique" }, - "version": "3.4.1~ynh3", + "version": "3.4.1~ynh4", "url": "https://gitlab.com/mojo42/Jirafeau", "license": "AGPL-3.0-only", "maintainer": { diff --git a/scripts/backup b/scripts/backup index 5873ab2..007099f 100644 --- a/scripts/backup +++ b/scripts/backup @@ -54,6 +54,13 @@ ynh_script_progression --message="Backing up php-fpm configuration..." ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf" +#================================================= +# BACKUP THE CRON FILE +#================================================= +ynh_script_progression --message="Backing up the cron file..." + +ynh_backup --src_path="/etc/cron.d/$app" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 507031a..93ab9b2 100755 --- a/scripts/install +++ b/scripts/install @@ -130,6 +130,15 @@ ynh_store_file_checksum --file="$jirafeauconfigfile" # Remove the install.php ynh_secure_remove --file=$final_path/install.php +#================================================= +# SET THE CRON FILE +#================================================= +ynh_script_progression --message="Configuring the cron file..." + +cp ../conf/cron /etc/cron.d/$app +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file=/etc/cron.d/$app +ynh_replace_string --match_string="__APP__" --replace_string=$app --target_file=/etc/cron.d/$app + #================================================= # GENERIC FINALISATION #================================================= diff --git a/scripts/remove b/scripts/remove index ade82c6..29aed30 100755 --- a/scripts/remove +++ b/scripts/remove @@ -45,6 +45,13 @@ ynh_script_progression --message="Removing php-fpm configuration..." --weight=2 # Remove the dedicated php-fpm config ynh_remove_fpm_config +#================================================= +# REMOVE THE CRON FILE +#================================================= +ynh_script_progression --message="Removing the cron file..." + +ynh_secure_remove --file="/etc/cron.d/$app" + #================================================= # SPECIFIC REMOVE #================================================= diff --git a/scripts/restore b/scripts/restore index a94399e..fde181b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -65,6 +65,13 @@ ynh_system_user_create --username=$app ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" +#================================================= +# RESTORE THE CRON FILE +#================================================= +ynh_script_progression --message="Restoring the cron file..." + +ynh_restore_file --origin_path="/etc/cron.d/$app" + #================================================= # SPECIFIC RESTORE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 8aaae53..51b0fe6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -157,6 +157,15 @@ ynh_store_file_checksum --file="$jirafeauconfigfile" # Remove the install.php ynh_secure_remove --file=$final_path/install.php +#================================================= +# SET THE CRON FILE +#================================================= +ynh_script_progression --message="Configuring the cron file..." + +cp ../conf/cron /etc/cron.d/$app +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file=/etc/cron.d/$app +ynh_replace_string --match_string="__APP__" --replace_string=$app --target_file=/etc/cron.d/$app + #================================================= # GENERIC FINALISATION #=================================================