feat: auto-restart dashboard after sshx install
This commit is contained in:
parent
c3899471e3
commit
695490c90c
|
|
@ -21,19 +21,35 @@ LINK_RE = re.compile(r"https://sshx\.io/s/[A-Za-z0-9_-]+")
|
||||||
|
|
||||||
|
|
||||||
def _ensure_sshx() -> bool:
|
def _ensure_sshx() -> bool:
|
||||||
if shutil.which("sshx"):
|
already = shutil.which("sshx") is not None
|
||||||
|
if already:
|
||||||
return True
|
return True
|
||||||
try:
|
try:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["sh", "-c", "curl -sSf https://sshx.io/get | sh"],
|
["sh", "-c", "curl -sSf https://sshx.io/get | sh"],
|
||||||
capture_output=True, timeout=60,
|
capture_output=True, timeout=60,
|
||||||
)
|
)
|
||||||
return shutil.which("sshx") is not None
|
if shutil.which("sshx"):
|
||||||
|
_trigger_dashboard_restart()
|
||||||
|
return True
|
||||||
|
return False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("sshx install failed: %s", e)
|
logger.error("sshx install failed: %s", e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def _trigger_dashboard_restart():
|
||||||
|
try:
|
||||||
|
subprocess.Popen(
|
||||||
|
["nohup", "bash", "-c",
|
||||||
|
"sleep 3 && sudo systemctl restart hermes-dashboard"],
|
||||||
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||||
|
stdin=subprocess.DEVNULL, start_new_session=True,
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("Failed to trigger dashboard restart: %s", e)
|
||||||
|
|
||||||
|
|
||||||
def _kill_sshx():
|
def _kill_sshx():
|
||||||
global _sshx_pid, _sshx_link
|
global _sshx_pid, _sshx_link
|
||||||
if _sshx_pid:
|
if _sshx_pid:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue