From e522bc1090a98cb32c5bcb0b3967d57cbf07524f Mon Sep 17 00:00:00 2001 From: Tommaso Chiti Date: Sun, 31 Oct 2021 08:42:25 +0100 Subject: [PATCH] Pretty print. --- easy-arch.sh | 64 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index 5d3c624..902043f 100644 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -3,7 +3,12 @@ # Cleaning the TTY. clear -# Selecting a kernel to install. +# Pretty print (function). +print () { + echo -e "\e[1m\e[93m[ \e[92m•\e[93m ] \e[4m$1\e[0m" +} + +# Selecting a kernel to install (function). kernel_selector () { echo "List of kernels:" echo "1) Stable — Vanilla Linux kernel and modules, with a few patches applied." @@ -26,7 +31,7 @@ kernel_selector () { esac } -# Selecting a way to handle internet connection. +# Selecting a way to handle internet connection (function). network_selector () { echo "Network utilities:" echo "1) IWD — iNet wireless daemon is a wireless daemon for Linux written by Intel (WiFi-only)." @@ -73,7 +78,7 @@ PS3="Select the disk where Arch Linux is going to be installed: " select ENTRY in $(lsblk -dpnoNAME|grep -P "/dev/sd|nvme|vd"); do DISK=$ENTRY - echo "Installing Arch Linux on $DISK." + print "Installing Arch Linux on $DISK." break done @@ -85,12 +90,12 @@ then wipefs -af "$DISK" &>/dev/null sgdisk -Zo "$DISK" &>/dev/null else - echo "Quitting." + print "Quitting." exit fi # Creating a new partition scheme. -echo "Creating new partition scheme on $DISK." +print "Creating new partition scheme on $DISK." parted -s "$DISK" \ mklabel gpt \ mkpart ESP fat32 1MiB 513MiB \ @@ -101,27 +106,27 @@ ESP="/dev/disk/by-partlabel/ESP" Cryptroot="/dev/disk/by-partlabel/Cryptroot" # Informing the Kernel of the changes. -echo "Informing the Kernel about the disk changes." +print "Informing the Kernel about the disk changes." partprobe "$DISK" # Formatting the ESP as FAT32. -echo "Formatting the EFI Partition as FAT32." +print "Formatting the EFI Partition as FAT32." mkfs.fat -F 32 $ESP &>/dev/null # Creating a LUKS Container for the root partition. -echo "Creating LUKS Container for the root partition" +print "Creating LUKS Container for the root partition" cryptsetup luksFormat $Cryptroot -echo "Opening the newly created LUKS Container." +print "Opening the newly created LUKS Container." cryptsetup open $Cryptroot cryptroot BTRFS="/dev/mapper/cryptroot" # Formatting the LUKS Container as BTRFS. -echo "Formatting the LUKS container as BTRFS." +print "Formatting the LUKS container as BTRFS." mkfs.btrfs $BTRFS &>/dev/null mount $BTRFS /mnt # Creating BTRFS subvolumes. -echo "Creating BTRFS subvolumes." +print "Creating BTRFS subvolumes." btrfs su cr /mnt/@ &>/dev/null btrfs su cr /mnt/@home &>/dev/null btrfs su cr /mnt/@snapshots &>/dev/null @@ -129,7 +134,7 @@ btrfs su cr /mnt/@var_log &>/dev/null # Mounting the newly created subvolumes. umount /mnt -echo "Mounting the newly created subvolumes." +print "Mounting the newly created subvolumes." mount -o ssd,noatime,space_cache,compress=zstd,subvol=@ $BTRFS /mnt mkdir -p /mnt/{home,.snapshots,/var/log,boot} mount -o ssd,noatime,space_cache=v2,compress=zstd,discard=async,subvol=@home $BTRFS /mnt/home @@ -141,13 +146,13 @@ mount $ESP /mnt/boot/ kernel_selector # Pacstrap (setting up a base sytem onto the new root). -echo "Installing the base system (it may take a while)." +print "Installing the base system (it may take a while)." pacstrap /mnt base $kernel $microcode linux-firmware btrfs-progs grub grub-btrfs efibootmgr snapper reflector base-devel snap-pac zram-generator network_selector # Generating /etc/fstab. -echo "Generating a new fstab." +print "Generating a new fstab." genfstab -U /mnt >> /mnt/etc/fstab # Setting hostname. @@ -167,7 +172,7 @@ read -r -p "Please insert the keyboard layout you use: " kblayout echo "KEYMAP=$kblayout" > /mnt/etc/vconsole.conf # Setting hosts file. -echo "Setting hosts file." +print "Setting hosts file." cat > /mnt/etc/hosts < /mnt/etc/hosts </dev/null + # Generating a new initramfs. echo "Creating a new initramfs." mkinitcpio -P &>/dev/null + # Snapper configuration umount /.snapshots rm -r /.snapshots @@ -204,13 +213,15 @@ arch-chroot /mnt /bin/bash -e </dev/null - + # Creating grub config file. echo "Creating GRUB config file." grub-mkconfig -o /boot/grub/grub.cfg &>/dev/null + # Adding user with sudo privilege if [ -n "$username" ]; then echo "Adding $username with root privilege." @@ -218,34 +229,35 @@ arch-chroot /mnt /bin/bash -e <> /etc/sudoers.d/$username fi + EOF # Setting root password. -echo "Setting root password." +print "Setting root password." arch-chroot /mnt /bin/passwd [ -n "$username" ] && echo "Setting user password for ${username}." && arch-chroot /mnt /bin/passwd "$username" # Enabling Reflector timer. -echo "Enabling Reflector." +print "Enabling Reflector." systemctl enable reflector.timer --root=/mnt &>/dev/null # Enabling Snapper automatic snapshots. -echo "Enabling Snapper and automatic snapshots entries." +print "Enabling Snapper and automatic snapshots entries." systemctl enable snapper-timeline.timer --root=/mnt &>/dev/null systemctl enable snapper-cleanup.timer --root=/mnt &>/dev/null systemctl enable grub-btrfs.path --root=/mnt &>/dev/null # Enabling systemd-oomd. -echo "Enabling systemd-oomd." +print "Enabling systemd-oomd." systemctl enable systemd-oomd --root=/mnt &>/dev/null -# ZRAM configuration -bash -c 'cat > /mnt/etc/systemd/zram-generator.conf' <<-'EOF' +# ZRAM configuration. +cat > /mnt/etc/systemd/zram-generator.conf <