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:
@@ -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
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class FlashThread(QThread):
|
||||
|
||||
def __init__(self, devices, firmware_path, max_workers=10,
|
||||
method="api", ssh_user="root", ssh_password="admin123a",
|
||||
set_passwd=False):
|
||||
ssh_backup_password="", set_passwd=False):
|
||||
super().__init__()
|
||||
self.devices = devices
|
||||
self.firmware_path = firmware_path
|
||||
@@ -63,6 +63,7 @@ class FlashThread(QThread):
|
||||
self.method = method
|
||||
self.ssh_user = ssh_user
|
||||
self.ssh_password = ssh_password
|
||||
self.ssh_backup_password = ssh_backup_password
|
||||
self.set_passwd = set_passwd
|
||||
|
||||
def run(self):
|
||||
@@ -76,6 +77,7 @@ class FlashThread(QThread):
|
||||
dev["ip"], self.firmware_path,
|
||||
user=self.ssh_user,
|
||||
password=self.ssh_password,
|
||||
backup_password=self.ssh_backup_password,
|
||||
set_passwd=self.set_passwd,
|
||||
status_cb=on_status
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user