Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP. Co-authored-by: Cursor <cursoragent@cursor.com>
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Wait for leftover apt on PVE guest, then install wg + ffmpeg and bring up wg-dy."""
|
|
import sys
|
|
import time
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
p = paramiko.SSHClient()
|
|
p.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
p.connect("107.173.30.245", 4014, "eric", "4669805", timeout=30, allow_agent=False, look_for_keys=False)
|
|
|
|
|
|
def run(cmd, timeout=60):
|
|
_, o, e = p.exec_command(cmd, timeout=timeout)
|
|
return (o.read() + e.read()).decode("utf-8", "replace")
|
|
|
|
|
|
print("waiting for apt lock...")
|
|
for i in range(40):
|
|
st = run("ps -p 17761 -o pid,cmd= 2>/dev/null; fuser /var/lib/dpkg/lock-frontend 2>/dev/null || true", 15)
|
|
print(f" [{i}] {st.strip()[:200]!r}")
|
|
if "17761" not in st and not st.strip().endswith(tuple("0123456789")):
|
|
# no pid holding
|
|
if "apt-get" not in st and "dpkg" not in st:
|
|
extra = run("pgrep -a apt-get || true; pgrep -a dpkg || true", 10)
|
|
if not extra.strip():
|
|
print("lock free")
|
|
break
|
|
time.sleep(8)
|
|
else:
|
|
print("still busy, last ps:")
|
|
print(run("ps aux | grep -E 'apt|dpkg' | grep -v grep", 10))
|
|
|
|
print("=== install ===")
|
|
print(run(
|
|
"echo '4669805' | sudo -S -p '' bash -c '"
|
|
"export DEBIAN_FRONTEND=noninteractive; "
|
|
"apt-get install -y --no-install-recommends wireguard-tools ffmpeg python3-venv python3-pip; "
|
|
"command -v wg; command -v ffmpeg; ffmpeg -version | head -1"
|
|
"'",
|
|
300,
|
|
))
|
|
p.close()
|
|
print("APT_DONE")
|