summaryrefslogtreecommitdiff
path: root/docker/entrypoint.sh
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-01-11 09:15:33 +0100
committerChristian Poessinger <christian@poessinger.com>2019-01-11 09:15:33 +0100
commit4c42851c53a5884b36a1a7850b7b663e4faf82c9 (patch)
treeeb09f7449662e6e49aedf58bff94ebca22c8db07 /docker/entrypoint.sh
parent4004496e89d2a27cfb4cc3a87253dd9dac54e160 (diff)
downloadvyos-build-4c42851c53a5884b36a1a7850b7b663e4faf82c9.tar.gz
vyos-build-4c42851c53a5884b36a1a7850b7b663e4faf82c9.zip
Docker: create UNIX group on demand
Diffstat (limited to 'docker/entrypoint.sh')
-rwxr-xr-xdocker/entrypoint.sh9
1 files changed, 7 insertions, 2 deletions
diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh
index 00e1e139..8db41103 100755
--- a/docker/entrypoint.sh
+++ b/docker/entrypoint.sh
@@ -18,8 +18,13 @@ fi
# Notify user about selected UID/GID
echo "Current UID/GID: $NEW_UID/$NEW_GID"
-useradd --shell /bin/bash -u $NEW_UID -g $NEW_GID -o -m $USER_NAME
-usermod -aG sudo $USER_NAME
+# Create UNIX group on the fly if it does not exist
+if ! grep -q $NEW_GID /etc/group; then
+ groupadd --gid $NEW_GID $USER_NAME
+fi
+
+useradd --shell /bin/bash --uid $NEW_UID --gid $NEW_GID --non-unique --create-home $USER_NAME
+usermod --append --groups sudo $USER_NAME
sudo chown $NEW_UID:$NEW_GID /home/$USER_NAME
export HOME=/home/$USER_NAME