fix(cloud-image): enhance firstboot and cleanup scripts for improved security and functionality

- Updated cleanup.sh to avoid recreating .env during cleanup, preventing exposure of default passwords before firstboot.
- Modified firstboot.sh to create .env from .env.example only if it doesn't exist, ensuring no sensitive data is present before initialization.
- Added support for Docker Hub and GitHub tarball download acceleration via new environment variables WEKNORA_GH_PROXY and DOCKER_REGISTRY_MIRROR.
- Implemented a mechanism to prune old WeKnora images based on the current version, reducing image size and maintaining a clean environment.
- Enhanced README.md with instructions for using the new acceleration features and image pruning options.
This commit is contained in:
wizardchen
2026-05-11 15:21:28 +08:00
committed by lyingbug
parent 0eb95ccbd8
commit 0cfbad7f97
5 changed files with 145 additions and 22 deletions
+5 -2
View File
@@ -30,8 +30,11 @@ fi
echo "[cleanup] 2/8 清空 WeKnora 业务数据 + 首启 marker / 日志"
if [[ -d "${WEKNORA_DIR}" ]]; then
rm -rf "${WEKNORA_DIR}/data"/* "${WEKNORA_DIR}/logs"/* 2>/dev/null || true
rm -f "${WEKNORA_DIR}/.env" "${WEKNORA_DIR}/.firstboot.done"
cp "${WEKNORA_DIR}/.env.example" "${WEKNORA_DIR}/.env"
# 故意不在这里重建 .env: 让镜像里 .env 缺失, 任何在 firstboot 之前
# 起来的 docker compose 都会因找不到 .env 而失败, 避免明文默认密码
# (postgres123!@# 之类) 把 postgres 数据卷初始化坏。
# firstboot.sh 自己会从 .env.example 拷贝并替换密钥。
rm -f "${WEKNORA_DIR}/.env" "${WEKNORA_DIR}/.firstboot.done"
fi
rm -f /root/weknora-credentials.txt /var/log/weknora-firstboot.log