59 lines
1.6 KiB
Python
59 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""Compare host browser-launch.sh with local; show if mangled."""
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
LOCAL = ROOT / "backend/neko/browser-launch.sh"
|
|
|
|
|
|
def main() -> None:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(
|
|
"107.173.30.245",
|
|
4014,
|
|
"eric",
|
|
"4669805",
|
|
timeout=45,
|
|
allow_agent=False,
|
|
look_for_keys=False,
|
|
banner_timeout=120,
|
|
)
|
|
sftp = c.open_sftp()
|
|
remote = sftp.file("/opt/douyinWEB/backend/neko/browser-launch.sh", "r").read()
|
|
sftp.close()
|
|
local = LOCAL.read_bytes()
|
|
print("local_sha", hashlib.sha256(local).hexdigest()[:16], "len", len(local))
|
|
print("remote_sha", hashlib.sha256(remote).hexdigest()[:16], "len", len(remote))
|
|
print("same", local == remote)
|
|
text = remote.decode("utf-8", "replace")
|
|
print("--- remote first 40 lines ---")
|
|
print("\n".join(text.splitlines()[:40]))
|
|
print("--- remote grep profile_dir / extension_flags / set - ---")
|
|
for i, line in enumerate(text.splitlines(), 1):
|
|
if any(
|
|
x in line
|
|
for x in (
|
|
"profile_dir=",
|
|
"extension_flags",
|
|
"set -",
|
|
"tm_load_dir",
|
|
"launch_browser",
|
|
"browser_pid",
|
|
)
|
|
):
|
|
print(f"{i}:{line}")
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|