Create /run/.toolboxenv in 'toolbox enter' for identification

This is better than setting an environment variable like
TOOLBOX_CONTAINER with 'podman create' because, unlike environment
variables, it can't be unset later by commands like su(1) or sudo(8).
One nice side-effect of doing it inside 'toolbox enter' is that it
will automatically work with older toolbox containers.

A subsequent commit will switch to using the /etc/profile.d/toolbox.sh
start-up script to set the PS1 instead of doing it as part of the
'podman exec' invocation. Having the identification mechanism work with
older toolbox containers is important to avoid breaking the PS1 for
backwards compatibility.

This reverts commit c7b7fa1867

https://github.com/debarshiray/toolbox/pull/148
This commit is contained in:
Debarshi Ray 2019-05-03 19:33:37 +02:00
parent c492907c12
commit f864d67baf
2 changed files with 6 additions and 2 deletions

View file

@ -25,7 +25,7 @@ fi
if [ -f /run/.containerenv ] \
&& ! [ -f "$toolbox_welcome_stub" ] \
&& [ "$TOOLBOX_CONTAINER" != "" ]; then
&& [ -f /run/.toolboxenv ]; then
echo ""
echo "Welcome to the Toolbox; a container where you can install and run"
echo "all your tools."

View file

@ -941,7 +941,6 @@ create()
$prefix_sudo podman create \
$dns_none \
$toolbox_path_set \
--env TOOLBOX_CONTAINER="$toolbox_container" \
--group-add wheel \
--hostname toolbox \
--name $toolbox_container \
@ -1083,6 +1082,11 @@ enter()
exit 1
fi
if ! $prefix_sudo podman exec --user root:root "$toolbox_container" touch /run/.toolboxenv 2>&3; then
echo "$base_toolbox_command: failed to create /run/.toolboxenv in container $toolbox_container" >&2
exit 1
fi
set_environment=$(create_environment_options)
echo "$base_toolbox_command: looking for $SHELL in container $toolbox_container" >&3