#!/usr/bin/env bash # Verify ownership handoff and full deletion (config + document root). set -uo pipefail ENTRY="${1:?usage: verify-delete.sh }" BASE="http://127.0.0.1:8888/$ENTRY" PASS=$(awk -F': ' '/^password:/{print $2}' /www/server/panel/data/initial_password.txt) curl -s -c /tmp/ck.txt -H 'Content-Type: application/json' -H 'Origin: http://127.0.0.1:8888' \ -d "{\"username\":\"admin\",\"password\":\"$PASS\"}" "$BASE/api/v1/auth/login" >/tmp/login.out CSRF=$(python3 -c "import json;print(json.load(open('/tmp/login.out'))['data']['csrf'])") echo "=== 创建临时站点 tmpdemo ===" curl -s -b /tmp/ck.txt -H 'Content-Type: application/json' -H 'Origin: http://127.0.0.1:8888' \ -H "X-CSRF-Token: $CSRF" \ -d '{"name":"tmpdemo","kind":"static","domains":["tmp.demo"],"options":{"waf":true,"security_headers":true}}' \ "$BASE/api/v1/sites" >/tmp/tmp.json ID=$(python3 -c "import json;print(json.load(open('/tmp/tmp.json'))['data']['id'])") echo "id=$ID owner=$(stat -c '%U:%G' /www/wwwroot/tmpdemo)" ls -1 /www/server/panel/vhost/nginx/extension/tmpdemo/ echo "=== 删除(含目录) ===" curl -s -b /tmp/ck.txt -H 'X-CSRF-Token: '"$CSRF" -X DELETE \ "$BASE/api/v1/sites/$ID?remove_files=1"; echo if [ -e /www/wwwroot/tmpdemo ]; then echo "目录仍存在"; else echo "目录已删除"; fi if [ -e /www/server/panel/vhost/nginx/tmpdemo.conf ]; then echo "vhost 仍存在"; else echo "vhost 已删除"; fi nginx -t 2>&1 | tail -1 echo "=== 指标接口 ===" curl -s -b /tmp/ck.txt "$BASE/api/v1/system/info" | python3 -c " import json,sys d=json.load(sys.stdin)['data'] print('host:', d['hostname'], d['distro']['pretty_name']) print('cpu: %.1f%% cores=%d load=%.2f' % (d['cpu_usage'], d['cpu_cores'], d['load1'])) print('mem: %.1f%% of %d MB' % (100*d['memory']['used']/d['memory']['total'], d['memory']['total']//1048576)) print('disk: %.1f%% of %d GB' % (100*d['disk']['used']/d['disk']['total'], d['disk']['total']//1073741824)) print('uptime:', d['uptime'], 's') "