Hi Damion- have been using this for a while but kept hitting an issue- using VSCode remotely, my terminal always opened in my home directory. I figured that’s happening because the command in enter namespace is using bash --login
. I tried some workaround, but not knowing this stuff that well, am not sure if I broke something else that I just haven’t noticed yet-
if [ -n "$SYSTEMD_PID" ] && [ "$SYSTEMD_PID" != "1" ]; then
if [ -n "$1" ] && [ "$1" != "bash --login" ] && [ "$1" != "/bin/bash --login" ]; then
exec /usr/bin/nsenter -t "$SYSTEMD_PID" -a /usr/bin/sudo -H -u "$SUDO_USER" /bin/bash -c 'set -a; source "$HOME/.systemd-env"; set +a; exec bash -c '"$(printf "%q" "$@")"
elif [ -n "$1" ] && [ "$1" == "bash --login" ] || [ "$1" == "/bin/bash --login" ]; then
exec /usr/bin/nsenter -t "$SYSTEMD_PID" -a /bin/login -p -f "$SUDO_USER" $(/bin/cat "$HOME/.systemd-env" | grep -v "^PATH=")
else
exec /usr/bin/nsenter -t "$SYSTEMD_PID" --preserve-credentials -a /bin/bash -c 'set -a; source $HOME/.systemd-env; set +a;'"cd ${PWD}; exec bash"
fi
fi
Trying to skip the login if we are already in the namespace and --login wasn’t specified.