You are not logged in.
In order to be able to deploy servers in mess with a controlled installation process, I recently wrote a script to install Arch Linux . It reads as follows.
............
echo 'echo "localhost" > /etc/hostname &&echo -e "127.0.0.1\tlocalhost\n::1\tlocalhost\n127.0.1.1\tlocalhost.localdomain\tlocalhost" > /etc/hosts &&ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&hwclock --systohc &&echo -e "en_US.UTF-8 UTF-8\nzh_CN.UTF-8 UTF-8" >> /etc/locale.gen &&locale-gen &&echo "LANG=en_US.UTF-8" > /etc/locale.conf' | arch-chroot /mnt
echo 'echo -e "y\ny" | sudo pacman -S intel-ucode grub efibootmgr os-prober &&grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=ARCH &&grub-mkconfig -o /boot/grub/grub.cfg' | arch-chroot /mnt 'useradd -m -G wheel -s /bin/bash myusername'| arch-chroot /mnt
When dealing with /etc/default/grub, I need to edit a line beginning with "GRUB_CMDLINE_LINUX_DEFAULT":
Remove the last "quiet" parameter;
Change the "loglevel" value from "3" to "5";
Add the parameter "modprobe.blacklist=iTCO_wdt".
That means changing the line GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet" into GRUB_CMDLINE_LINUX_DEFAULT="loglevel=5 modprobe.blacklist=iTCO_wdt"
But I can't use a script to make an exact substitution for a particular line. So I have to manually modify the content: How can I use a regular expression to locate a line that contains a specific string (starting with a string, to be exact), and modify the content of that line with a command like “sed...”?
(On the network, there are only solutions to locating rows with row numbers matching certain regularity numerically)
----------------
AND: I don't have a way to automate the password change for the user “root“ and the non-root user “myusername” using script commands. When I use
echo "echo 'mypassword' | passwd myusername" | arch-chroot /mnt
command, it has no effect. What's the solution?
Last edited by hotwind (2024-12-02 17:24:47)
Offline
For your second question, I looked up arch-chroot at https://wiki.archlinux.org/title/Chroot and I believe your syntax needs to be changed to:
# arch-chroot /mnt echo "echo 'mypassword' | passwd myusername"
Offline