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.