From 05977de8e1378a196c760eb259068e53026aead0 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sat, 28 Mar 2020 12:44:22 +0100 Subject: [PATCH] Add an action to disable maintenance mode --- actions.toml | 8 +++++ scripts/actions/disable_maintenance | 52 +++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 actions.toml create mode 100755 scripts/actions/disable_maintenance diff --git a/actions.toml b/actions.toml new file mode 100644 index 0000000..38c52a8 --- /dev/null +++ b/actions.toml @@ -0,0 +1,8 @@ +[disable_maintenance] +name = "Disable the maintenance mode of Nextcloud" +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 Nextcloud 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..0c2c8b2 --- /dev/null +++ b/scripts/actions/disable_maintenance @@ -0,0 +1,52 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} + +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 [ "$(grep "maintenance" "$final_path/config/config.php" | awk '{print $3}' | cut -d',' -f1)" != "true" ] +then + ynh_die --message="Nextcloud isn't currently under maintenance." --ret_code=0 +fi + +#================================================= +# SPECIFIC ACTION +#================================================= +# DISABLE THE MAINTENANCE MODE +#================================================= + +ynh_script_progression --message="Disabling maintenance mode..." --weight=3 + +( +cd "$final_path" && exec_as "$app" \ + php$YNH_PHP_VERSION occ --no-interaction --no-ansi maintenance:mode --off +) + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Execution completed" --last