Automatically run a script when entering a toolbox container

Hi all ! (new registered user here)

I’ve been toying with Fedora Silverblue since two days, and I must say this is the most thrilling new thing since a lot of time.

I’m now trying to adapt my old workflows to operate with Silverblue.

At the moment I’m stuck with running a script when I’m entering a specific toolbox. For instance, in my python-dev toolbox container, I would like to automatically load virtualenvwrapper related scripts.

On my old non-silverblue installation, it was done in my .bashrc file because virtualenvwrapper was installed system wide. But putting it in the .bashrc shared with multiple containers and the host system seems wrong to me.

How would you do it ?

Thanks :slight_smile:

Would something like this in .bashrc work?

# If inside toolbox do something
if [[ "$(hostname)" = "toolbox" ]]; then
	do something
fi

That was my first thought too.

But it does not tell which container is actually activated and I did not see any environment variable hosting the information.

This sounds like a good case for an enhancement to toolbox. Should be pretty easy to set an env var that has a configurable container name.

Could you file an issue upstream? https://github.com/debarshiray/toolbox/issues

I’ve been reading opened issues and pending PR on the project repository.

https://github.com/debarshiray/toolbox/pull/210 seems to be a good candidate for my use case if we mix it with the answer of @returntrip. However, having a dedicated env var to store the container name should be available too.

I will take a more in depth look at the project to submit an issue and/or a pull request.

2 Likes