diff --git a/README.md b/README.md index ed6fd97..d1141c6 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,9 @@ this package: ## Additional information +* There is a breaking change in the management of the administrator password when upgrading to 0.7.0. You must change the admin password! +* To be able to change the admin password, please visit the page: `https://you.domain.tld/yunohost/admin/#/apps/baikal/actions` and set a new password. + ## Links * Report a bug: https://github.com/YunoHost-Apps/baikal_ynh/issues diff --git a/actions.toml b/actions.toml new file mode 100644 index 0000000..aa446e3 --- /dev/null +++ b/actions.toml @@ -0,0 +1,10 @@ +[reset_admin_password] +name = "Reset the admin password" +command = "/bin/bash scripts/actions/reset_admin_password" +accepted_return_codes = [0] +description = "Change the admin password of the app." + [reset_admin_password.arguments] + [reset_admin_password.arguments.password] + type = "password" + ask.en = "Set the password for the administration" + ask.fr = "Définissez le mot de passe pour l'administration" \ No newline at end of file diff --git a/scripts/actions/reset_admin_password b/scripts/actions/reset_admin_password new file mode 100644 index 0000000..c2b0be8 --- /dev/null +++ b/scripts/actions/reset_admin_password @@ -0,0 +1,57 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +# Get password +password=${YNH_ACTION_PASSWORD} + +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 +#================================================= + +password_hash_old=$(ynh_app_setting_get --app=$app --key=password_hash) +password_hash=$(echo -n admin:BaikalDAV:$password | sha256sum | cut -d ' ' -f 1) +if [ $password_hash == $password_hash_old ] +then + ynh_die "This is the same password." 0 +fi + +#================================================= +# SPECIFIC ACTION +#================================================= +# CHANGE THE PASSWORD +#================================================= +ynh_script_progression --message="Changing the password..." --weight=1 + +bk_conf="${final_path}/config/baikal.yaml" + +ynh_backup_if_checksum_is_different --file="${final_path}/config/baikal.yaml" + +ynh_replace_string --match_string="${password_hash_old}" --replace_string="${password_hash}" --target_file="$bk_conf" +ynh_app_setting_set --app=$app --key=password_hash --value=$password_hash + +ynh_store_file_checksum --file="${final_path}/config/baikal.yaml" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Execution completed" --last \ No newline at end of file