Files
endial 694480f2ae
ci/woodpecker/push/woodpecker Pipeline was successful
refactor: replace legacy LOG_* functions with standardized logging
- Replace LOG_D calls with debug() function
- Replace LOG_I calls with info() function
- Maintain echo() in build-time overrides script
- Fix 'command not found' errors for LOG_I function
- Ensure consistent logging format across all runtime scripts

Modified files:
- customer/usr/local/bin/common.sh: 4 LOG_D -> debug calls
- customer/usr/local/bin/setup.sh: 3 LOG_I -> info, 1 LOG_D -> debug calls
- customer/usr/local/bin/run.sh: 2 LOG_I -> info calls
- customer/usr/local/bin/entry.sh: already using info() calls (no changes needed)
2026-01-23 16:00:34 +08:00

43 lines
1.5 KiB
Bash

#!/bin/bash
# Ver: 1.3 by Endial Fang (endial@126.com)
#
# 应用通用业务处理函数
. /usr/local/lib/libcommon.sh # 通用函数库
. /usr/local/lib/libfile.sh
. /usr/local/lib/libfs.sh
. /usr/local/lib/liblog.sh
. /usr/local/lib/libos.sh
. /usr/local/lib/libservice.sh
. /usr/local/lib/libvalidations.sh
# 检测应用相应的配置文件是否存在,如果不存在,则从默认配置文件目录拷贝一份
# 默认配置文件路径:/etc/${APP_NAME}
# 目标配置文件路径:/srv/conf/${APP_NAME}
# 参数:
# $1 - 目标路径
# $2 - 源路径
# $* - 基础路径下的文件及目录列表,以" "分割
# 例子:
# ensure_config_file_exist /etc/${APP_NAME} conf.d server.conf
app_ensure_config_file_exist() {
local -r dist_path="${1:?dist paths is missing}"
local -r base_path="${2:?source paths is missing}"
local f=""
shift 2
debug "List to check in ${base_path}: $@"
while [ "$#" -gt 0 ]; do
f="${1}"
debug " Process \"${f}\""
if [ -d "${base_path}/${f}" ]; then
[[ ! -d "${dist_path}/${f}" ]] && debug " Create directory: ${dist_path}/${f}" && mkdir -p "${dist_path}/${f}"
[[ ! -z $(ls -A "${base_path}/${f}") ]] && app_ensure_config_file_exist "${dist_path}/${f}" "${base_path}/${f}" $(ls -A "${base_path}/${f}")
else
[[ ! -e "${dist_path}/${f}" ]] && debug " Copy: ${base_path}/${f} to ${dist_path}" && cp "${base_path}/${f}" "${dist_path}"
fi
shift
done
}