From 6318dc754e13e98254bd839087b0a291664d3444 Mon Sep 17 00:00:00 2001 From: casjay Date: Sun, 14 Jul 2024 18:37:48 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Committing=20everything?= =?UTF-8?q?=20that=20changed=20=F0=9F=97=83=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rootfs/usr/local/etc/docker/functions/entrypoint.sh rootfs/usr/local/etc/docker/init.d/00-tftpd.sh rootfs/usr/local/etc/docker/init.d/zz-nginx.sh --- .../local/etc/docker/functions/entrypoint.sh | 3 +-- .../usr/local/etc/docker/init.d/00-tftpd.sh | 2 +- .../usr/local/etc/docker/init.d/zz-nginx.sh | 24 +++++++++---------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/rootfs/usr/local/etc/docker/functions/entrypoint.sh b/rootfs/usr/local/etc/docker/functions/entrypoint.sh index fc41999..d6f0d15 100644 --- a/rootfs/usr/local/etc/docker/functions/entrypoint.sh +++ b/rootfs/usr/local/etc/docker/functions/entrypoint.sh @@ -501,10 +501,9 @@ __start_init_scripts() { for init in "$init_dir"/*.sh; do if [ -f "$init" ]; then name="$(basename "$init")" - sleep 10 && (exec "$init" &) && sleep 10 || false + sleep 10 && sh -c "$init" && sleep 20 || false initStatus=$(($? + initStatus)) echo "" - sleep 20 fi done fi diff --git a/rootfs/usr/local/etc/docker/init.d/00-tftpd.sh b/rootfs/usr/local/etc/docker/init.d/00-tftpd.sh index f19001c..304bbe1 100755 --- a/rootfs/usr/local/etc/docker/init.d/00-tftpd.sh +++ b/rootfs/usr/local/etc/docker/init.d/00-tftpd.sh @@ -364,7 +364,7 @@ __run_start_script() { export cmd_exec="$cmd $args" message="Starting service: $name $args $message" fi - [ -f "$START_SCRIPT" ] && printf '#!/usr/bin/env sh\n# %s\n%s\n' "$message" "$cmd_exec" >"$START_SCRIPT" + [ -f "$START_SCRIPT" ] && printf '#!/usr/bin/env sh\n# %s\n%s\n' "$message" "$cmd_exec &" >"$START_SCRIPT" [ -f "$START_SCRIPT" ] && chmod 755 -Rf "$START_SCRIPT" [ -n "$su_exec" ] && echo "using $su_exec" echo "$message" diff --git a/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh b/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh index db817c5..3e15b1b 100644 --- a/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh +++ b/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh @@ -412,7 +412,7 @@ __run_start_script() { local sysname="${SERVER_NAME:-${FULL_DOMAIN_NAME:-$HOSTNAME}}" # set hostname [ -f "$CONF_DIR/$SERVICE_NAME.exec_cmd.sh" ] && . "$CONF_DIR/$SERVICE_NAME.exec_cmd.sh" if [ -z "$cmd" ]; then - __post_execute 2>"/dev/stderr" |& tee -p -a "$LOG_DIR/init.txt" &>/dev/null + __post_execute 2>"/dev/stderr" | tee -p -a "$LOG_DIR/init.txt" >/dev/null retVal=$? echo "Initializing $SCRIPT_NAME has completed" exit $retVal @@ -420,7 +420,7 @@ __run_start_script() { # ensure the command exists if [ ! -x "$cmd" ]; then echo "$name is not a valid executable" - exit 2 + return 2 fi # set working directories [ -z "$home" ] && home="${workdir:-/tmp/docker}" @@ -435,7 +435,7 @@ __run_start_script() { # check and exit if already running if __proc_check "$name" || __proc_check "$cmd"; then echo "$name is already running" >&2 - exit 0 + return 0 else # cd to dir # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -453,22 +453,22 @@ __run_start_script() { export cmd_exec="$cmd $args" message="Starting service: $name $args $message" fi - [ -f "$START_SCRIPT" ] || printf '#!/usr/bin/env sh -# %s -%s -' "$message" "$cmd_exec" >"$START_SCRIPT" - [ -x "$START_SCRIPT" ] || chmod 755 -Rf "$START_SCRIPT" + [ -f "$START_SCRIPT" ] && printf '#!/usr/bin/env sh\n# %s\n%s\n' "$message" "$cmd_exec &" >"$START_SCRIPT" + [ -f "$START_SCRIPT" ] && chmod 755 -Rf "$START_SCRIPT" [ -n "$su_exec" ] && echo "using $su_exec" echo "$message" su_cmd touch "$SERVICE_PID_FILE" __post_execute |& tee -p -a "$LOG_DIR/init.txt" &>/dev/null & if [ "$RESET_ENV" = "yes" ]; then - su_cmd env -i HOME="$home" LC_CTYPE="$lc_type" PATH="$path" HOSTNAME="$sysname" USER="${SERVICE_USER:-$RUNAS_USER}" $extra_env sh -c "$START_SCRIPT" || - eval env -i HOME="$home" LC_CTYPE="$lc_type" PATH="$path" HOSTNAME="$sysname" USER="${SERVICE_USER:-$RUNAS_USER}" $extra_env sh -c "$START_SCRIPT" || - return 10 + env_command="$(eval echo "env -i HOME=\"$home\" LC_CTYPE=\"$lc_type\" PATH=\"$path\" HOSTNAME=\"$sysname\" USER=\"${SERVICE_USER:-$RUNAS_USER}\" $extra_env")" + echo "$env_command" + su_cmd $env_command sh -c "$START_SCRIPT" || eval $env_command sh -c "$START_SCRIPT" + runExitCode=$? else - su_cmd "$START_SCRIPT" || eval "$START_SCRIPT" || return 10 + su_cmd "$START_SCRIPT" || eval "$START_SCRIPT" + runExitCode=$? fi + return $runExitCode fi fi }