mirror of
https://github.com/openwrt-xiaomi/xmir-patcher.git
synced 2026-09-22 22:57:55 +03:00
gateway: Fix SSH-error after run "reboot" command
This commit is contained in:
+5
-1
@@ -901,7 +901,7 @@ class Gateway():
|
||||
return False
|
||||
return True
|
||||
|
||||
def run_cmd(self, command, msg = None, timeout = None, die_on_error = True):
|
||||
def run_cmd(self, command, msg = None, timeout = None, die_on_error = True, reboot = False):
|
||||
error = 0
|
||||
reslist = [ ]
|
||||
self.errcode = -1
|
||||
@@ -938,6 +938,10 @@ class Gateway():
|
||||
except Exception as e:
|
||||
error = -10
|
||||
finally:
|
||||
if reboot:
|
||||
self.shutdown()
|
||||
self.errcode = 0
|
||||
return ''
|
||||
channel.close()
|
||||
channel.wait_closed()
|
||||
if error != 0 and die_on_error:
|
||||
|
||||
+1
-5
@@ -1116,12 +1116,8 @@ class XqFlash():
|
||||
else:
|
||||
import ssh2
|
||||
print('Send command "reboot" via SSH/Telnet ...')
|
||||
try:
|
||||
gw.run_cmd("reboot -f", die_on_error = False)
|
||||
gw.run_cmd("reboot -f", die_on_error = False, reboot = True)
|
||||
print("Forced REBOOT activated!")
|
||||
except ssh2.exceptions.SocketRecvError as e:
|
||||
print("Forced REBOOT Activated!")
|
||||
pass
|
||||
|
||||
def flash_data_to_mtd(self, img_name, img: Image, timeout, check = True):
|
||||
print(f'Writing {img_name} image to addr 0x{img.addr:08X} ...')
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import platform
|
||||
|
||||
import xmir_base
|
||||
@@ -15,7 +16,8 @@ gw = gateway.Gateway(detect_ssh = False)
|
||||
ssh = gw.detect_ssh(verbose = 1, interactive = True)
|
||||
if ssh > 0:
|
||||
print('Send command "reboot" via SSH ...')
|
||||
gw.run_cmd("reboot")
|
||||
gw.run_cmd("reboot", reboot = True)
|
||||
time.sleep(1)
|
||||
else:
|
||||
if not gw.stok:
|
||||
gw.web_login()
|
||||
|
||||
Reference in New Issue
Block a user