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 False
|
||||||
return True
|
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
|
error = 0
|
||||||
reslist = [ ]
|
reslist = [ ]
|
||||||
self.errcode = -1
|
self.errcode = -1
|
||||||
@@ -938,6 +938,10 @@ class Gateway():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
error = -10
|
error = -10
|
||||||
finally:
|
finally:
|
||||||
|
if reboot:
|
||||||
|
self.shutdown()
|
||||||
|
self.errcode = 0
|
||||||
|
return ''
|
||||||
channel.close()
|
channel.close()
|
||||||
channel.wait_closed()
|
channel.wait_closed()
|
||||||
if error != 0 and die_on_error:
|
if error != 0 and die_on_error:
|
||||||
|
|||||||
+2
-6
@@ -1116,12 +1116,8 @@ class XqFlash():
|
|||||||
else:
|
else:
|
||||||
import ssh2
|
import ssh2
|
||||||
print('Send command "reboot" via SSH/Telnet ...')
|
print('Send command "reboot" via SSH/Telnet ...')
|
||||||
try:
|
gw.run_cmd("reboot -f", die_on_error = False, reboot = True)
|
||||||
gw.run_cmd("reboot -f", die_on_error = False)
|
print("Forced REBOOT activated!")
|
||||||
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):
|
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} ...')
|
print(f'Writing {img_name} image to addr 0x{img.addr:08X} ...')
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
import xmir_base
|
import xmir_base
|
||||||
@@ -15,7 +16,8 @@ gw = gateway.Gateway(detect_ssh = False)
|
|||||||
ssh = gw.detect_ssh(verbose = 1, interactive = True)
|
ssh = gw.detect_ssh(verbose = 1, interactive = True)
|
||||||
if ssh > 0:
|
if ssh > 0:
|
||||||
print('Send command "reboot" via SSH ...')
|
print('Send command "reboot" via SSH ...')
|
||||||
gw.run_cmd("reboot")
|
gw.run_cmd("reboot", reboot = True)
|
||||||
|
time.sleep(1)
|
||||||
else:
|
else:
|
||||||
if not gw.stok:
|
if not gw.stok:
|
||||||
gw.web_login()
|
gw.web_login()
|
||||||
|
|||||||
Reference in New Issue
Block a user