2026-04-11 12:43:19 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
# 生成安全密钥
|
|
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
urlsafe_rand() { openssl rand -base64 "$1" | tr '+/' '-_' | tr -d '='; }
|
|
|
|
|
|
|
|
|
|
jwt_key=$(urlsafe_rand 32)
|
|
|
|
|
encryption_key=$(urlsafe_rand 32)
|
2026-09-04 03:45:52 +08:00
|
|
|
db_password=$(urlsafe_rand 32)
|
|
|
|
|
redis_password=$(urlsafe_rand 32)
|
|
|
|
|
mysql_password=$(urlsafe_rand 32)
|
|
|
|
|
mysql_root_password=$(urlsafe_rand 32)
|
2026-04-11 12:43:19 +08:00
|
|
|
|
|
|
|
|
cat <<EOF
|
|
|
|
|
|
|
|
|
|
将以下内容添加到 .env 文件:
|
|
|
|
|
|
|
|
|
|
JWT_SECRET_KEY=${jwt_key}
|
|
|
|
|
ENCRYPTION_KEY=${encryption_key}
|
2026-09-04 03:45:52 +08:00
|
|
|
DB_PASSWORD=${db_password}
|
|
|
|
|
REDIS_PASSWORD=${redis_password}
|
|
|
|
|
MYSQL_PASSWORD=${mysql_password}
|
|
|
|
|
MYSQL_ROOT_PASSWORD=${mysql_root_password}
|
2026-04-11 12:43:19 +08:00
|
|
|
|
|
|
|
|
注意:
|
|
|
|
|
- JWT_SECRET_KEY 用于用户登录 token 签名
|
|
|
|
|
- ENCRYPTION_KEY 用于敏感数据加密 (如 Provider API Keys)
|
2026-09-04 03:45:52 +08:00
|
|
|
- 数据库和 Redis 密码分别生成,不复用应用加密密钥
|
2026-04-11 12:43:19 +08:00
|
|
|
EOF
|