diff --git a/conf/phpservermon.cron b/conf/phpservermon.cron new file mode 100644 index 0000000..c13cb6e --- /dev/null +++ b/conf/phpservermon.cron @@ -0,0 +1 @@ +*/5 * * * * __USER__ /usr/bin/php__YNH_PHP_VERSION__ -f __DESTDIR__/cron/status.cron.php \ No newline at end of file diff --git a/manifest.json b/manifest.json index a4edb57..32e6c30 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "$app is a script that checks whether your websites and servers are up and running", "fr": "$app est un application pour vérifier que vos sites web et serveurs fonctionnent" }, - "version": "3.5.2~ynh3", + "version": "3.5.2~ynh4", "url": "www.phpservermonitor.org", "license": "GPL-3.0-or-later", "maintainer": { diff --git a/scripts/backup b/scripts/backup index 14041ed..5165138 100755 --- a/scripts/backup +++ b/scripts/backup @@ -64,6 +64,12 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +#================================================= +# BACKUP THE CRON FILE +#================================================= + +ynh_backup --src_path="/etc/cron.d/$app" + #================================================= # BACKUP THE MYSQL DATABASE #================================================= diff --git a/scripts/install b/scripts/install index 7f371d4..e8860f3 100755 --- a/scripts/install +++ b/scripts/install @@ -162,6 +162,20 @@ ynh_replace_string --match_string="db_user" --replace_string=$db_user --target_f ynh_replace_string --match_string="db_pass" --replace_string=$db_pwd --target_file="$final_path/config.php" ynh_replace_string --match_string="db_name" --replace_string=$db_name --target_file="$final_path/config.php" ynh_replace_string --match_string="'PSM_BASE_URL', ''" --replace_string="'PSM_BASE_URL', '$path_url'" --target_file="$final_path/config.php" + +#================================================= +# ADD A CRON JOB +#================================================= + +cron_path="/etc/cron.d/$app" +cp -a ../conf/phpservermon.cron "$cron_path" +chown root: "$cron_path" +chmod 644 "$cron_path" + +ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="$cron_path" +ynh_replace_string --match_string="__DESTDIR__" --replace_string="$final_path" --target_file="$cron_path" +ynh_replace_string --match_string="__YNH_PHP_VERSION__" --replace_string="$phpversion" --target_file="$cron_path" + #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= diff --git a/scripts/remove b/scripts/remove index eb0b597..6b832df 100755 --- a/scripts/remove +++ b/scripts/remove @@ -72,14 +72,13 @@ ynh_remove_fpm_config # REMOVE VARIOUS FILES #================================================= +#================================================= +# REMOVE THE CRON FILE +#================================================= + # Remove a cron file -#ynh_secure_remove --file="/etc/cron.d/$app" - -# Remove a directory securely -#ynh_secure_remove --file="/etc/$app/" - -# Remove the log files -#ynh_secure_remove --file="/var/log/$app/" +# TODO: Ensure that cron job is not running (How !?) +ynh_secure_remove --file="/etc/cron.d/$app" #================================================= # GENERIC FINALIZATION diff --git a/scripts/restore b/scripts/restore index f8e1283..bdc7043 100755 --- a/scripts/restore +++ b/scripts/restore @@ -91,6 +91,13 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=1 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies +#================================================= +# RESTORE THE CRON FILE +#================================================= + +ynh_restore_file --origin_path="/etc/cron.d/$app" + + #================================================= # RESTORE THE MYSQL DATABASE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 37a1437..1e35489 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -118,6 +118,20 @@ ynh_store_file_checksum --file="$final_path/config.php" # Set permissions on app files chown -R $app:$app $final_path +#================================================= +# UPDATE THE CRON JOB +#================================================= + +cron_path="/etc/cron.d/$app" +cp -a ../conf/phpservermon.cron "$cron_path" +chown root: "$cron_path" +chmod 644 "$cron_path" + +ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="$cron_path" +ynh_replace_string --match_string="__DESTDIR__" --replace_string="$final_path" --target_file="$cron_path" +ynh_replace_string --match_string="__YNH_PHP_VERSION__" --replace_string="$phpversion" --target_file="$cron_path" + + #================================================= # RELOAD NGINX #=================================================