64 lines
2.3 KiB
Python
64 lines
2.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Deploy UI-only busy unlock (FE build). No backend/data changes."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
ROOT = Path(r"c:\Users\admin\Desktop\douyinWEB")
|
|
FILES = [
|
|
("frontend/src/components/YtAssignPanel.tsx", "/tmp/_dy_YtAssignPanel.tsx"),
|
|
("frontend/src/app/shorts/page.tsx", "/tmp/_dy_shorts_page.tsx"),
|
|
("frontend/src/app/youtube/page.tsx", "/tmp/_dy_youtube_page.tsx"),
|
|
]
|
|
|
|
REMOTE = r'''#!/bin/bash
|
|
set -euo pipefail
|
|
python3 - <<'PY'
|
|
from pathlib import Path
|
|
pairs=[
|
|
('/tmp/_dy_YtAssignPanel.tsx','/opt/douyinWEB/frontend/src/components/YtAssignPanel.tsx'),
|
|
('/tmp/_dy_shorts_page.tsx','/opt/douyinWEB/frontend/src/app/shorts/page.tsx'),
|
|
('/tmp/_dy_youtube_page.tsx','/opt/douyinWEB/frontend/src/app/youtube/page.tsx'),
|
|
]
|
|
for s,d in pairs:
|
|
p=Path(s); dst=Path(d)
|
|
dst.write_bytes(p.read_bytes().replace(b'\r\n',b'\n').replace(b'\r',b'\n'))
|
|
print('ok', dst.name, dst.stat().st_size)
|
|
PY
|
|
cd /opt/douyinWEB/frontend
|
|
npm run build 2>&1 | tail -25
|
|
systemctl restart douyinweb-web.service
|
|
sleep 3
|
|
systemctl is-active douyinweb-web.service
|
|
curl -sS -o /dev/null -w 'youtube=%{http_code}\n' http://127.0.0.1:4015/youtube
|
|
curl -sS -o /dev/null -w 'shorts=%{http_code}\n' http://127.0.0.1:4015/shorts
|
|
'''
|
|
|
|
|
|
def deploy(label, host, port, user, pw, sudo=False):
|
|
print(f"\n===== {label} =====")
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(host, port, user, pw, timeout=45, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
for local, remote in FILES:
|
|
data = (ROOT / local).read_bytes().replace(b"\r\n", b"\n").replace(b"\r", b"\n")
|
|
with sftp.file(remote, "wb") as f:
|
|
f.write(data)
|
|
with sftp.file("/tmp/_dy_ui_busy.sh", "w") as f:
|
|
f.write(REMOTE.replace("\r\n", "\n"))
|
|
sftp.close()
|
|
cmd = f"echo '{pw}' | sudo -S -p '' bash /tmp/_dy_ui_busy.sh" if sudo else "bash /tmp/_dy_ui_busy.sh"
|
|
_, o, e = c.exec_command(cmd, timeout=600)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|
|
|
|
|
|
deploy("vps-dylive", "107.173.30.245", 22, "root", "Xiao4669805", sudo=False)
|
|
deploy("phys-dy", "107.173.30.245", 4014, "eric", "4669805", sudo=True)
|
|
print("DONE")
|