mirror of
https://github.com/YunoHost-Apps/transmission_ynh.git
synced 2024-09-04 01:46:12 +02:00
Also store the password hash on upgrade
This commit is contained in:
parent
806bfaf4b4
commit
14bbf2cf49
2 changed files with 23 additions and 0 deletions
|
@ -30,6 +30,27 @@ _wait_and_save_rcp_password_hash() {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_save_and_revert_rpc_password_hash_to_password() {
|
||||||
|
# This one is tricky :
|
||||||
|
# * transmission did password -> hash (we want to store hash)
|
||||||
|
# * user might have overrided other settings, we want to save them
|
||||||
|
# * we don't want false positives about user editing, so we revert the password change
|
||||||
|
# * in upgrade script, we will then re-write the saved password hash.
|
||||||
|
|
||||||
|
password_hash=$(jq -r '.["rpc-password"]' "$SETTINGS_FILE")
|
||||||
|
if [[ "$rpcpassword" == "$password_hash" ]]; then
|
||||||
|
# Upgrade already did this, exiting
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
ynh_app_setting_set --app="$app" --key="rpcpassword" --value="$password_hash"
|
||||||
|
|
||||||
|
# Revert the change to maybe prevent ynh_backup_if_checksum_is_different to trigger
|
||||||
|
sed -i "s|\"${password_hash}\"|\"${rpcpassword}\"|" "$SETTINGS_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# EXPERIMENTAL HELPERS
|
# EXPERIMENTAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -44,6 +44,8 @@ else
|
||||||
path_less="$path"
|
path_less="$path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
_save_and_revert_rpc_password_hash_to_password
|
||||||
|
|
||||||
ynh_add_config --template="../conf/settings.json" --destination="$SETTINGS_FILE"
|
ynh_add_config --template="../conf/settings.json" --destination="$SETTINGS_FILE"
|
||||||
|
|
||||||
chmod 400 "$SETTINGS_FILE"
|
chmod 400 "$SETTINGS_FILE"
|
||||||
|
|
Loading…
Reference in a new issue