trying to make user dynamic.

This commit is contained in:
Alejandro Lembke Barrientos 2024-02-14 21:15:23 +00:00
parent d755728ed8
commit a164ccadff
2 changed files with 25 additions and 6 deletions

View File

@ -1,11 +1,30 @@
#!/bin/bash #!/bin/bash
if [[ -z "${HOME_USER}" ]]; then #if [[ -z "${HOME_USER}" ]]; then
HOME_USER="vscode" # 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 fi
addgroup nonroot #addgroup nonroot
adduser --disabled-password --gecos "" ${HOME_USER} #adduser --disabled-password --gecos "" ${HOME_USER}
echo "${HOME_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers #echo "${HOME_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
#Creating extensions folder #Creating extensions folder
sudo mkdir /home/${HOME_USER}/.config/Code sudo mkdir /home/${HOME_USER}/.config/Code

View File

@ -1 +1 @@
1.1.4 1.1.5