From 0b40f9773e09ff1cb098e6e2bdfa01e247c7b0f7 Mon Sep 17 00:00:00 2001 From: hakong Date: Sat, 11 May 2024 13:16:54 +0000 Subject: [PATCH] fix: improve entrypoint to conditionally chown directories This fix makes the entrypoint only attempt to chown if the directory is not writable to the 'urbackup' user. If the directory is not writable for root (example: rootless container, backup dir on host is NFS mounted and bind mounted into container) the chown will fail, preventing the container from running. --- entrypoint.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 7279b9c..c8fe67f 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -17,6 +17,9 @@ then else groupmod -g 101 -o urbackup fi -chown urbackup:urbackup /backups -chown urbackup:urbackup /var/urbackup + +# Check if /backups and /var/urbackup is writable by urbackup user and conditionally chown +su -s /bin/bash -c "test -w /backups" urbackup || chown urbackup:urbackup /backups +su -s /bin/bash -c "test -w /var/urbackup" urbackup || chown urbackup:urbackup /var/urbackup + exec urbackupsrv "$@"