trace/deploy/bootstrap-env.sh
Lee 8f5a35395d
All checks were successful
Java Maven 3.9.9 & JDK 26 CI/CD Pipeline / build-and-deploy (push) Successful in 9m30s
refactor: rename TraceCD project to Trace
2026-08-19 19:27:13 +08:00

34 lines
1003 B
Bash

#!/usr/bin/env bash
set -euo pipefail
cd /opt/trace
umask 077
if [[ -e stack.env || -e app.env ]]; then
echo "Refusing to overwrite existing secret environment files." >&2
exit 1
fi
mysql_root_password="$(openssl rand -hex 24)"
mysql_app_password="$(openssl rand -hex 24)"
app_default_password="$(openssl rand -hex 16)"
{
printf 'MYSQL_ROOT_PASSWORD=%s\n' "$mysql_root_password"
printf 'MYSQL_PASSWORD=%s\n' "$mysql_app_password"
printf 'GITEA_HOST=git.1633292.cn\n'
} > stack.env
{
printf '%s\n' 'SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/trace?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&createDatabaseIfNotExist=true'
printf 'SPRING_DATASOURCE_USERNAME=trace\n'
printf 'SPRING_DATASOURCE_PASSWORD=%s\n' "$mysql_app_password"
printf 'DEEPSEEK_API_KEY=\n'
printf 'MIMO_API_KEY=\n'
printf 'APP_DEFAULT_PASSWORD=%s\n' "$app_default_password"
} > app.env
chmod 600 stack.env app.env
ln -s stack.env .env
echo "Created protected environment files."