Files
postgresql/customer/usr/local/bin/entry.sh
T

38 lines
1.4 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.6 by Endial Fang (endial@126.com)
#
# 容器入口脚本;当前脚本执行完毕时,使用默认用户执行镜像 CMD 定义的命令(默认为'/usr/local/bin/run.sh'
# 设置 shell 执行参数,可使用'-'(打开)'+'(关闭)控制。常用:
# -e: 命令执行错误则报错(errexit); -u: 变量未定义则报错(nounset); -x: 打印实际待执行的命令行; -o pipefail: 设置管道中命令遇到失败则报错
set -euo pipefail
. /colovu/lib/libcommon.sh # 加载通用函数库
. /usr/local/bin/environment.sh # 设置环境变量
LOG_I "** Processing entry.sh **"
# 优先处理'-'开始的版本信息、帮助信息显示命令,如果是该类命令,处理后退出容器
[[ "${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
# 处理非以上情形的自定义命令
LOG_I "Start container with command: $@"
exec "$@"