feat(domoticz): Add password reset via RPCD

New RPCD method: reset_password
- Resets Domoticz admin password via SQLite
- Accessible from LuCI dashboard
- MD5 hashes the password before storing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2026-02-05 13:10:18 +01:00
parent 7f4f34b930
commit 0d619d4780

View File

@ -19,7 +19,7 @@ lxc_exists() {
case "$1" in
list)
echo '{"status":{},"start":{},"stop":{},"restart":{},"install":{},"uninstall":{},"update":{},"configure_mqtt":{},"configure_haproxy":{},"backup":{},"restore":{"path":"str"},"logs":{"lines":"int"}}'
echo '{"status":{},"start":{},"stop":{},"restart":{},"install":{},"uninstall":{},"update":{},"configure_mqtt":{},"configure_haproxy":{},"backup":{},"restore":{"path":"str"},"logs":{"lines":"int"},"reset_password":{"password":"str"}}'
;;
call)
case "$2" in
@ -251,6 +251,35 @@ case "$1" in
json_add_string "logs" "$logs"
json_dump
;;
reset_password)
read -r input
password=$(echo "$input" | jsonfilter -e '@.password' 2>/dev/null)
[ -z "$password" ] && password="password"
# MD5 hash the password
md5hash=$(echo -n "$password" | md5sum | cut -d' ' -f1)
# Update in Domoticz database (username is base64 encoded 'admin')
if lxc_running; then
lxc-attach -n "$LXC_NAME" -- sqlite3 /opt/domoticz/db/domoticz.db \
"UPDATE Users SET Password='$md5hash' WHERE Username='YWRtaW4=';" 2>/dev/null
code=$?
else
echo '{"success":false,"error":"Container not running"}'
exit 0
fi
json_init
if [ "$code" = "0" ]; then
json_add_boolean "success" 1
json_add_string "message" "Password reset successfully"
else
json_add_boolean "success" 0
json_add_string "error" "Failed to reset password"
fi
json_dump
;;
esac
;;
esac