feat: import Sea vHost single-server testing release

This commit is contained in:
canglan committed 2026-10-30 08:39:10 +08:00
commit 248badd33e
441 files changed
+63221

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -euo pipefail
/www/server/panel/pyenv/bin/python3 - <<'PY'
import json
import os
import stat
import tempfile
from pathlib import Path
path = Path('/www/server/panel/config/api.json')
if not path.is_file() or path.is_symlink():
raise SystemExit('aaPanel API configuration is missing or unsafe')
metadata = path.stat()
payload = json.loads(path.read_text(encoding='utf-8'))
addresses = payload.get('limit_addr')
if not isinstance(payload, dict) or not isinstance(addresses, list):
raise SystemExit('aaPanel API allowlist has an unexpected format')
if '127.0.0.1' in addresses:
print('aaPanel API loopback allowlist: already present')
raise SystemExit(0)
addresses.append('127.0.0.1')
handle, temporary_name = tempfile.mkstemp(prefix='.sea-vhost-api-', dir=str(path.parent), text=True)
try:
with os.fdopen(handle, 'w', encoding='utf-8') as output:
json.dump(payload, output, ensure_ascii=False, separators=(',', ':'))
output.write('\n')
output.flush()
os.fsync(output.fileno())
os.chmod(temporary_name, stat.S_IMODE(metadata.st_mode))
os.chown(temporary_name, metadata.st_uid, metadata.st_gid)
os.replace(temporary_name, path)
finally:
try:
os.unlink(temporary_name)
except FileNotFoundError:
pass
print('aaPanel API loopback allowlist: added 127.0.0.1')
PY