Script to Enter Chroot Container and Run Program?

I have box86 running successfully on a PinePhone Beta/Manjaro ARM/xfce. I’d like a script that gets into the chroot container and runs a command to start a program.

These commands work in terminal, in successive order:

cd gaming
sudo chroot .
box86 wine "C:\Program Files\HanDBase4\handbasedesktop.exe"

But when I script them, and run the script in terminal, the script executes without error, yet does nothing.

I have universal root privileges in /etc/sudoers, so a password is not necessary. Is it possible to script into a chroot container and run a program, or must one use the terminal?

Thanks for any advice.

From looking on the internet that program seems to run in a GUI which if it does did you leave out some other things like (xhost +local: and export DISPLAY=:0). It has been a long time since I have messed with chroot so things may have changed.

Combining your lines in a bash script will cause issues the second the chroot command is issued. It will not complete the rest of the script until the chroot command has exited fully.

Since you say things work going line by line with only the lines you provided as is according to the chroot wiki you can enter the chroot environment and run a command with one line.

sudo chroot  path/to/your/new/root box86 wine C:\Program Files\HanDBase4\handbasedesktop.exe

Some of the best magic tricks are the simplest. Your single command does everything. Many, many thanks.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.