I have a created a chroot jail in my Ubuntu 14.04 machine using schroot and debootstrap.
Now I want to write a shell script that goes back and forth between my native environment and the chroot.
When I write the commands directly in a shell script it chokes the moment I switch to chroot.
... sudo chroot /JAIL #folder to chroot echo "Chrooted now" ...
I get switched to the chroot folder /JAIL however, I don't get the output in echo. It is only when I exit from the chroot to the Host, this output is printed. I inferred that this might have something to do with the user being changed when the when we enter chroot jail.
So, I tried the solutions mentioned in this question How to switch back and forth between users quickly on a single terminal? I also read about heredocs but couldn't get them to work.
Ideally I would like a shell script that has the flow as below:
- chroot to jail
- Do something there
- Move back to Host
- Do something here as well
- Go back to chroot, and so on..