From 014dd33231ca9de6763f301c2ad17dc1f301cf14 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Feb 2026 16:52:46 +0000 Subject: [PATCH] fix: ensure wger sudoers entry persists after sudo package installation The sudoers entry for the wger user was written to /etc/sudoers before the sudo package was installed. When apt-get installs sudo, its default /etc/sudoers conffile may overwrite the entry, causing sudo to fail at runtime. This prevented ha_entrypoint.sh from running as root, so /data/media was never created with correct permissions, resulting in PermissionError when downloading exercise images. Fix: re-add the sudoers entry after the sudo package is installed. Also improve symlink handling in 90-run.sh to avoid self-referencing copies on subsequent container starts. Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com> --- wger/Dockerfile | 4 ++++ wger/rootfs/etc/cont-init.d/90-run.sh | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/wger/Dockerfile b/wger/Dockerfile index b80b98af4..9c8a7d38d 100644 --- a/wger/Dockerfile +++ b/wger/Dockerfile @@ -67,6 +67,10 @@ ENV PACKAGES="sudo nginx" ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_autoapps.sh" "/ha_autoapps.sh" RUN chmod 744 /ha_autoapps.sh && /ha_autoapps.sh "$PACKAGES" || true && rm /ha_autoapps.sh +# Ensure sudoers entry exists after sudo package installation +# (installing sudo may overwrite /etc/sudoers with its default conffile) +RUN echo "wger ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + ################ # 4 Entrypoint # ################ diff --git a/wger/rootfs/etc/cont-init.d/90-run.sh b/wger/rootfs/etc/cont-init.d/90-run.sh index fbea5cf6f..3968f1963 100755 --- a/wger/rootfs/etc/cont-init.d/90-run.sh +++ b/wger/rootfs/etc/cont-init.d/90-run.sh @@ -11,22 +11,22 @@ sed -i "s|/home/wger/db/database.sqlite|/data/database.sqlite|g" /home/wger/src/ ##################### echo "... create directories" mkdir -p /data/static -if [ -d /home/wger/static ]; then +if [ -d /home/wger/static ] && [ ! -L /home/wger/static ]; then if [ -n "$(ls -A /home/wger/static 2> /dev/null)" ]; then cp -rnf /home/wger/static/* /data/static/ fi rm -r /home/wger/static fi -ln -s /data/static /home/wger +ln -sf /data/static /home/wger mkdir -p /data/media -if [ -d /home/wger/media ]; then +if [ -d /home/wger/media ] && [ ! -L /home/wger/media ]; then if [ -n "$(ls -A /home/wger/media 2> /dev/null)" ]; then cp -rnf /home/wger/media/* /data/media/ fi rm -r /home/wger/media fi -ln -s /data/media /home/wger +ln -sf /data/media /home/wger ##################### # Align permissions #