import paramiko

client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('152.136.232.83', port=22, username='root', password='Jianhua105', timeout=10)

def run(cmd):
    print(f"\n>>> {cmd[:120]}")
    stdin, stdout, stderr = client.exec_command(cmd, timeout=15)
    out = stdout.read().decode('utf-8', errors='replace').strip()
    err = stderr.read().decode('utf-8', errors='replace').strip()
    if out: print(out[-800:])
    if err: print(f"ERR: {err[-300:]}")
    return out

# Verify index.js patch
run("grep -n 'system/config/public' /www/wwwroot/zhinengtiapp/index.js")

# Verify admin.html patch
run("grep -n 'UPDATE_COS' /www/wwwroot/zhinengtiapp/public/admin.html")

# Test endpoint
run("curl -s http://localhost:3002/api/system/config/public")

# Check .env for COS_BUCKET
run("grep COS_ /www/wwwroot/zhinengtiapp/.env")

# Check sysConfig
run("cat /www/wwwroot/zhinengtiapp/data/sysConfig.json 2>/dev/null | head -20")

client.close()
print("\n=== DONE ===")
