#!/usr/bin/env bash # Uploaded binary (0644) should be detected and made executable on create. set -uo pipefail ENTRY="${1:-ipdduiyy}" BASE="http://127.0.0.1:8888/$ENTRY" PASS=$(awk -F': ' '/^password:/{print $2}' /www/server/panel/data/initial_password.txt) ORIGIN="http://127.0.0.1:8888" curl -s -c /tmp/ck.txt -H 'Content-Type: application/json' -H "Origin: $ORIGIN" \ -d "{\"username\":\"admin\",\"password\":\"$PASS\"}" "$BASE/api/v1/auth/login" >/dev/null CSRF=$(curl -s -b /tmp/ck.txt "$BASE/api/v1/auth/session" | python3 -c "import json,sys;print(json.load(sys.stdin)['data']['csrf'])") H=(-b /tmp/ck.txt -H "X-CSRF-Token: $CSRF" -H 'Content-Type: application/json' -H "Origin: $ORIGIN") echo "== 权限 0644 时仍能检测 ==" stat -c 'before: %a' /www/wwwroot/goauto/app curl -s -b /tmp/ck.txt "$BASE/api/v1/sites/executables?dir=%2Fgoauto" echo echo "== 创建站点并自动补执行位 ==" curl -s "${H[@]}" -d '{"kind":"go","domains":["go.upload"],"root":"/goauto","port":8133,"env":"PORT=8133"}' \ "$BASE/api/v1/sites" > /tmp/goupload.json python3 -c " import json d=json.load(open('/tmp/goupload.json'))['data'] print('slug=%s start_cmd=%s port=%s' % (d['slug'], d['start_cmd'], d['port']))" stat -c 'after: %a' /www/wwwroot/goauto/app SLUG=$(python3 -c "import json;print(json.load(open('/tmp/goupload.json'))['data']['slug'])") sleep 2 systemctl is-active "miaopanel-site-$SLUG.service" curl -s --max-time 5 -H 'Host: go.upload' http://127.0.0.1/ || echo "proxy failed" SID=$(python3 -c "import json;print(json.load(open('/tmp/goupload.json'))['data']['id'])") curl -s "${H[@]}" -X DELETE "$BASE/api/v1/sites/$SID?remove_files=1" >/dev/null echo "cleanup done"