mirror of
https://github.com/YunoHost-Apps/baikal_ynh.git
synced 2024-09-03 18:16:11 +02:00
57 lines
No EOL
1.9 KiB
Bash
57 lines
No EOL
1.9 KiB
Bash
#!/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 |