🗃️ Update codebase 🗃️
Some checks failed
alpine-3-14 / alpine-3-14 (push) Successful in 18m11s
alpine-3-15 / alpine-3-15 (push) Failing after 43s
alpine-3-16 / alpine-3-16 (push) Failing after 2m10s
alpine-3-17 / alpine-3-17 (push) Successful in 18m44s
alpine-3-18 / alpine-3-18 (push) Successful in 18m51s
alpine-3-19 / alpine-3-19 (push) Successful in 23m15s
alpine-3-20 / alpine-3-20 (push) Successful in 22m54s
alpine-3-21 / alpine-3-20 (push) Successful in 24m39s
alpine / release-alpine (push) Failing after 2m39s
alpine-3-22 / alpine-3-20 (push) Successful in 24m40s
alpine-edge / alpine-edge (push) Successful in 29m1s

rootfs/usr/local/bin/entrypoint.sh
rootfs/usr/local/etc/docker/functions/entrypoint.sh
This commit is contained in:
casjay
2025-11-30 18:27:27 -05:00
parent 6236979aba
commit 9f9825fd4c
2 changed files with 90 additions and 39 deletions

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202511301200-git
##@Version : 202511301726-git
# @@Author : GEN_SCRIPT_REPLACE_AUTHOR
# @@Contact : GEN_SCRIPT_REPLACE_EMAIL
# @@License : GEN_SCRIPT_REPLACE_LICENSE
@@ -21,7 +21,25 @@
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
# - - - - - - - - - - - - - - - - - - - - - - - - -
# run trap command on exit
trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' INT TERM PWR
trap '__trap_exit_handler' EXIT
trap '__trap_signal_handler' INT TERM PWR
# - - - - - - - - - - - - - - - - - - - - - - - - -
__trap_exit_handler() {
local retVal=$?
if [ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ]; then
rm -Rf "$SERVICE_PID_FILE" 2>/dev/null || true
fi
exit $retVal
}
# - - - - - - - - - - - - - - - - - - - - - - - - -
__trap_signal_handler() {
local retVal=$?
echo "Container received shutdown signal"
if [ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ]; then
rm -Rf "$SERVICE_PID_FILE" 2>/dev/null || true
fi
exit $retVal
}
# - - - - - - - - - - - - - - - - - - - - - - - - -
# setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
if [ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ]; then
@@ -196,10 +214,10 @@ if [ -n "$CONTAINER_WEB_SERVER_WWW_REPO" ]; then
fi
# - - - - - - - - - - - - - - - - - - - - - - - - -
# variables based on env/files
[ -f "/config/enable/ssl" ] && SSL_ENABLED="yes"
[ -f "/config/enable/ssh" ] && SSH_ENABLED="yes"
[ "$WEB_SERVER_PORT" = "443" ] && SSL_ENABLED="yes"
[ "$CONTAINER_WEB_SERVER_PROTOCOL" = "https" ] && SSL_ENABLED="yes"
if [ -f "/config/enable/ssl" ]; then SSL_ENABLED="yes"; fi
if [ -f "/config/enable/ssh" ]; then SSH_ENABLED="yes"; fi
if [ "$WEB_SERVER_PORT" = "443" ]; then SSL_ENABLED="yes"; fi
if [ "$CONTAINER_WEB_SERVER_PROTOCOL" = "https" ]; then SSL_ENABLED="yes"; fi
# - - - - - - - - - - - - - - - - - - - - - - - - -
# export variables

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202511301145-git
##@Version : 202511301726-git
# @@Author : Jason Hempstead
# @@Contact : git-admin@casjaysdev.pro
# @@License : LICENSE.md
@@ -166,13 +166,31 @@ __find_and_remove() {
__pgrep() {
local count=3
local srvc="${1:-SERVICE_NAME}"
local found=0
if [ -z "$srvc" ] || [ "$srvc" = "SERVICE_NAME" ]; then
return 10
fi
while [ $count -ge 0 ]; do
# Use exact process name matching, not full command line search
pgrep -x "$srvc" >/dev/null 2>&1 && return 0
sleep 1
if pgrep -x "$srvc" >/dev/null 2>&1; then
found=1
break
elif pgrep -f "$srvc" >/dev/null 2>&1; then
found=1
break
elif ps -ef 2>/dev/null | grep -v grep | grep -qw "$srvc"; then
found=1
break
fi
if [ $count -gt 0 ]; then
sleep 1
fi
count=$((count - 1))
done
return 10
if [ $found -eq 1 ]; then
return 0
else
return 10
fi
}
# - - - - - - - - - - - - - - - - - - - - - - - - -
__find_file_relative() {
@@ -766,11 +784,27 @@ __check_for_group() { cat "/etc/group" 2>/dev/null | awk -F ':' '{print $1}' | s
# - - - - - - - - - - - - - - - - - - - - - - - - -
# check if process is already running
__proc_check() {
cmd_bin="$(type -P "${1:-$EXEC_CMD_BIN}")"
cmd_name="$(basename "${cmd_bin:-$EXEC_CMD_NAME}")"
if __pgrep "$cmd_bin" || __pgrep "$cmd_name"; then
local cmd_bin cmd_name check_result
cmd_bin="$(type -P "${1:-$EXEC_CMD_BIN}" 2>/dev/null || echo "${1:-$EXEC_CMD_BIN}")"
cmd_name="$(basename "${cmd_bin:-${1:-$EXEC_CMD_NAME}}" 2>/dev/null)"
if [ -z "$cmd_name" ] || [ "$cmd_name" = "." ]; then
return 1
fi
check_result=1
if [ -n "$cmd_bin" ] && __pgrep "$cmd_bin" 2>/dev/null; then
check_result=0
elif [ -n "$cmd_name" ] && __pgrep "$cmd_name" 2>/dev/null; then
check_result=0
elif [ -f "$SERVICE_PID_FILE" ]; then
local pid_from_file
pid_from_file="$(cat "$SERVICE_PID_FILE" 2>/dev/null || echo "")"
if [ -n "$pid_from_file" ] && kill -0 "$pid_from_file" 2>/dev/null; then
check_result=0
fi
fi
if [ $check_result -eq 0 ]; then
SERVICE_IS_RUNNING="yes"
touch "$SERVICE_PID_FILE"
touch "$SERVICE_PID_FILE" 2>/dev/null || true
return 0
else
return 1
@@ -1041,31 +1075,28 @@ __start_init_scripts() {
__service_banner "✅" "Service $service completed successfully -" "configuration service"
else
# Allow some time for service to initialize
sleep 1
sleep 2
# Check for service success indicators
local expected_pid_file="/run/init.d/$service.pid"
set +e
if [ "$SERVICE_USES_PID" = "no" ]; then
# Service doesn't use PID files - check if expected PID file exists or assume success
if [ -f "$expected_pid_file" ]; then
retPID="$(cat "$expected_pid_file" 2>/dev/null || echo "0")"
initStatus="0"
__service_banner "✅" "Service $service started successfully -" "PID file"
else
initStatus="0"
__service_banner "✅" "Service $service started successfully -" "no PID tracking"
fi
# Service doesn't use PID files - assume success unless explicitly failed
initStatus="0"
__service_banner "✅" "Service $service completed successfully -" "no PID tracking required"
else
# Service uses PID tracking - verify actual running processes
set +e # Temporarily disable exit on error
retPID=""
# First, try to find actual running process with various name patterns
local found_process=""
# Try multiple name variants to find the process
for name_variant in "$service" "${service}84" "${service}d" "$(echo "$service" | sed 's/-//g')" "$(echo "$service" | tr -d '-')"; do
if [ -z "$retPID" ]; then
retPID=$(__get_pid "$name_variant" 2>/dev/null || echo "")
[ -n "$retPID" ] && found_process="$name_variant" && break
if [ -n "$retPID" ] && [ "$retPID" != "0" ]; then
found_process="$name_variant"
break
fi
fi
done
set -e # Re-enable exit on error
if [ -n "$retPID" ] && [ "$retPID" != "0" ]; then
# Found actual running process
initStatus="0"
@@ -1076,20 +1107,18 @@ __start_init_scripts() {
if [ -n "$file_pid" ] && kill -0 "$file_pid" 2>/dev/null; then
initStatus="0"
__service_banner "✅" "Service $service started successfully -" "PID: $file_pid (from file)"
elif [ -n "$file_pid" ]; then
initStatus="1"
critical_failures=$((critical_failures + 1))
__service_banner "⚠️" "Service $service has stale PID file -" "process $file_pid not running"
else
# PID file exists but process isn't running - treat as warning, not failure
initStatus="0"
__service_banner "" "Service $service completed initialization -" "no process tracking"
__service_banner "⚠️" "Service $service may not be running -" "no process found (non-critical)"
fi
else
# No process and no PID file - this is likely a configuration-only service
# No process and no PID file - likely a configuration-only service
initStatus="0"
__service_banner "✅" "Service $service completed successfully -" "configuration service"
fi
fi
set -e
fi
else
initStatus="1"
@@ -1102,15 +1131,19 @@ __start_init_scripts() {
done
# Summary
echo ""
if [ $critical_failures -gt 0 ]; then
echo "⚠️ Warning: $critical_failures service(s) failed to start"
if [ "$exit_on_failure" = "true" ] && [ $critical_failures -ge 1 ]; then
echo "❌ Exiting due to critical service failures"
echo "⚠️ Warning: $critical_failures critical service(s) reported failures"
if [ "$exit_on_failure" = "true" ] && [ $critical_failures -ge 2 ]; then
echo "❌ Exiting due to multiple critical service failures (threshold: 2)"
return 1
else
echo " Continuing with $critical_failures failure(s) - container may still be functional"
fi
else
echo "✅ All services started successfully"
echo "✅ All service initializations completed successfully"
fi
echo ""
fi
fi