From 373685d5736eba2b42495867eb4119db9991a60d Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Tue, 21 Apr 2020 12:45:43 +0200 Subject: [PATCH] Action to remove maintenance mode --- actions.toml | 9 +++++ scripts/actions/disable_maintenance | 56 +++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100755 scripts/actions/disable_maintenance diff --git a/actions.toml b/actions.toml index f10fb3d..4f9185b 100644 --- a/actions.toml +++ b/actions.toml @@ -9,3 +9,12 @@ description = "Change the public access of the app." type = "boolean" ask = "Is it a public app ?" default = true + +[disable_maintenance] +name = "Disable the maintenance mode of Wordpress" +command = "/bin/bash scripts/actions/disable_maintenance" +# user = "root" # optional +# cwd = "/" # optional +# accepted_return_codes = [0, 1, 2, 3] # optional +accepted_return_codes = [0] +description = "Disable the maintenance mode of Wordpress if you're stuck after an upgrade" diff --git a/scripts/actions/disable_maintenance b/scripts/actions/disable_maintenance new file mode 100755 index 0000000..6c3c679 --- /dev/null +++ b/scripts/actions/disable_maintenance @@ -0,0 +1,56 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +app=${YNH_APP_INSTANCE_NAME} + +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +#================================================= +# CHECK IF ARGUMENTS ARE CORRECT +#================================================= + +#================================================= +# CHECK IF AN ACTION HAS TO BE DONE +#================================================= + +# Check the current status of the maintenance mode + +if [ ! -e "$final_path/.maintenance" ] +then + ynh_die --message="Wordpress isn't currently under maintenance." --ret_code=0 +fi + +#================================================= +# SPECIFIC ACTION +#================================================= +# DISABLE THE MAINTENANCE MODE +#================================================= + +ynh_script_progression --message="Disabling maintenance mode..." + +ynh_secure_remove --file="$final_path/.maintenance" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Execution completed" --last