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>
92 lines
3.1 KiB
Python
92 lines
3.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Re-enable nomadvps (neko 7), fix Evan HomeLab group name, deploy 4-channel schedule."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
HOST = "108.174.50.68"
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
APP = "/opt/douyinWEB"
|
|
|
|
EVAN_HOMELAB_GID = "6c42de20-1577-40c4-bd7b-c2cf0005dd77"
|
|
NOMADVPS_GID = "1cc3e3f0-02cf-4216-9780-d5015f338a6e"
|
|
|
|
FILES = [
|
|
"backend/app/yt_assign_db.py",
|
|
"frontend/src/components/YtAssignPanel.tsx",
|
|
]
|
|
|
|
REMOTE = f"""#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
curl -sS -c /tmp/dy.ck -X POST https://dy.nomadro.live/api/auth/login \\
|
|
-H 'Content-Type: application/json' \\
|
|
-d '{{"username":"hackrobot","password":"Xiao4669805@"}}' >/dev/null
|
|
|
|
echo '=== fix groups ==='
|
|
curl -sS -b /tmp/dy.ck -X PATCH "https://dy.nomadro.live/api/youtube/assign/groups/{EVAN_HOMELAB_GID}" \\
|
|
-H 'Content-Type: application/json' \\
|
|
-d '{{"name":"Evan HomeLab","note":"@evan_homelab · Neko #6"}}' | python3 -c "import json,sys; g=json.load(sys.stdin); print('Evan HomeLab', g.get('name'), g.get('enabled'))"
|
|
|
|
curl -sS -b /tmp/dy.ck -X PATCH "https://dy.nomadro.live/api/youtube/assign/groups/{NOMADVPS_GID}" \\
|
|
-H 'Content-Type: application/json' \\
|
|
-d '{{"enabled": true, "neko_enabled": true, "name": "nomadvps", "note": "@nomadvps · Neko #7"}}' | python3 -c "import json,sys; g=json.load(sys.stdin); print('nomadvps', g.get('name'), 'enabled', g.get('enabled'))"
|
|
|
|
cd /opt/douyinWEB/frontend
|
|
npm run build 2>&1 | tail -8
|
|
systemctl restart douyinweb-web
|
|
sleep 2
|
|
systemctl restart douyinweb-api
|
|
sleep 4
|
|
|
|
curl -sS -b /tmp/dy.ck 'https://dy.nomadro.live/api/youtube/assign/schedule' | python3 -c "
|
|
import json,sys
|
|
s=json.load(sys.stdin)
|
|
print('channel_count', s.get('channel_count'), 'slot_hours', s.get('slot_hours'))
|
|
for c in s.get('channels') or []:
|
|
print(c.get('start_label'), c.get('end_label'), c.get('name'), 'active', c.get('active'))
|
|
"
|
|
echo DONE
|
|
"""
|
|
|
|
|
|
def main() -> None:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, 22, "root", "Xiao4669805", timeout=60, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
for rel in FILES:
|
|
print("upload", rel)
|
|
sftp.put(str(ROOT / rel), f"{APP}/{rel.replace(chr(92), '/')}")
|
|
with sftp.file("/tmp/fix_4channel_schedule.sh", "w") as f:
|
|
f.write(REMOTE)
|
|
sftp.chmod("/tmp/fix_4channel_schedule.sh", 0o755)
|
|
sftp.close()
|
|
chan = c.get_transport().open_session()
|
|
chan.settimeout(360)
|
|
chan.exec_command("bash /tmp/fix_4channel_schedule.sh")
|
|
out = b""
|
|
deadline = time.time() + 340
|
|
while time.time() < deadline:
|
|
if chan.recv_ready():
|
|
out += chan.recv(8192)
|
|
elif chan.exit_status_ready():
|
|
while chan.recv_ready():
|
|
out += chan.recv(8192)
|
|
break
|
|
time.sleep(0.5)
|
|
print(out.decode("utf-8", "replace")[-6000:])
|
|
if chan.exit_status_ready():
|
|
print("exit", chan.recv_exit_status())
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|