From 0c2334502dad14c3edefa14a5931508c7ff3db28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sun, 10 Mar 2024 23:53:11 +0100 Subject: [PATCH] do not recreate docker runner group and user --- docker/scripts/entry-point-dev.sh | 12 ++++++++---- docker/scripts/entry-point.sh | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/docker/scripts/entry-point-dev.sh b/docker/scripts/entry-point-dev.sh index 2b1d6a5..de9f63b 100755 --- a/docker/scripts/entry-point-dev.sh +++ b/docker/scripts/entry-point-dev.sh @@ -16,10 +16,14 @@ echo "Migrating DB..." ./rvr db:migrate echo "Set runner user based on owner of .env..." -USER_UID=$(stat -c "%u" .env) -USER_GID=$(stat -c "%g" .env) -groupadd --gid $USER_GID rvr -useradd --uid $USER_UID --gid $USER_GID rvr +if ! getent group rvr; then + USER_GID=$(stat -c "%g" .env) + groupadd --gid $USER_GID rvr +fi +if ! id -u rvr; then + USER_UID=$(stat -c "%u" .env) + useradd --uid $USER_UID --gid $USER_GID rvr +fi sed -i -e "s/^user = .*$/user = rvr/g" -e "s/^group = .*$/group = rvr/g" /etc/php/8.1/fpm/pool.d/www.conf set +e diff --git a/docker/scripts/entry-point.sh b/docker/scripts/entry-point.sh index 62ef125..db207e5 100755 --- a/docker/scripts/entry-point.sh +++ b/docker/scripts/entry-point.sh @@ -9,10 +9,14 @@ echo "Installing crontab..." /usr/bin/crontab docker/scripts/cron echo "Set runner user based on owner of .env..." -USER_UID=$(stat -c "%u" .env) -USER_GID=$(stat -c "%g" .env) -groupadd --gid $USER_GID rvr -useradd --uid $USER_UID --gid $USER_GID rvr +if ! getent group rvr; then + USER_GID=$(stat -c "%g" .env) + groupadd --gid $USER_GID rvr +fi +if ! id -u rvr; then + USER_UID=$(stat -c "%u" .env) + useradd --uid $USER_UID --gid $USER_GID rvr +fi chown -R rvr:rvr cache sed -i -e "s/^user = .*$/user = rvr/g" -e "s/^group = .*$/group = rvr/g" /etc/php/8.1/fpm/pool.d/www.conf -- 2.45.2