Compare commits

..

4 Commits

2 changed files with 12 additions and 14 deletions

View File

@ -1,14 +1,10 @@
#!/bin/bash #!/bin/bash
set -eu set -eu
if [[ -z "${HOME_USER}" ]]; then if [[ -z "${HOME_USER-}" ]]; then
HOME_USER="vscode" HOME_USER="vscode"
fi fi
#addgroup nonroot
#adduser --disabled-password --gecos "" ${HOME_USER}
#echo "${HOME_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# We do this first to ensure sudo works below when renaming the user. # 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. # Otherwise the current container UID may not exist in the passwd database.
eval "$(fixuid -q)" eval "$(fixuid -q)"
@ -37,18 +33,20 @@ if [ "${HOME_USER-}" ]; then
sudo su - ${HOME_USER} -c "echo 'export $line' >> ~/.bashrc" sudo su - ${HOME_USER} -c "echo 'export $line' >> ~/.bashrc"
done done
# Get the PATH of vscode user
VSCODE_PATH=$(sudo -u vscode -i echo $PATH)
# Add the PATH to the .bashrc of HOME_USER
sudo su - ${HOME_USER} -c "echo 'export PATH=$VSCODE_PATH' >> ~/.bashrc"
# Changing the property of the directory /home/${HOME_USER}
sudo chown -R ${HOME_USER}: /home/${HOME_USER}/
# Changing the HOME_USER in the .bashrc file # Changing the HOME_USER in the .bashrc file
sudo su - ${HOME_USER} -c 'sed -i "s|/home/vscode|/home/${HOME_USER}|g" ~/.bashrc' sudo su - ${HOME_USER} -c 'sed -i "s|/home/vscode|/home/${HOME_USER}|g" ~/.bashrc'
# Switch to the user specified by $HOME_USER and start an interactive shell session.
sudo -u $HOME_USER -i sudo -u $HOME_USER -i
# 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
# sudo cd /home/${HOME_USER}
sudo chown -R ${HOME_USER}:${HOME_USER} /home/${HOME_USER}
fi fi
fi fi

View File

@ -1 +1 @@
2.0.31 2.0.36