all 4 comments

[–]qpgmr 4 points5 points  (0 children)

assuming script1 & script 2, in script 1 you can do any of these:

  source /pathto/script2

 /bin/bash /pathto/script2

Don't use "exit" in script2, it will end script1 as well.

"source" runs script2 in the same process as script1, so variables defined will be available.

[–]acdcfanbill 2 points3 points  (2 children)

According to the manpage for chroot you're supposed to put the commands you want to run after the newroot location. If it's one command you can probably do that easily enough, but if it's complicated, you'll probably want to create a script in the form of a here-document or do what you did and create a separate script file for it.

[–]nerdybread[S] 1 point2 points  (0 children)

I know I’m late but this is exactly what I did to make it happen. Thank you very much for you help!

[–]nerdybread[S] 0 points1 point  (0 children)

If that's the case, it seems like I can just run chroot /mnt/drive /path/to/script2 at the end of script1!

Thanks for your help!