Update: Fix loi up FW lan 2 that bai do thiet bi da duoc cai PassWord (them o nhap Backup PassWord va fallback)

This commit is contained in:
2026-03-08 14:48:24 +07:00
parent 2c2a78d27c
commit f8ce6f5831
3 changed files with 28 additions and 4 deletions

View File

@@ -113,7 +113,7 @@ def set_device_password(ip, user="root", old_password="", new_password="admin123
def flash_device_ssh(ip, firmware_path, user="root", password="admin123a",
set_passwd=False, status_cb=None):
backup_password="", set_passwd=False, status_cb=None):
"""
Flash firmware to an OpenWrt device via SSH/SCP.
@@ -134,8 +134,14 @@ def flash_device_ssh(ip, firmware_path, user="root", password="admin123a",
if set_passwd:
result = set_device_password(ip, user, "", password, status_cb)
if result.startswith("FAIL"):
# Try with current password as old password
result = set_device_password(ip, user, password, password, status_cb)
# Try with backup password if set
if backup_password:
result = set_device_password(ip, user, backup_password, password, status_cb)
# If still failing, try with current intended password just in case it was already set
if result.startswith("FAIL"):
result = set_device_password(ip, user, password, password, status_cb)
if result.startswith("FAIL"):
return result