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

27 lines
684 B
Bash
Executable File

#!/bin/bash
# Ver: 1.5 by Endial Fang (endial@126.com)
#
# 应用初始化脚本;当前脚本使用‘gosu ${APP_USER}’方式切换至用户空间执行
set -o errexit
set -o nounset
set -o pipefail
. /usr/local/lib/libapplication.sh
info "** Processing init.sh **"
# 加载应用环境变量
eval "$(app_env)"
# 检测环境变量是否有效
app_env_validate
# 注册脚本退出时执行的应用停止操作
trap "app_stop_server" EXIT
# 确认用户为`root`时,守护进城执行操作的用户存在
is_root && ensure_user_exists "$APP_USER" --group "$APP_GROUP"
# 执行应用初始化操作
app_default_init
# 执行用户自定义初始化脚本
app_custom_init