mirror of
https://github.com/coder/code-server.git
synced 2024-12-04 23:03:06 +08:00
de38960e27
Co-authored-by: Asher <ash@coder.com>
31 lines
1.0 KiB
Bash
Executable File
31 lines
1.0 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
# 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)"
|
|
|
|
if [ "${DOCKER_USER-}" ]; then
|
|
USER="$DOCKER_USER"
|
|
if [ "$DOCKER_USER" != "$(whoami)" ]; then
|
|
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" coder
|
|
sudo groupmod -n "$DOCKER_USER" coder
|
|
|
|
sudo sed -i "/coder/d" /etc/sudoers.d/nopasswd
|
|
fi
|
|
fi
|
|
|
|
# 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}/*
|
|
for f in "${ENTRYPOINTD}"/*.sh; do
|
|
echo "Running Entrypoint: ${f}"
|
|
bash "${f}"
|
|
done
|
|
|
|
exec dumb-init /usr/bin/code-server "$@"
|