# -*- coding: utf-8 -*- import json import sys import time import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") HOST = "108.174.50.68" LOCAL = r"c:\Users\admin\Desktop\douyinWEB" REMOTE = r""" # S3 anonymous read for cover images python3 - <<'PY' import json path = '/etc/seaweedfs/douyinweb-s3.json' with open(path) as f: cfg = json.load(f) ids = [i for i in cfg.get('identities', []) if i.get('name') != 'anonymous'] ids.append({'name': 'anonymous', 'actions': ['Read:douyin-covers', 'List:douyin-covers']}) cfg['identities'] = ids with open(path, 'w') as f: json.dump(cfg, f, indent=2) print('updated s3 json') PY systemctl restart douyinweb-s3 sleep 2 systemctl is-active douyinweb-s3 curl -sS -o /dev/null -w "s3_anon=%{http_code} sz=%{size_download}\n" \ http://127.0.0.1:8333/douyin-covers/covers/5d3e14cd-8c13-4b7c-9522-e44dc1cad31e.jpg SID=$(cd /opt/douyinWEB/backend && .venv/bin/python -c "from app import db; s=db.list_active_sessions(); print(s[0]['id'] if s else '')") echo sid=$SID if [ -n "$SID" ]; then curl -sS -o /dev/null -w "cover_api=%{http_code} sz=%{size_download}\n" \ "http://127.0.0.1:8014/api/sessions/$SID/cover" fi systemctl restart douyinweb-api sleep 4 systemctl is-active douyinweb-api curl -sS -o /dev/null -w "covers_page=%{http_code}\n" -k https://127.0.0.1/covers/ -H "Host: dy.nomadro.live" -L echo DONE """ 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 ("backend/app/session_auth.py",): print("upload", rel) sftp.put(f"{LOCAL}/{rel}".replace("\\", "/"), f"/opt/douyinWEB/{rel}") sftp.close() _i, o, e = c.exec_command(REMOTE, timeout=90) print(o.read().decode("utf-8", "replace")) if e.read().decode().strip(): print("ERR", e.read().decode()[:500]) c.close()