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>
51 lines
1.9 KiB
Python
51 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from urllib.parse import parse_qs, urlparse
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
REMOTE = r"""
|
|
import os
|
|
from urllib.parse import parse_qs, urlparse
|
|
from app.config import settings
|
|
from app import db, shorts_oauth
|
|
|
|
print("DY_PUBLIC_BASE_URL", os.environ.get("DY_PUBLIC_BASE_URL"))
|
|
print("settings.public_base_url", repr(settings.public_base_url))
|
|
db.init_db()
|
|
cfg = db.get_settings_map()
|
|
print("kv_redirect", cfg.get("shorts_oauth_redirect_uri"))
|
|
print("resolve('')", shorts_oauth.resolve_redirect_uri(""))
|
|
print("resolve(dy)", shorts_oauth.resolve_redirect_uri("https://dy.nomadro.live"))
|
|
ch_id = "0fcb0235-900e-4434-8531-70cd15366c29"
|
|
url = shorts_oauth.build_authorize_url(channel_pk=ch_id, request_base="https://dy.nomadro.live")
|
|
print("auth_redirect", parse_qs(urlparse(url).query).get("redirect_uri"))
|
|
print("auth_scope", (parse_qs(urlparse(url).query).get("scope") or [""])[0][:180])
|
|
"""
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("108.174.50.68", 22, "root", "Xiao4669805", timeout=45, allow_agent=False, look_for_keys=False)
|
|
# run under systemd env
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/_redir_check.py", "w") as f:
|
|
f.write(REMOTE)
|
|
sftp.close()
|
|
_, o, e = c.exec_command(
|
|
"cd /opt/douyinWEB/backend && set -a && "
|
|
". /etc/systemd/system/douyinweb-api.service 2>/dev/null; "
|
|
"export $(systemctl show douyinweb-api -p Environment --value | tr ' ' '\\n' | xargs -I{} echo {}) 2>/dev/null; "
|
|
"eval $(systemctl show-environment 2>/dev/null); "
|
|
"systemctl show douyinweb-api -p Environment --value | tr ' ' '\\n' > /tmp/dyenv.txt; "
|
|
"set -a; . /tmp/dyenv.txt; set +a; "
|
|
"PYTHONPATH=. .venv/bin/python /tmp/_redir_check.py 2>&1",
|
|
timeout=60,
|
|
)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
print(e.read().decode("utf-8", "replace"))
|
|
c.close()
|