LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Chroot in shell scripts: Ensuring that subsequent commands execute within the chroot (http://www.linuxquestions.org/questions/programming-9/chroot-in-shell-scripts-ensuring-that-subsequent-commands-execute-within-the-chroot-830522/)

Kenny_Strawn 09-05-2010 09:09 PM

Chroot in shell scripts: Ensuring that subsequent commands execute within the chroot
 
I currently am writing a shell script to install and configure a full system without Ubiquity and have run into a roadblock: When the script gets to the chroot (that being "sudo chroot <install drive mount point>, inside the chroot nothing happens. It just leaves me with the main prompt. Any ideas on how to fix this?

unSpawn 09-06-2010 02:09 PM

The manual page says 'chroot NEWROOT [COMMAND...]' as in 'sudo chroot echo "Hello World!";'? meaning you can either run a command directly or drop a shell script in the chroot and execute that.

Siljrath 05-21-2012 12:25 PM

sry for being slow with this.


just to clarify,
so where one might normally add /bin/bash, one can replace it with a script?

like in my case the line:
Code:

chroot /mnt/$DISTRONAME /bin/bash
becomes
Code:

chroot /mnt/$DISTRONAME witchroot
witchroot being the script i had just generated.

does that seem right?

or would the ~ no, i'll simply ask that^ before i get any more confused.


...also... i wonder if there's a way (~sorry, perhaps veering somewhat off-topic with this~) to pass variables to the chrooted environment too. is there?


All times are GMT -5. The time now is 09:42 AM.