From a164ccadff93dd75ecefe8dda5586f30f56dae14 Mon Sep 17 00:00:00 2001 From: Alejandro Lembke Barrientos Date: Wed, 14 Feb 2024 21:15:23 +0000 Subject: [PATCH] trying to make user dynamic. --- entrypoint.sh | 29 ++++++++++++++++++++++++----- version.txt | 2 +- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 993e07b..a67f84a 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,11 +1,30 @@ #!/bin/bash -if [[ -z "${HOME_USER}" ]]; then - HOME_USER="vscode" +#if [[ -z "${HOME_USER}" ]]; then +# HOME_USER="vscode" +#fi + +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 [ "${HOME_USER-}" ]; then + USER="$HOME_USER" + if [ "$HOME_USER" != "$(whoami)" ]; then + echo "$HOME_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 "$HOME_USER" vscode + sudo groupmod -n "$HOME_USER" vscode + + sudo sed -i "/vscode/d" /etc/sudoers.d/nopasswd + fi fi -addgroup nonroot -adduser --disabled-password --gecos "" ${HOME_USER} -echo "${HOME_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers +#addgroup nonroot +#adduser --disabled-password --gecos "" ${HOME_USER} +#echo "${HOME_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers #Creating extensions folder sudo mkdir /home/${HOME_USER}/.config/Code diff --git a/version.txt b/version.txt index 1b87bcd..314c3d7 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.1.4 \ No newline at end of file +1.1.5 \ No newline at end of file