Files
aios/ops/gitops-migration/fix_gitops_api_owner_and_uat.sh
T

64 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT="/data/aios-gitops"
WORKSPACE="$ROOT/workspace"
LOG="$ROOT/logs/gitops-api-owner-fix-uat.log"
mkdir -p "$ROOT/logs"
exec > >(tee -a "$LOG") 2>&1
echo "== fix ownership =="
sudo chown -R aiman:aiman "$ROOT/runtime" "$WORKSPACE" "$ROOT/logs" "$ROOT/artifacts"
echo "== commit sanitized runner =="
cd "$WORKSPACE"
git add scripts/hermes_gitops_parallel_agents.py
git commit -m "fix(gitops): sanitize parallel agent UAT secret handling" || true
echo "== restart API =="
sudo systemctl restart aios-gitops-model-api.service
sleep 3
systemctl status aios-gitops-model-api.service --no-pager | sed -n '1,100p'
curl -fsS http://127.0.0.1:18890/health
echo
curl -fsS http://127.0.0.1:18890/api/status
echo
echo "== API UAT =="
TOKEN="$(head -1 "$ROOT/runtime/secrets/gitops.tokens")"
curl -fsS \
-H "Authorization: Bearer $TOKEN" \
-H 'X-AIOS-User: agent-uat' \
-H 'X-AIOS-Role: owner' \
-H 'Content-Type: application/json' \
-d '{"username":"agent-uat","role":"owner","tier":"ultra"}' \
http://127.0.0.1:18890/api/runtime/select
echo
curl -fsS \
-H "Authorization: Bearer $TOKEN" \
-H 'X-AIOS-User: agent-uat' \
-H 'X-AIOS-Role: owner' \
-H 'Content-Type: application/json' \
-d '{"provider_name":"agent-local-openai-compatible","base_url":"http://127.0.0.1:13000/v1","model_name":"agent-test-model","display_name":"Agent Test Model","priority":10,"api_key_secret_ref":"secret://llm/agent-uat/pre-provisioned-test"}' \
http://127.0.0.1:18890/api/model/custom/add
echo
curl -fsS \
-H "Authorization: Bearer $TOKEN" \
-H 'X-AIOS-User: agent-uat' \
-H 'X-AIOS-Role: owner' \
-H 'Content-Type: application/json' \
-d '{"username":"agent-uat"}' \
http://127.0.0.1:18890/api/model/route/resolve
echo
echo "== secret scan =="
if grep -R 'redacted-test-key\|sk-[A-Za-z0-9]' -n "$WORKSPACE" "$ROOT/logs" 2>/dev/null; then
echo "SECRET_SCAN_FAILED"
exit 2
fi
echo "SECRET_SCAN_OK"
echo "== git status =="
git status --short
git log --oneline -8