feat(batch): add live reuse admin verification flow
This commit is contained in:
@@ -7,7 +7,7 @@ REMOTE="${REMOTE:-ubuntu@43.155.133.187}"
|
||||
REMOTE_PORTAL_DIR="${REMOTE_PORTAL_DIR:-/var/www/sub2api-portal}"
|
||||
REMOTE_NGINX_SITE="${REMOTE_NGINX_SITE:-/etc/nginx/sites-available/tksea}"
|
||||
REMOTE_HOST_PORT="${REMOTE_HOST_PORT:-18169}"
|
||||
LOCAL_PORTAL_INDEX="${LOCAL_PORTAL_INDEX:-$ROOT_DIR/deploy/tksea-portal/index.html}"
|
||||
LOCAL_PORTAL_DIR="${LOCAL_PORTAL_DIR:-$ROOT_DIR/deploy/tksea-portal}"
|
||||
REMOTE_STAGE_DIR="${REMOTE_STAGE_DIR:-/tmp/sub2api-portal-deploy}"
|
||||
DRY_RUN="${DRY_RUN:-0}"
|
||||
|
||||
@@ -43,18 +43,20 @@ main() {
|
||||
require_cmd ssh
|
||||
require_cmd scp
|
||||
|
||||
[[ -f "$LOCAL_PORTAL_INDEX" ]] || die "missing portal index: $LOCAL_PORTAL_INDEX"
|
||||
[[ -d "$LOCAL_PORTAL_DIR" ]] || die "missing portal dir: $LOCAL_PORTAL_DIR"
|
||||
[[ -f "$LOCAL_PORTAL_DIR/index.html" ]] || die "missing portal index: $LOCAL_PORTAL_DIR/index.html"
|
||||
if [[ "$DRY_RUN" != "1" ]]; then
|
||||
[[ -f "$KEY" ]] || die "missing ssh key: $KEY"
|
||||
fi
|
||||
|
||||
local tmpdir patch_file index_copy
|
||||
local tmpdir patch_file portal_stage_dir
|
||||
tmpdir="$(mktemp -d)"
|
||||
trap "rm -rf $(printf '%q' "$tmpdir")" EXIT
|
||||
patch_file="$tmpdir/patch_tksea_portal_nginx.py"
|
||||
index_copy="$tmpdir/index.html"
|
||||
portal_stage_dir="$tmpdir/portal"
|
||||
|
||||
cp "$LOCAL_PORTAL_INDEX" "$index_copy"
|
||||
mkdir -p "$portal_stage_dir"
|
||||
cp -R "$LOCAL_PORTAL_DIR/." "$portal_stage_dir/"
|
||||
|
||||
cat > "$patch_file" <<EOF
|
||||
from pathlib import Path
|
||||
@@ -144,14 +146,15 @@ path.write_text(text)
|
||||
EOF
|
||||
|
||||
ssh_remote "mkdir -p $(printf '%q' "$REMOTE_STAGE_DIR")"
|
||||
scp_remote "$index_copy" "$REMOTE:$REMOTE_STAGE_DIR/index.html"
|
||||
scp_remote -r "$portal_stage_dir" "$REMOTE:$REMOTE_STAGE_DIR/"
|
||||
scp_remote "$patch_file" "$REMOTE:$REMOTE_STAGE_DIR/patch_tksea_portal_nginx.py"
|
||||
ssh_remote "sudo install -d -m 755 $(printf '%q' "$REMOTE_PORTAL_DIR") && sudo cp $(printf '%q' "$REMOTE_STAGE_DIR/index.html") $(printf '%q' "$REMOTE_PORTAL_DIR/index.html") && sudo python3 $(printf '%q' "$REMOTE_STAGE_DIR/patch_tksea_portal_nginx.py") && sudo nginx -t && sudo systemctl reload nginx"
|
||||
ssh_remote "sudo install -d -m 755 $(printf '%q' "$REMOTE_PORTAL_DIR") && sudo cp -R $(printf '%q' "$REMOTE_STAGE_DIR/portal/.") $(printf '%q' "$REMOTE_PORTAL_DIR/") && sudo python3 $(printf '%q' "$REMOTE_STAGE_DIR/patch_tksea_portal_nginx.py") && sudo nginx -t && sudo systemctl reload nginx"
|
||||
|
||||
cat <<EOF
|
||||
tksea portal deployed
|
||||
remote: ${REMOTE}
|
||||
portal url: https://sub.tksea.top/portal/
|
||||
batch import admin url: https://sub.tksea.top/portal/admin-batch-import.html
|
||||
legacy url: https://sub.tksea.top/kimi-portal/
|
||||
portal dir: ${REMOTE_PORTAL_DIR}
|
||||
nginx site: ${REMOTE_NGINX_SITE}
|
||||
|
||||
@@ -3,6 +3,7 @@ set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
HTML_FILE="$ROOT_DIR/deploy/tksea-portal/index.html"
|
||||
ADMIN_HTML_FILE="$ROOT_DIR/deploy/tksea-portal/admin-batch-import.html"
|
||||
NGINX_FILE="$ROOT_DIR/deploy/tksea-portal/nginx.sub.tksea.top.conf.example"
|
||||
DEPLOY_SCRIPT="$ROOT_DIR/scripts/deploy/deploy_tksea_portal.sh"
|
||||
|
||||
@@ -20,6 +21,7 @@ assert_contains_file() {
|
||||
}
|
||||
|
||||
[[ -f "$HTML_FILE" ]] || fail "missing $HTML_FILE"
|
||||
[[ -f "$ADMIN_HTML_FILE" ]] || fail "missing $ADMIN_HTML_FILE"
|
||||
[[ -f "$NGINX_FILE" ]] || fail "missing $NGINX_FILE"
|
||||
[[ -f "$DEPLOY_SCRIPT" ]] || fail "missing $DEPLOY_SCRIPT"
|
||||
|
||||
@@ -41,6 +43,17 @@ assert_contains_file "$HTML_FILE" "gpt-5.4"
|
||||
assert_contains_file "$HTML_FILE" "MiniMax-M2.7-highspeed"
|
||||
assert_contains_file "$HTML_FILE" "deepseek-chat"
|
||||
|
||||
assert_contains_file "$ADMIN_HTML_FILE" "Batch Import Admin"
|
||||
assert_contains_file "$ADMIN_HTML_FILE" "matched_account_state"
|
||||
assert_contains_file "$ADMIN_HTML_FILE" "account_resolution"
|
||||
assert_contains_file "$ADMIN_HTML_FILE" "/api/batch-import/runs"
|
||||
assert_contains_file "$ADMIN_HTML_FILE" "/api/batch-import/runs/"
|
||||
assert_contains_file "$ADMIN_HTML_FILE" '/items${query ?'
|
||||
assert_contains_file "$ADMIN_HTML_FILE" "Authorization"
|
||||
assert_contains_file "$ADMIN_HTML_FILE" "base_url|api_key|requested_model_1,requested_model_2"
|
||||
assert_contains_file "$ADMIN_HTML_FILE" "reused"
|
||||
assert_contains_file "$ADMIN_HTML_FILE" "reactivated"
|
||||
|
||||
assert_contains_file "$NGINX_FILE" "location = /portal"
|
||||
assert_contains_file "$NGINX_FILE" "location = /kimi-portal"
|
||||
assert_contains_file "$NGINX_FILE" "location /portal/"
|
||||
@@ -48,7 +61,9 @@ assert_contains_file "$NGINX_FILE" "location /portal-proxy/"
|
||||
assert_contains_file "$NGINX_FILE" "location /kimi-portal-proxy/"
|
||||
|
||||
assert_contains_file "$DEPLOY_SCRIPT" "portal url: https://sub.tksea.top/portal/"
|
||||
assert_contains_file "$DEPLOY_SCRIPT" "batch import admin url: https://sub.tksea.top/portal/admin-batch-import.html"
|
||||
assert_contains_file "$DEPLOY_SCRIPT" "REMOTE_PORTAL_DIR"
|
||||
assert_contains_file "$DEPLOY_SCRIPT" "LOCAL_PORTAL_DIR"
|
||||
assert_contains_file "$DEPLOY_SCRIPT" "patch_tksea_portal_nginx.py"
|
||||
|
||||
echo "PASS: tksea portal assets look consistent"
|
||||
|
||||
Reference in New Issue
Block a user