fix: 自动生成并持久化 API_SERVER_KEY
Browse files- entrypoint.sh +10 -0
entrypoint.sh
CHANGED
|
@@ -404,6 +404,15 @@ export API_SERVER_ENABLED=true
|
|
| 404 |
export API_SERVER_PORT=8642
|
| 405 |
export API_SERVER_HOST=127.0.0.1
|
| 406 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 407 |
# 默认允许所有用户
|
| 408 |
export GATEWAY_ALLOW_ALL_USERS="${GATEWAY_ALLOW_ALL_USERS:-true}"
|
| 409 |
|
|
@@ -445,6 +454,7 @@ PERSISTENT_VARS=(
|
|
| 445 |
"AUTH_TOKEN"
|
| 446 |
"HF_TOKEN"
|
| 447 |
"HF_DATASET_REPO"
|
|
|
|
| 448 |
)
|
| 449 |
|
| 450 |
declare -A env_entries=()
|
|
|
|
| 404 |
export API_SERVER_PORT=8642
|
| 405 |
export API_SERVER_HOST=127.0.0.1
|
| 406 |
|
| 407 |
+
# 生成或复用 API Server 密钥
|
| 408 |
+
if [ -n "$API_SERVER_KEY" ]; then
|
| 409 |
+
echo " ℹ️ 使用已有的 API_SERVER_KEY"
|
| 410 |
+
else
|
| 411 |
+
API_SERVER_KEY=$(python3 -c "import secrets; print(secrets.token_hex(32))")
|
| 412 |
+
echo " 🔑 已生成新的 API_SERVER_KEY"
|
| 413 |
+
fi
|
| 414 |
+
export API_SERVER_KEY
|
| 415 |
+
|
| 416 |
# 默认允许所有用户
|
| 417 |
export GATEWAY_ALLOW_ALL_USERS="${GATEWAY_ALLOW_ALL_USERS:-true}"
|
| 418 |
|
|
|
|
| 454 |
"AUTH_TOKEN"
|
| 455 |
"HF_TOKEN"
|
| 456 |
"HF_DATASET_REPO"
|
| 457 |
+
"API_SERVER_ENABLED" "API_SERVER_PORT" "API_SERVER_HOST" "API_SERVER_KEY"
|
| 458 |
)
|
| 459 |
|
| 460 |
declare -A env_entries=()
|