From 89ea5bec647941d148093ffa99ed18c856ead404 Mon Sep 17 00:00:00 2001 From: mol Date: Sat, 24 Feb 2024 13:47:20 +0000 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20entrypoint.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entrypoint.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index c8684b7..6ee7445 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,14 +10,15 @@ set -eu # 初始化 if [ "${DOCKER_USER-}" ]; then USER="$DOCKER_USER" - if [ "$DOCKER_USER" != "$(id -un 1000)" ]; then + USER_HOME="$(id -un 1000)" + if [ "$DOCKER_USER" != "$USER_HOME" ]; then # 无密码sudo echo "$DOCKER_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd > /dev/null # Unfortunately we cannot change $HOME as we cannot move any bind mounts # nor can we bind mount $HOME into a new home as that requires a privileged container. - sudo usermod --login "$DOCKER_USER" "$(id -un 1000)" - sudo groupmod -n "$DOCKER_USER" "$(id -un 1000)" + sudo usermod --login "$DOCKER_USER" "$USER_HOME" + sudo groupmod -n "$DOCKER_USER" "$USER_HOME" sudo chown -R "$DOCKER_USER":999 /home/coder