0

I have written a BASH script that would prepare and install everything during ArchLinux initial installation. The script would work fine and execute everything successfully until it reaches the arch-chroot command then it would stop.

Also, the solutions I found online (like the EOF trick) wouldn't pass functions or variables after chroot.

Here is a demo:

#!/bin/bash

username=test
pause_var=1

pause ()
{
if [ $pause_var -eq 1 ]
then
    read -n 1 -s -r -p "Press any key to continue"
fi
}

arch-chroot /mnt #the script stops after executing this line!!

# some commands after chroot
useradd -m $username
pause

echo $username:123 | chpasswd
pause

# ... more commands below

I googled for a solution but none of the solutions that I found have worked for me. I'm a Linux noob.

Thank you.

1 Answer 1

0

From man arch-chroot

arch-chroot [options] chroot-dir [command]

So you can simply do this arch-chroot /mnt /bin/bash /file/in/chroot/script.sh

If it doesn't accept additional arguments you could try arch-chroot /mnt /file/in/chroot/script.sh

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.