From 2430a4f0123ba5de2d4fe767e49dfeeeef1fbcfa Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Thu, 30 Nov 2023 15:12:16 +0100 Subject: [PATCH] Docker: Only create user/group when don't already exist --- docker-entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 7a730ea..2a47929 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -16,8 +16,8 @@ if [ "$PUID" == "0" ] || [ "$UID" != "0" ]; then deno run -A --unstable /silverbullet.js $@ else # Create silverbullet user and group ad-hoc mapped to PUID and PGID - groupadd -g $PGID silverbullet - useradd -M -u $PUID -g $PGID silverbullet + getent group silverbullet || groupadd -g $PGID silverbullet + id -u silverbullet &> /dev/null || useradd -M -u $PUID -g $PGID silverbullet # And make sure /deno-dir (Deno cache) is accessible chown -R $PUID:$PGID /deno-dir # And run via su as the newly mapped 'silverbullet' user