Refactor entrypoint.sh for clarity and functionality

Updated comments for clarity and improved Python path handling.
This commit is contained in:
clsferguson 2025-09-09 22:34:11 -06:00 committed by GitHub
parent 8538d95ce5
commit c77021a965
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,9 +9,9 @@ PGID=${PGID:-1000}
BASE_DIR=/app/ComfyUI
CUSTOM_NODES_DIR="$BASE_DIR/custom_nodes"
# If running as root, map to requested UID/GID, fix ownership, and make system install targets writable
# If running as root, map to requested UID/GID, fix ownership, and make Python install targets writable
if [ "$(id -u)" = "0" ]; then
# Map group
# Map group to PGID if it already exists, otherwise remap the named group
if getent group "${PGID}" >/dev/null; then
EXISTING_GRP="$(getent group "${PGID}" | cut -d: -f1)"
usermod -g "${EXISTING_GRP}" "${APP_USER}" || true
@ -20,7 +20,7 @@ if [ "$(id -u)" = "0" ]; then
groupmod -o -g "${PGID}" "${APP_GROUP}" || true
fi
# Map user
# Map user to PUID
usermod -o -u "${PUID}" "${APP_USER}" || true
# Ensure home and app dir exist and are owned
@ -29,19 +29,24 @@ if [ "$(id -u)" = "0" ]; then
[ -e "$d" ] && chown -R "${APP_USER}:${APP_GROUP}" "$d" || true
done
# Make Python "system" install targets writable for the runtime user
# This covers packages (purelib/platlib), console scripts (scripts), and headers (include/platinclude)
# Discard anything not under /usr/local to avoid over-broad changes.
# Make Python system install targets writable for the runtime user
# Includes: site-packages (purelib/platlib), scripts, headers, data, and data/share(+man1)
# Discards anything not under /usr/local to avoid over-broad changes.
readarray -t PY_PATHS < <(python - <<'PY'
import sysconfig
keys = ("purelib","platlib","scripts","include","platinclude")
import sysconfig, os
keys = ("purelib","platlib","scripts","include","platinclude","data")
p = sysconfig.get_paths()
for k in keys:
v = p.get(k)
if v:
print(v)
d = p.get("data")
if d:
# Wheel .data/data payloads commonly land under {data}/share, including manpages like ttx.1
print(os.path.join(d, "share"))
print(os.path.join(d, "share", "man", "man1"))
PY
)
)
for d in "${PY_PATHS[@]}"; do
case "$d" in
/usr/local/*)