File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,15 +5,23 @@ set -eu
55# Otherwise the current container UID may not exist in the passwd database.
66eval " $( 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
1927fi
You can’t perform that action at this time.
0 commit comments