Files
cms-SiteForge/scripts/init_config.py
T
浅念 601451f22b upgrade: adopt V8.21.3 (V8.13→8.21.3: P5 SFTP/S3, P6 multilingual, editor overhaul, enterprise hardening)
Overlay ~150 upstream items onto our V8.12 base, preserving trade-pro
theme, registry tests, and design docs. Re-applied our patch set
(discovery/env_for/blocks.css/type-mapping/theme_color/frontend entries,
test_theme_pro_v3 mods) — all anchors survived upstream evolution.

New platform enhancement (fixes upgrade-introduced regression):
multilingual.site_locale now honors settings_json.locale, plus
PUT /api/i18n/sites/{id}/locale — standalone English sites get
<html lang='en'> under the V8.15 locale-rewrite pipeline.

compose: adopt V8.21.3 (image 8.21.3-dev.1, /api/ready probes, MySQL/S3
env) with project name pinned to siteforge-v8-10 (data volumes).

Tests: 356 passed / 11 failed — all 11 confirmed pre-existing in
pristine V8.21.3 on this host (10 upstream Windows env + our build test
now green after locale fix). Patch registry updated in plan doc.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-23 12:31:03 +08:00

24 lines
1.6 KiB
Python

"""Generate a local .env using only Docker's Python image (no host Python needed)."""
import os
import secrets
from pathlib import Path
root=Path(__file__).resolve().parent.parent
config=root/'.env'
if config.exists():
print('已存在 .env:为了防止覆盖现有密码和密钥,本次不做修改。')
raise SystemExit(0)
password=secrets.token_urlsafe(24)
secret=secrets.token_urlsafe(48)
pg_password=secrets.token_urlsafe(30)
deploy_secret=secrets.token_urlsafe(48)
config.write_text(f'''# SiteForge Factory 8.21.3-dev.1 - 不要上传至代码仓库\nSITEFORGE_PORT=8787\nSITEFORGE_ADMIN_PASSWORD={password}\nSITEFORGE_SESSION_SECRET={secret}\nSITEFORGE_COOKIE_SECURE=false\nSITEFORGE_DOMAIN=siteforge.example.com\nSITEFORGE_PG_USER=siteforge\nSITEFORGE_PG_PASSWORD={pg_password}\nSITEFORGE_PG_DB=siteforge\nSITEFORGE_DEPLOY_SECRET={deploy_secret}\n# Remote deployment target: configure HTTPS URLs and corresponding secrets manually.\nSITEFORGE_DEPLOY_STAGING_URL=\nSITEFORGE_DEPLOY_STAGING_SECRET_REF=\nSITEFORGE_DEPLOY_PRODUCTION_URL=\nSITEFORGE_DEPLOY_PRODUCTION_SECRET_REF=\n''', encoding='utf-8')
try:os.chmod(config,0o600)
except OSError:pass
print('SiteForge 已生成 .env 配置。')
print('首次登录管理员密码:'+password)
print('请将密码保存在安全的位置,忘记后可编辑 .env 的密码并重启容器。')
print('SQLite 单机启动:docker compose up -d --build')
print('PostgreSQL / Redis 企业测试:docker compose -f compose.enterprise.yaml up -d --build')
print('发布 Agent 应安装在独立机器,经 HTTPS 反向代理并限制访问 IP。')