Skip to content

Commit

Permalink
init: ensure basic variables are properly sourced during logins
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Di Maio <[email protected]>
  • Loading branch information
89luca89 committed Feb 15, 2024
1 parent 8f6b91d commit bdffd2f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions distrobox-init
Original file line number Diff line number Diff line change
Expand Up @@ -1753,11 +1753,17 @@ touch /run/.toolboxenv
# Ensure we copy only if the dotfile is not already present.
mkdir -p /etc/profile.d
cat << EOF > /etc/profile.d/distrobox_profile.sh
test -z "\$USER" && USER="\$(id -un 2> /dev/null)"
test -z "\$UID" && readonly UID="\$(id -ur 2> /dev/null)"
test -z "\$USER" && export USER="\$(id -un 2> /dev/null)"
test -z "\$UID" && readonly UID="\$(id -ur 2> /dev/null)"
test -z "\$EUID" && readonly EUID="\$(id -u 2> /dev/null)"
export SHELL="\$(getent passwd "\${USER}" | cut -f 7 -d :)"
# Ensure we have these two variables from the host, so that graphical apps
# also work in case we use a login session
test -z \$DISPLAY && export DISPLAY="\$(host-spawn sh -c "echo \\\$DISPLAY")"
test -z \$XAUTHORITY && export XAUTHORITY="\$(host-spawn sh -c "echo \\\$XAUTHORITY")"
test -z \$XAUTHLOCALHOSTNAME && export XAUTHLOCALHOSTNAME="\$(host-spawn sh -c "echo \\\$XAUTHLOCALHOSTNAME")"
# This will ensure a default prompt for a container, this will be remineshent of
# toolbx prompt: https://github.com/containers/toolbox/blob/main/profile.d/toolbox.sh#L47
# this will ensure greater compatibility between the two implementations
Expand Down

0 comments on commit bdffd2f

Please sign in to comment.