Improve script output

The '==>' prefix is used by pacstrap, pacman, and mkinitcpio. A new
prefix is needed to better differentiate the output of the script from
the output of the programs mentioned above.
Also adding more output to the different steps helps during troubleshooting.
This commit is contained in:
Christian Kotte 2020-07-12 22:27:25 +02:00 committed by Aaron Bull Schaefer
parent d52ce407d4
commit 090a1cb9a6
6 changed files with 45 additions and 16 deletions

View file

@ -1,9 +1,11 @@
#!/usr/bin/bash -x
# Clean the pacman cache.
/usr/bin/yes | /usr/bin/pacman -Scc
echo ">>>> cleanup.sh: Cleaning pacman cache.."
/usr/bin/pacman -Scc --noconfirm
# Write zeros to improve virtual disk compaction.
echo ">>>> cleanup.sh: Writing zeros to improve virtual disk compaction.."
zerofile=$(/usr/bin/mktemp /zerofile.XXXXX)
/usr/bin/dd if=/dev/zero of="$zerofile" bs=1M
/usr/bin/rm -f "$zerofile"

View file

@ -21,83 +21,100 @@ TARGET_DIR='/mnt'
COUNTRY=${COUNTRY:-US}
MIRRORLIST="https://www.archlinux.org/mirrorlist/?country=${COUNTRY}&protocol=http&protocol=https&ip_version=4&use_mirror_status=on"
echo "==> Setting local mirror"
echo ">>>> install-base.sh: Setting pacman ${COUNTRY} mirrors.."
curl -s "$MIRRORLIST" | sed 's/^#Server/Server/' > /etc/pacman.d/mirrorlist
echo "==> Clearing partition table on ${DISK}"
echo ">>>> install-base.sh: Clearing partition table on ${DISK}.."
/usr/bin/sgdisk --zap ${DISK}
echo "==> Destroying magic strings and signatures on ${DISK}"
echo ">>>> install-base.sh: Destroying magic strings and signatures on ${DISK}.."
/usr/bin/dd if=/dev/zero of=${DISK} bs=512 count=2048
/usr/bin/wipefs --all ${DISK}
echo "==> Creating /root partition on ${DISK}"
echo ">>>> install-base.sh: Creating /root partition on ${DISK}.."
/usr/bin/sgdisk --new=1:0:0 ${DISK}
echo "==> Setting ${DISK} bootable"
echo ">>>> install-base.sh: Setting ${DISK} bootable.."
/usr/bin/sgdisk ${DISK} --attributes=1:set:2
echo '==> Creating /root filesystem (ext4)'
echo ">>>> install-base.sh: Creating /root filesystem (ext4).."
/usr/bin/mkfs.ext4 -O ^64bit -F -m 0 -q -L root ${ROOT_PARTITION}
echo "==> Mounting ${ROOT_PARTITION} to ${TARGET_DIR}"
echo ">>>> install-base.sh: Mounting ${ROOT_PARTITION} to ${TARGET_DIR}.."
/usr/bin/mount -o noatime,errors=remount-ro ${ROOT_PARTITION} ${TARGET_DIR}
echo '==> Bootstrapping the base installation'
echo ">>>> install-base.sh: Bootstrapping the base installation.."
/usr/bin/pacstrap ${TARGET_DIR} base base-devel linux
# Need to install netctl as well: https://github.com/archlinux/arch-boxes/issues/70
# Can be removed when Vagrant's Arch plugin will use systemd-networkd: https://github.com/hashicorp/vagrant/pull/11400
echo ">>>> install-base.sh: Installing basic packages.."
/usr/bin/arch-chroot ${TARGET_DIR} pacman -S --noconfirm gptfdisk openssh syslinux dhcpcd netctl
echo ">>>> install-base.sh: Configuring syslinux.."
/usr/bin/arch-chroot ${TARGET_DIR} syslinux-install_update -i -a -m
/usr/bin/sed -i "s|sda3|${ROOT_PARTITION##/dev/}|" "${TARGET_DIR}/boot/syslinux/syslinux.cfg"
/usr/bin/sed -i 's/TIMEOUT 50/TIMEOUT 10/' "${TARGET_DIR}/boot/syslinux/syslinux.cfg"
echo '==> Generating the filesystem table'
echo ">>>> install-base.sh: Generating the filesystem table.."
/usr/bin/genfstab -p ${TARGET_DIR} >> "${TARGET_DIR}/etc/fstab"
echo '==> Generating the system configuration script'
echo ">>>> install-base.sh: Generating the system configuration script.."
/usr/bin/install --mode=0755 /dev/null "${TARGET_DIR}${CONFIG_SCRIPT}"
CONFIG_SCRIPT_SHORT=`basename "$CONFIG_SCRIPT"`
cat <<-EOF > "${TARGET_DIR}${CONFIG_SCRIPT}"
echo ">>>> ${CONFIG_SCRIPT_SHORT}: Configuring hostname, timezone, and keymap.."
echo '${FQDN}' > /etc/hostname
/usr/bin/ln -s /usr/share/zoneinfo/${TIMEZONE} /etc/localtime
echo 'KEYMAP=${KEYMAP}' > /etc/vconsole.conf
echo ">>>> ${CONFIG_SCRIPT_SHORT}: Configuring locale.."
/usr/bin/sed -i 's/#${LANGUAGE}/${LANGUAGE}/' /etc/locale.gen
/usr/bin/locale-gen
echo ">>>> ${CONFIG_SCRIPT_SHORT}: Creating initramfs.."
/usr/bin/mkinitcpio -p linux
echo ">>>> ${CONFIG_SCRIPT_SHORT}: Setting root pasword.."
/usr/bin/usermod --password ${PASSWORD} root
# https://wiki.archlinux.org/index.php/Network_Configuration#Device_names
echo ">>>> ${CONFIG_SCRIPT_SHORT}: Configuring network.."
/usr/bin/ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
/usr/bin/ln -s '/usr/lib/systemd/system/dhcpcd@.service' '/etc/systemd/system/multi-user.target.wants/dhcpcd@eth0.service'
echo ">>>> ${CONFIG_SCRIPT_SHORT}: Configuring sshd.."
/usr/bin/sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config
/usr/bin/systemctl enable sshd.service
# Workaround for https://bugs.archlinux.org/task/58355 which prevents sshd to accept connections after reboot
echo ">>>> ${CONFIG_SCRIPT_SHORT}: Adding workaround for sshd connection issue after reboot.."
/usr/bin/pacman -S --noconfirm rng-tools
/usr/bin/systemctl enable rngd
# Vagrant-specific configuration
echo ">>>> ${CONFIG_SCRIPT_SHORT}: Creating vagrant user.."
/usr/bin/useradd --password ${PASSWORD} --comment 'Vagrant User' --create-home --user-group vagrant
echo ">>>> ${CONFIG_SCRIPT_SHORT}: Configuring sudo.."
echo 'Defaults env_keep += "SSH_AUTH_SOCK"' > /etc/sudoers.d/10_vagrant
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/10_vagrant
/usr/bin/chmod 0440 /etc/sudoers.d/10_vagrant
echo ">>>> ${CONFIG_SCRIPT_SHORT}: Configuring ssh access for vagrant.."
/usr/bin/install --directory --owner=vagrant --group=vagrant --mode=0700 /home/vagrant/.ssh
/usr/bin/curl --output /home/vagrant/.ssh/authorized_keys --location https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub
/usr/bin/chown vagrant:vagrant /home/vagrant/.ssh/authorized_keys
/usr/bin/chmod 0600 /home/vagrant/.ssh/authorized_keys
# clean up
echo ">>>> ${CONFIG_SCRIPT_SHORT}: Cleaning up.."
/usr/bin/pacman -Rcns --noconfirm gptfdisk
EOF
echo '==> Entering chroot and configuring system'
echo ">>>> install-base.sh: Entering chroot and configuring system.."
/usr/bin/arch-chroot ${TARGET_DIR} ${CONFIG_SCRIPT}
rm "${TARGET_DIR}${CONFIG_SCRIPT}"
# http://comments.gmane.org/gmane.linux.arch.general/48739
echo '==> Adding workaround for shutdown race condition'
echo ">>>> install-base.sh: Adding workaround for shutdown race condition.."
/usr/bin/install --mode=0644 /root/poweroff.timer "${TARGET_DIR}/etc/systemd/system/poweroff.timer"
echo '==> Installation complete!'
echo ">>>> install-base.sh: Completing installation.."
/usr/bin/sleep 3
/usr/bin/umount ${TARGET_DIR}
/usr/bin/systemctl reboot
echo ">>>> install-base.sh: Installation complete!"

View file

@ -2,6 +2,7 @@
# Parallels Tools
# https://wiki.archlinux.org/index.php/Parallels
echo ">>>> install-virtualbox.sh: Installing Parallels Tools.."
mount /dev/sr1 /mnt
ln -sf /usr/lib/systemd/scripts/ /etc/init.d
export def_sysconfdir=/etc/init.d
@ -11,6 +12,7 @@ ln -sf /usr/bin/python2 /usr/local/bin/python
/mnt/install --install-unattended
# clean up
echo ">>>> install-virtualbox.sh: Cleaning Up.."
umount /dev/sr1
/usr/bin/pacman -Rcns --noconfirm python2 linux-headers
rm -f /etc/init.d

View file

@ -2,10 +2,15 @@
# VirtualBox Guest Additions
# https://wiki.archlinux.org/index.php/VirtualBox/Install_Arch_Linux_as_a_guest
echo ">>>> install-virtualbox.sh: Installing VirtualBox Guest Additions and NFS utilities.."
/usr/bin/pacman -S --noconfirm virtualbox-guest-utils-nox nfs-utils
echo ">>>> install-virtualbox.sh: Enabling VirtualBox Guest service.."
/usr/bin/systemctl enable vboxservice.service
echo ">>>> install-virtualbox.sh: Enabling RPC Bind service.."
/usr/bin/systemctl enable rpcbind.service
# Add groups for VirtualBox folder sharing
echo ">>>> install-virtualbox.sh: Enabling VirtualBox Shared Folders.."
/usr/bin/usermod --append --groups vagrant,vboxsf vagrant

View file

@ -3,7 +3,11 @@
# Open VM Tools
# https://wiki.archlinux.org/index.php/VMware
# https://wiki.archlinux.org/index.php/VMware/Installing_Arch_as_a_guest
echo ">>>> install-virtualbox.sh: Installing Open-VM-Tools and NFS utilities.."
/usr/bin/pacman -S --noconfirm linux-headers open-vm-tools nfs-utils
echo ">>>> install-virtualbox.sh: Enabling Open-VM-Tools service.."
/usr/bin/systemctl enable vmtoolsd.service
echo ">>>> install-virtualbox.sh: Enabling RPC Bind service.."
/usr/bin/systemctl enable rpcbind.service

View file

@ -2,7 +2,6 @@
PASSWORD=$(/usr/bin/openssl passwd -crypt 'vagrant')
echo "==> Enabling SSH"
# Vagrant-specific configuration
/usr/bin/useradd --password ${PASSWORD} --comment 'Vagrant User' --create-home --user-group vagrant
echo 'Defaults env_keep += "SSH_AUTH_SOCK"' > /etc/sudoers.d/10_vagrant