Auto update toolbox containers

This article below describes a similar approach as distrobox:

However, I have tmux as my default shell. My ~/.bashrc includes the following to make sure tmux is only ran with an interactive shell. However, toolbox --container fedora-toolbox run sudo dnf upgrade --quiet --refresh --assumeyes is also regarded as an interactive shell. Which doesn’t allow me to run that dnf upgrade command. It goes to an empty tmux shell.

if [[ -n "$DISPLAY" ]]; then # Only continue if in a GUI environment
  if [[ -z "$SSH_CLIENT" ]] || [[ -z "$SSH_TTY" ]] && [[ -f /run/.toolboxenv ]]; then # Only continue if not in an SSH session
    if command -v tmux &> /dev/null && [[ -z "$TMUX" ]]; then # Only continue if tmux is installed and not already started
      exec tmux -2
    fi
  fi
fi

Which makes me wonder. How do you update your toolbox containers automatically? A different update approach might work as well.

If you’re embedding that command in a systemd unit, how do you know that it’s going into an empty tmux shell?

Also, are you certain “fedora-toolbox” is your container name? The default naming convention that’s used is “fedora-toolbox-##”. That’s what’s created when toolbox create is executed, and “##” being the Fedora release number that was used when that command was executed.

Because I can do it interactively, and then I just get a tmux shell in a new session where nothing happens.

And the logs say:

sep 15 00:00:09 ws1 systemd[2664]: Starting refresh-toolbox@fedora-toolbox.service - Refresh dnf cache (fedora-toolbox)...
sep 15 00:00:09 ws1 podman[233734]: 2024-09-15 00:00:09.353892125 +0200 CEST m=+0.052694297 container exec c1a70d0d88c6206f8473c363846d8489933bdefe1cd55354400b3124c7506b8d (image=localhost/user/fedora-toolbox:latest, name=fedora-toolbox, com.github.containers.toolbox=true, org.opencontainers.image.url=https://fedoraproject.org/, license=MIT, org.opencontainers.image.vendor=Fedora Project, version=40, vendor=Fedora Project, org.opencontainers.image.version=40, org.openconta>
sep 15 00:00:09 ws1 toolbox[233734]: stty: 'standard input': Inappropriate ioctl for device
sep 15 00:00:09 ws1 toolbox[233734]: open terminal failed: not a terminal

It’s custom indeed, because I build my custom Fedora toolbox. Since Toolbox doesn’t have an easy way to template containers (like Distrobox), I created my own build with overlay packages. That’s why I also have a custom name for the container.

People don’t auto-update their Toolbox container I guess? Or maybe they do, but don’t have tmux setup in their Bash env of course.

May i ask how do you manage to template fedora toolbox ? i was looking alternatives to make a template for toolbox

Can you comment out the tmux stuff in your .bashrc and try? I’m curious if that’s really the problem.

Then it works. The method described in that blog post in the top post indeed works, but tmux intercepts it.

But I think nobody here auto-updates their container (in any other way). It sucks a bit, since distrobox makes this so easy and then it does work with tmux as default shell in bashrc.