🐛 Fix entrypoint hijacking any passed command into daemon mode 🐛

- rootfs/usr/local/bin/entrypoint.sh: the "start all services" gate
  (`if [ "$START_SERVICES" = "yes" ] || [ -z "$1" ]`) always evaluated true
  on a first-run container regardless of $1, because START_SERVICES is
  force-set to "yes" whenever no PID file exists yet. This meant any
  command passed to `docker run` — `exec ...`, `sh -c ...`, `shell`, or an
  arbitrary program — was swallowed into the service-start+monitor branch
  before ever reaching the `case "$1"` statement that already handles
  those subcommands correctly, causing the container to hang as a
  persistent daemon instead of running the given command. Changed the
  condition to `if [ -z "$1" ]` so the daemon branch only fires when no
  command was given at all, matching the default case's own `$# -eq 0`
  check further down. Verified `bash -n` passes; script-lint confirms the
  edited block is clean (3 unrelated pre-existing findings logged to
  TODO.AI.md).
- TODO.AI.md: logged 3 pre-existing script-lint findings in this same
  file (two bare `exit` statements, one missing VERSION= stamp) found
  incidentally while linting the fix above — out of scope for this
  change since this file is regenerated wholesale from the shared
  upstream template.
This commit is contained in:
2026-07-27 15:52:22 -04:00
parent c0cf2117a9
commit 6de223133c
2 changed files with 22 additions and 2 deletions
+5 -2
View File
@@ -481,8 +481,11 @@ SKIP_SERVICE_START="no"
[ "$1" = "init" ] && SKIP_SERVICE_START="yes" && CONTAINER_INIT="yes"
[ "$2" = "init" ] && SKIP_SERVICE_START="yes" && CONTAINER_INIT="yes"
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Start all services if no pidfile and not skipping
if [ "$START_SERVICES" = "yes" ] || [ -z "$1" ]; then
# Start all services only when no command was given at all — an explicit
# command (exec, shell, tail, or an arbitrary program) must reach the case
# statement below instead of being swallowed into daemon/monitor mode, even
# on a first run where START_SERVICES is force-set to "yes"
if [ -z "$1" ]; then
if [ "$SKIP_SERVICE_START" = "no" ]; then
[ "$1" = "start" ] && shift 1
[ "$1" = "all" ] && shift 1