refactor: 移除 install.sh 中硬编码的配置模板

配置文件的生成和补全完全由 Go 程序负责,install.sh 只管目录和权限。
以后新增配置项只需改 Go 代码,无需同步修改安装脚本。
This commit is contained in:
2026-05-28 15:37:53 +08:00
parent e32d51a989
commit 5184d42d00
+4 -25
View File
@@ -131,32 +131,11 @@ deploy_files() {
cp -rf "${BUILD_DIR}/templates" "${INSTALL_DIR}/templates"
cp -rf "${BUILD_DIR}/static" "${INSTALL_DIR}/static"
# 复制配置文件(仅当配置目录下不存在时预生成)
if [[ ! -f "${CONFIG_DIR}/config.toml" ]]; then
info "预生成默认配置文件 ..."
cat > "${CONFIG_DIR}/config.toml" <<TMPL
[data]
dir = '${DATA_DIR}'
[database]
type = 'sqlite'
path = 'portal.db'
[database.mysql]
host = '127.0.0.1'
port = 3306
user = 'root'
password = ''
dbname = 'portal_page'
[server]
addr = ':8080'
unix = '${INSTALL_DIR}/server.sock'
TMPL
chown "${SERVICE_USER}:${SERVICE_USER}" "${CONFIG_DIR}/config.toml"
ok "默认配置文件已生成: ${CONFIG_DIR}/config.toml"
else
# 配置文件由程序首次启动时自动生成 + 缺失项自动补全,脚本不干预
if [[ -f "${CONFIG_DIR}/config.toml" ]]; then
info "保留现有配置文件: ${CONFIG_DIR}/config.toml"
else
info "配置文件不存在,程序首次启动将自动生成"
fi
# 设置安装目录所有权