diff --git a/conf/outline.cron b/conf/outline.cron new file mode 100644 index 0000000..65e6066 --- /dev/null +++ b/conf/outline.cron @@ -0,0 +1 @@ +0 3 * * * __APP__ curl https://__DOMAIN__/api/cron.daily?token=__UTILS_SECRET__ \ No newline at end of file diff --git a/scripts/backup b/scripts/backup index 3aa800e..c4eb4aa 100755 --- a/scripts/backup +++ b/scripts/backup @@ -89,6 +89,12 @@ ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" ynh_backup --src_path="/etc/logrotate.d/$app" +#================================================= +# BACKUP THE CRON FILE +#================================================= + +ynh_backup --src_path="/etc/cron.d/$app" + #================================================= # BACKUP LOGS #================================================= diff --git a/scripts/install b/scripts/install index bb02976..5458c3f 100755 --- a/scripts/install +++ b/scripts/install @@ -232,6 +232,15 @@ ynh_script_progression --message="Configuring log rotation..." --weight=1 # Use logrotate to manage application logfile(s) ynh_use_logrotate +#================================================= +# ADD A CRON JOB +#================================================= + +cron_path="/etc/cron.d/$app" +ynh_add_config --template="../conf/outline.cron" --destination="$cron_path" +chown root: "$cron_path" +chmod 644 "$cron_path" + #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= diff --git a/scripts/remove b/scripts/remove index 6705a36..ca52fce 100755 --- a/scripts/remove +++ b/scripts/remove @@ -109,6 +109,16 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config +#================================================= +# SPECIFIC REMOVE +#================================================= +# REMOVE VARIOUS FILES +#================================================= +ynh_script_progression --message="Removing various files..." --weight=1 + +# Remove a cron file +ynh_secure_remove --file="/etc/cron.d/$app" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index d568df4..d52cc61 100755 --- a/scripts/restore +++ b/scripts/restore @@ -188,6 +188,13 @@ ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload +#================================================= +# RESTORE THE CRON FILE +#================================================= +ynh_script_progression --message="Restoring cron job..." --weight=1 + +ynh_restore_file --origin_path="/etc/cron.d/$app" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index eef033d..68f0290 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -193,6 +193,15 @@ ynh_script_progression --message="Upgrading logrotate configuration..." --weight # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append +#================================================= +# UPDATE THE CRON JOB +#================================================= + +cron_path="/etc/cron.d/$app" +ynh_add_config --template="../conf/outline.cron" --destination="$cron_path" +chown root: "$cron_path" +chmod 644 "$cron_path" + #================================================= # INTEGRATE SERVICE IN YUNOHOST #=================================================