From defe1ee7a175e64d63fc6d9636dbee13fb9d2d86 Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong(cubxxw)" <3293172751nss@gmail.com> Date: Tue, 5 Dec 2023 04:16:00 +0800 Subject: [PATCH] fix: fix openim make init Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> --- .gitignore | 3 ++- scripts/init-config.sh | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 6b65697d9..675ce10c7 100644 --- a/.gitignore +++ b/.gitignore @@ -391,4 +391,5 @@ Sessionx.vim dist/ .env config/config.yaml -config/alertmanager.yml \ No newline at end of file +config/alertmanager.yml +config/prometheus.yml \ No newline at end of file diff --git a/scripts/init-config.sh b/scripts/init-config.sh index 3fcd2fdfd..6b9cedc5e 100755 --- a/scripts/init-config.sh +++ b/scripts/init-config.sh @@ -39,13 +39,18 @@ openim::log::info "Read more configuration information: https://github.com/openi for template in "${!TEMPLATES[@]}"; do if [[ ! -f "${template}" ]]; then - openim::log::error_exit "template file ${template} does not exist..." + openim::log::error_exit "Template file ${template} does not exist..." + exit 1 fi +done +for template in "${!TEMPLATES[@]}"; do IFS=';' read -ra OUTPUT_FILES <<< "${TEMPLATES[$template]}" for output_file in "${OUTPUT_FILES[@]}"; do if [[ -f "${output_file}" ]]; then - read -p "File ${output_file} already exists. Overwrite? (Y/N): " + echo -n "File ${output_file} already exists. Overwrite? (Y/N): " + read -r -n 1 REPLY + echo # 新增一行,以便在用户输入后换行 if [[ $REPLY =~ ^[Yy]$ ]]; then openim::log::info "Overwriting ${output_file}. Previous configuration will be lost." else @@ -55,6 +60,10 @@ for template in "${!TEMPLATES[@]}"; do fi openim::log::info "⌚ Working with template file: ${template} to ${output_file}..." + if [[ ! -f "${OPENIM_ROOT}/scripts/genconfig.sh" ]]; then + openim::log::error "genconfig.sh script not found" + exit 1 + fi "${OPENIM_ROOT}/scripts/genconfig.sh" "${ENV_FILE}" "${template}" > "${output_file}" || { openim::log::error "Error processing template file ${template}" exit 1 @@ -63,4 +72,5 @@ for template in "${!TEMPLATES[@]}"; do done done + openim::log::success "✨ All configuration files have been successfully generated!"