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>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-25 16:52:46 +00:00
parent c44737b118
commit 014dd33231
2 changed files with 8 additions and 4 deletions

View File

@@ -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 #
################

View File

@@ -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 #