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>
60 lines
1.9 KiB
Python
60 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Enable public read on douyin-covers bucket + verify cover URLs."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
HOST = "108.174.50.68"
|
|
|
|
REMOTE = r"""#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
echo "=== set anonymous read on douyin-covers ==="
|
|
# SeaweedFS 3.x: per-bucket anonymous access via weed shell
|
|
printf 's3.bucket.access -name douyin-covers -user anonymous -access Read,List\nexit\n' \
|
|
| /opt/seaweedfs/weed shell -master=127.0.0.1:9333 2>&1 | tail -20 || true
|
|
|
|
# fallback command name on newer builds
|
|
printf 's3.anonymous.set -bucket douyin-covers -access Read,List\nexit\n' \
|
|
| /opt/seaweedfs/weed shell -master=127.0.0.1:9333 2>&1 | tail -10 || true
|
|
|
|
echo "=== test anonymous GET ==="
|
|
KEY=$(cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'
|
|
from app import db
|
|
for s in db.list_active_sessions():
|
|
cp = str(s.get('cover_path') or '')
|
|
if '/douyin-covers/' in cp:
|
|
print(cp.split('/douyin-covers/', 1)[-1])
|
|
break
|
|
PY
|
|
)
|
|
echo "key=$KEY"
|
|
if [ -n "$KEY" ]; then
|
|
curl -sS -o /dev/null -w "anon_s3=%{http_code} size=%{size_download}\n" \
|
|
"http://127.0.0.1:8333/douyin-covers/$KEY"
|
|
curl -sS -o /dev/null -w "nginx_cover=%{http_code} size=%{size_download}\n" -k \
|
|
"https://127.0.0.1/douyin-covers/$KEY" -H "Host: dy.nomadro.live"
|
|
fi
|
|
echo DONE
|
|
"""
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, 22, "root", "Xiao4669805", timeout=45, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/fix_s3_public.sh", "w") as f:
|
|
f.write(REMOTE)
|
|
sftp.chmod("/tmp/fix_s3_public.sh", 0o755)
|
|
sftp.close()
|
|
_i, o, e = c.exec_command("bash /tmp/fix_s3_public.sh", timeout=180)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
err = e.read().decode("utf-8", "replace").strip()
|
|
if err:
|
|
print("ERR", err[-2500:])
|
|
c.close()
|