init: UserBaseService (backend + deploy + scripts)

This commit is contained in:
chenxing
2026-08-10 14:50:22 +08:00
commit 4ec19486e0
234 changed files with 15604 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
# 探测内网 nacos:8848 是否可达、public 空间下 userbase.yaml 是否存在、是否需要鉴权
echo "== resolve nacos =="
getent hosts nacos || echo "cannot resolve nacos"
echo "== fetch userbase.yaml (public, no auth) =="
curl -s -m 8 -o /tmp/nc.txt -w "http=%{http_code}\n" "http://nacos:8848/nacos/v1/cs/configs?dataId=userbase.yaml&group=USERBASE&tenant="
echo "--- body (first 200 chars) ---"
head -c 200 /tmp/nc.txt; echo
if grep -q "unknown user" /tmp/nc.txt || grep -q "403" /tmp/nc.txt || [ "$(head -c 1 /tmp/nc.txt)" = "" ]; then
echo "== needs auth, try login nacos/nacos =="
TOKEN=$(curl -s -m 8 -X POST "http://nacos:8848/nacos/v1/auth/login?username=nacos&password=nacos" | sed -n 's/.*"accessToken":"\([^"]*\)".*/\1/p')
echo "token_len=${#TOKEN}"
if [ -n "$TOKEN" ]; then
curl -s -m 8 -o /tmp/nc2.txt -w "http=%{http_code}\n" "http://nacos:8848/nacos/v1/cs/configs?dataId=userbase.yaml&group=USERBASE&tenant=&accessToken=$TOKEN"
echo "--- authed body (first 200 chars) ---"
head -c 200 /tmp/nc2.txt; echo
fi
fi
echo "== done =="