2020-09-04 05:38:40 +07:00
|
|
|
#!/bin/sh
|
2020-08-26 02:38:12 +07:00
|
|
|
set -eu
|
|
|
|
|
2020-10-23 23:07:08 +07:00
|
|
|
# We do this first to ensure sudo works below when renaming the user.
|
|
|
|
# Otherwise the current container UID may not exist in the passwd database.
|
|
|
|
eval "$(fixuid -q)"
|
|
|
|
|
2020-12-15 01:57:36 +07:00
|
|
|
if [ "${DOCKER_USER-}" ] && [ "$DOCKER_USER" != "$USER" ]; then
|
2021-03-16 05:36:31 +07:00
|
|
|
echo "$DOCKER_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd >/dev/null
|
2020-09-04 05:38:40 +07:00
|
|
|
# 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" coder
|
2020-08-26 02:38:12 +07:00
|
|
|
sudo groupmod -n "$DOCKER_USER" coder
|
|
|
|
|
2020-09-09 11:07:04 +07:00
|
|
|
USER="$DOCKER_USER"
|
2020-09-04 05:38:40 +07:00
|
|
|
|
2020-08-26 02:38:12 +07:00
|
|
|
sudo sed -i "/coder/d" /etc/sudoers.d/nopasswd
|
|
|
|
fi
|
|
|
|
|
2020-10-23 23:07:08 +07:00
|
|
|
dumb-init /usr/bin/code-server "$@"
|