Files
template/customer/usr/local/bin/entry.sh
T
2025-04-21 17:09:10 +08:00

39 lines
1.2 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/dumb-init /bin/bash
# Ver: 1.7 by Endial Fang (endial@126.com)
#
# 容器入口脚本;当前脚本执行完毕时,使用默认用户执行镜像 CMD 定义的命令(默认为'/usr/local/bin/run.sh'
set -o errexit
set -o nounset
set -o pipefail
. /usr/local/lib/libapplication.sh
info "** Processing entry.sh **"
# 加载应用环境变量
eval "$(app_env)"
# 优先处理'-'开始的版本信息、帮助信息显示命令,如果是该类命令,处理后退出容器
[[ "${1:0:1}" == '-' ]] && set -- "${APP_EXEC:-/bin/bash}" "$@" && print_command_help "$@"
# 处理 root 用户**且**使用默认启动脚本时的初始化
if [[ "$(id -u)" == '0' ]] && [[ "$1" == "run.sh" ]]; then
print_welcome_info
/usr/local/bin/setup.sh
gosu "${APP_USER}" /usr/local/bin/init.sh
# 执行应用启动脚本并替换当前进程
exec gosu "${APP_USER}" "$@"
fi
# 处理 root 用户**且**使用init.sh脚本时的初始化
if [[ "$(id -u)" == '0' ]] && [[ "$1" == "init.sh" ]]; then
/usr/local/bin/setup.sh
exec gosu "${APP_USER}" /usr/local/bin/init.sh
fi
# 处理非以上情形的自定义命令
info "Start container with command: $@"
exec "$@"