2020-09-04 06:38:40 +08:00
|
|
|
#!/bin/sh
|
2020-08-26 03:38:12 +08:00
|
|
|
set -eu
|
|
|
|
|
2020-10-24 00:07:08 +08: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)"
|
|
|
|
|
2021-05-11 23:26:38 +08:00
|
|
|
if [ "${DOCKER_USER-}" ]; then
|
2020-09-09 12:07:04 +08:00
|
|
|
USER="$DOCKER_USER"
|
2021-05-11 23:26:38 +08:00
|
|
|
if [ "$DOCKER_USER" != "$(whoami)" ]; then
|
2021-06-29 00:36:55 +08:00
|
|
|
echo "$DOCKER_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd > /dev/null
|
2021-05-11 23:26:38 +08: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
|
|
|
|
sudo groupmod -n "$DOCKER_USER" coder
|
2020-09-04 06:38:40 +08:00
|
|
|
|
2021-05-11 23:26:38 +08:00
|
|
|
sudo sed -i "/coder/d" /etc/sudoers.d/nopasswd
|
|
|
|
fi
|
2020-08-26 03:38:12 +08:00
|
|
|
fi
|
|
|
|
|
2022-05-12 00:49:21 +08:00
|
|
|
# Allow users to have scripts run on container startup to prepare workspace.
|
|
|
|
# https://github.com/coder/code-server/issues/5177
|
|
|
|
chmod u+x ${ENTRYPOINTD}/*.sh
|
|
|
|
sudo chown -R ${USER} ${ENTRYPOINTD}/*
|
2022-05-12 03:34:45 +08:00
|
|
|
for f in "${ENTRYPOINTD}"/*.sh; do
|
2022-05-12 00:49:21 +08:00
|
|
|
echo "Running Entrypoint: ${f}"
|
|
|
|
bash "${f}"
|
|
|
|
done
|
|
|
|
|
2022-02-12 03:44:01 +08:00
|
|
|
exec dumb-init /usr/bin/code-server "$@"
|