Skip to content

Commit 0deb740

Browse files
committed
Add comments explaining what entrypoint is supposed to do
Also fixes the case where DOCKER_USER=coder
1 parent 53d981a commit 0deb740

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

ci/release-image/entrypoint.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,23 @@ set -eu
55
# Otherwise the current container UID may not exist in the passwd database.
66
eval "$(fixuid -q)"
77

8-
if [ "${DOCKER_USER-}" ]; then
8+
# Rename the `coder` user if a new name is specified by the `DOCKER_USER` environment variable
9+
if [ "${DOCKER_USER-}" != "coder" ]; then
910
USER="$DOCKER_USER"
11+
12+
# If the named user is not already present in the system
1013
if [ -z "$(id -u "$DOCKER_USER" 2>/dev/null)" ]; then
14+
15+
# Add a line adding the new user to sudoers without password prompting
1116
echo "$DOCKER_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd > /dev/null
17+
18+
# Rename the `coder` user and group
1219
# Unfortunately we cannot change $HOME as we cannot move any bind mounts
1320
# nor can we bind mount $HOME into a new home as that requires a privileged container.
1421
sudo usermod --login "$DOCKER_USER" coder
1522
sudo groupmod -n "$DOCKER_USER" coder
1623

24+
# Delete the line granting sudo access for the former username (coder)
1725
sudo sed -i "/coder/d" /etc/sudoers.d/nopasswd
1826
fi
1927
fi

0 commit comments

Comments
 (0)