You are not logged in.
Hi all,
I'm running a number of test installs from the bootable .iso copied onto a USB flash drive.
Instead of entering every command manually I've made a basic install script (well, series of scripts) to do the hard work for me.
At the end of the process, one of the scripts has the following commands in it:
exit
umount -R /mnt
rebootThe problem is this just exits the script. So what do I do once this has happened to achieve the desired reboot automatically?
Thanks,
Loady
Last edited by loadlover (2017-06-09 13:27:19)
Offline
Who put "exit" there? That becomes the *final* command.
Offline
I have to exit. To get back to the virtual install console. I then need to exit THAT, then reboot - all in an automated way. See?
Like waking up from a dream, only to realize you were dreaming in your dream, and are therefore still asleep. How to solve?
Last edited by loadlover (2017-06-09 13:17:51)
Offline
Run the script using the source command, then there is no need to exit.
Offline
Superb.
Thanks breb.
Loady
Offline
From the context I gather you were intending to exit from a chroot. You do need to exit a chroot, and I don't see how sourcing a script will help avoid that. However, this can't be done with a single script, you need at least two: one to do the work outside the chroot and one inside. You can have these in the same file with a here document. But the key is that the "inner" script will exit, then the outscript unmounts and reboots:
fdisk ...
mkfs ...
mount ...
pacstrap ...
genfstab ...
cat <<EOF >/mnt/root/setup
ln -sf /usr/share/zoneinfo/...
sed -i '...' /etc/locale.conf
locale-gen
...
exit
EOF
chmod 0755 /mnt/root/setup
arch-chroot /mnt /root/setup
umnt -R /mnt
reboot"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Took me a little while to digest but yes I understand now: 'setup' is the inner script.
Many thanks,
Loady
Offline
..
Last edited by vegangaro (2017-06-11 15:27:23)
C++ and KDE = PRAISE THE SUN!
Offline
How what is done vegangaro? Installation of arch linux is done acording to the wiki. The only step that isn't in the installation guide on the wiki that would be needed for a script is coordinating the inner/outer scripts as I described above. A here-documented (as demonstrated above) is one simple way of doing this.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
vegangaro: don't do that https://wiki.archlinux.org/index.php/Co … way_street
Offline
From the context I gather you were intending to exit from a chroot. You do need to exit a chroot, and I don't see how sourcing a script will help avoid that. However, this can't be done with a single script, you need at least two: one to do the work outside the chroot and one inside. You can have these in the same file with a here document. But the key is that the "inner" script will exit, then the outscript unmounts and reboots:
fdisk ... mkfs ... mount ... pacstrap ... genfstab ... cat <<EOF >/mnt/root/setup ln -sf /usr/share/zoneinfo/... sed -i '...' /etc/locale.conf locale-gen ... exit EOF chmod 0755 /mnt/root/setup arch-chroot /mnt /root/setup umnt -R /mnt reboot
I got this working just fine a while ago. Thanks again Trilby. Recently, however, I was messing around and did this:
cat <<EOF >/mnt/root/setup
...
pacman -S --noconfirm $(< /stuff/payload/pac2)
...
EOFWhen cat has done its magic, the setup script file created contains the pacman line, but truncated to:
pacman -S --noconfirm If you know the answer as to why, PLEASE don't tell me, but could you give me a hint? This is a consequence of how cat works, right?
Thanks,
Loady
EDIT: SOLVED. Forget it;)
Last edited by loadlover (2017-07-10 10:18:41)
Offline
Please share your solution for others. I'm pretty sure I know: it'd not be due to how cat works, but rather how here documents work. They can be started with the initial EOF indicator "plain" or quoted ( <<EOF vs <<'EOF' ) and those behave differently.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
My mistake was far more prosaic (and embarrassing) than the interesting difference between the two here document invocations. It arose because of the scope in which the original script was executed - *before* the change of root. So I should have used /mnt/stuff/payload/pac2 and not /stuff/payload/pac2.
In other words, the file doesn't actually exist, and the whole "$(< /stuff/payload/pac2)" part amounts to precisely nothing.
![]()
Oh well.
Offline