From b3b860c8d61225e402293d65b415c87a2cc6b8e5 Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Mon, 25 Apr 2022 09:43:06 +0000 Subject: [PATCH 01/31] change btrfs subvolume related commands to loops --- easy-arch.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index 89004dc..0b357c0 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -254,9 +254,9 @@ mount $BTRFS /mnt # Creating BTRFS subvolumes. print "Creating BTRFS subvolumes." -for volume in @ @home @root @srv @snapshots @var_log @var_pkgs -do - btrfs su cr /mnt/$volume +subvols=(snapshots var_pkgs var_log home root srv) +for subvol in '' ${subvols[@]}; do + btrfs su cr /mnt/@$volume done # Mounting the newly created subvolumes. @@ -264,11 +264,10 @@ umount /mnt print "Mounting the newly created subvolumes." mount -o ssd,noatime,compress-force=zstd:3,discard=async,subvol=@ $BTRFS /mnt mkdir -p /mnt/{home,root,srv,.snapshots,/var/log,/var/cache/pacman/pkg,boot} -mount -o ssd,noatime,compress-force=zstd:3,discard=async,subvol=@home $BTRFS /mnt/home -mount -o ssd,noatime,compress-force=zstd:3,discard=async,subvol=@root $BTRFS /mnt/root -mount -o ssd,noatime,compress-force=zstd:3,discard=async,subvol=@srv $BTRFS /mnt/srv +for subvol in ${subvols[@]:2}; do # ":2" excludes first two subvols (@var_pkgs and @snapshots) from loop +mount -o ssd,noatime,compress-force=zstd:3,discard=async,subvol=@$subvol $BTRFS /mnt/$(sed 's,_,/,g' <<< $subvol) +done mount -o ssd,noatime,compress-force=zstd:3,discard=async,subvol=@snapshots $BTRFS /mnt/.snapshots -mount -o ssd,noatime,compress-force=zstd:3,discard=async,subvol=@var_log $BTRFS /mnt/var/log mount -o ssd,noatime,compress-force=zstd:3,discard=async,subvol=@var_pkgs $BTRFS /mnt/var/cache/pacman/pkg chattr +C /mnt/var/log mount $ESP /mnt/boot/ From c56fbb98782d20d8da15cd36eccb94d52fa5a0d6 Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Mon, 25 Apr 2022 09:44:31 +0000 Subject: [PATCH 02/31] use nested brace expansion when making subvol dirs also removed unnecessary / --- easy-arch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy-arch.sh b/easy-arch.sh index 0b357c0..93edca7 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -263,7 +263,7 @@ done umount /mnt print "Mounting the newly created subvolumes." mount -o ssd,noatime,compress-force=zstd:3,discard=async,subvol=@ $BTRFS /mnt -mkdir -p /mnt/{home,root,srv,.snapshots,/var/log,/var/cache/pacman/pkg,boot} +mkdir -p /mnt/{home,root,srv,.snapshots,var/{log,cache/pacman/pkg},boot} for subvol in ${subvols[@]:2}; do # ":2" excludes first two subvols (@var_pkgs and @snapshots) from loop mount -o ssd,noatime,compress-force=zstd:3,discard=async,subvol=@$subvol $BTRFS /mnt/$(sed 's,_,/,g' <<< $subvol) done From 7797b19331780f65eadb63e6f233860e1ca9d2c6 Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Mon, 25 Apr 2022 09:54:37 +0000 Subject: [PATCH 03/31] simplify grub & sudoers sed expressions --- easy-arch.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index 93edca7..70288c3 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -324,7 +324,7 @@ EOF # Setting up LUKS2 encryption in grub. print "Setting up grub config." UUID=$(blkid -s UUID -o value $CRYPTROOT) -sed -i "s,^GRUB_CMDLINE_LINUX=\"\",GRUB_CMDLINE_LINUX=\"rd.luks.name=$UUID=cryptroot root=$BTRFS\",g" /mnt/etc/default/grub +sed -i "s,^GRUB_CMDLINE_LINUX=\",&rd.luks.name=$UUID=cryptroot root=$BTRFS\",g" /mnt/etc/default/grub # Configuring the system. arch-chroot /mnt /bin/bash -e < Date: Mon, 25 Apr 2022 09:55:43 +0000 Subject: [PATCH 04/31] fix typo in last commit --- easy-arch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy-arch.sh b/easy-arch.sh index 70288c3..64c320a 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -373,7 +373,7 @@ echo "root:$rootpass" | arch-chroot /mnt chpasswd if [ -n "$username" ]; then print "Adding the user $username to the system with root privilege." arch-chroot /mnt useradd -m -G wheel -s /bin/bash "$username" - sed -i '%wheel ALL=(ALL) ALL/s/^# //' /mnt/etc/sudoers + sed -i '/%wheel ALL=(ALL) ALL/s/^# //' /mnt/etc/sudoers print "Setting user password for $username." echo "$username:$userpass" | arch-chroot /mnt chpasswd fi From 3df93905c4eeb01184cf158cf712f38e3156fc19 Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Mon, 25 Apr 2022 21:48:55 +0000 Subject: [PATCH 05/31] Update easy-arch.sh --- easy-arch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy-arch.sh b/easy-arch.sh index 64c320a..d8e1173 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -264,7 +264,7 @@ umount /mnt print "Mounting the newly created subvolumes." mount -o ssd,noatime,compress-force=zstd:3,discard=async,subvol=@ $BTRFS /mnt mkdir -p /mnt/{home,root,srv,.snapshots,var/{log,cache/pacman/pkg},boot} -for subvol in ${subvols[@]:2}; do # ":2" excludes first two subvols (@var_pkgs and @snapshots) from loop +for subvol in ${subvols[@]:2}; do # ":2" excludes first two subvols (@snapshots and @var_pkgs) from loop mount -o ssd,noatime,compress-force=zstd:3,discard=async,subvol=@$subvol $BTRFS /mnt/$(sed 's,_,/,g' <<< $subvol) done mount -o ssd,noatime,compress-force=zstd:3,discard=async,subvol=@snapshots $BTRFS /mnt/.snapshots From 576912e9ecff5409764e25b68df133eff544e6f4 Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Tue, 26 Apr 2022 07:54:53 +0000 Subject: [PATCH 06/31] fix indentation of password selection functions made the indentation on the password selection functions more consistent and use 4 spaces per indent instead of a literal tab character. --- easy-arch.sh | 84 ++++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index d8e1173..042756e 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -104,20 +104,20 @@ network_selector () { # Setting up a password for the LUKS Container (function). lukspass_selector () { - while true; do - read -r -s -p "Insert password for the LUKS container (you're not going to see the password): " password - while [ -z "$password" ]; do - echo - print "You need to enter a password for the LUKS Container in order to continue." - read -r -s -p "Insert password for the LUKS container (you're not going to see the password): " password - [ -n "$password" ] && break - done - echo - read -r -s -p "Password (again): " password2 - echo - [ "$password" = "$password2" ] && break - echo "Passwords don't match, try again." - done + while true; do + read -r -s -p "Insert password for the LUKS container (you're not going to see the password): " password + while [ -z "$password" ]; do + echo + print "You need to enter a password for the LUKS Container in order to continue." + read -r -s -p "Insert password for the LUKS container (you're not going to see the password): " password + [ -n "$password" ] && break + done + echo + read -r -s -p "Password (again): " password2 + echo + [ "$password" = "$password2" ] && break + echo "Passwords don't match, try again." + done echo -n "$password" | cryptsetup luksFormat "$CRYPTROOT" -d - echo -n "$password" | cryptsetup open "$CRYPTROOT" cryptroot -d - BTRFS="/dev/mapper/cryptroot" @@ -125,38 +125,38 @@ lukspass_selector () { # Setting up a password for the user account (function). userpass_selector () { -while true; do - read -r -s -p "Set a user password for $username: " userpass - while [ -z "$userpass" ]; do - echo - print "You need to enter a password for $username." - read -r -s -p "Set a user password for $username: " userpass - [ -n "$userpass" ] && break - done - echo - read -r -s -p "Insert password again: " userpass2 - echo - [ "$userpass" = "$userpass2" ] && break - echo "Passwords don't match, try again." -done + while true; do + read -r -s -p "Set a user password for $username: " userpass + while [ -z "$userpass" ]; do + echo + print "You need to enter a password for $username." + read -r -s -p "Set a user password for $username: " userpass + [ -n "$userpass" ] && break + done + echo + read -r -s -p "Insert password again: " userpass2 + echo + [ "$userpass" = "$userpass2" ] && break + echo "Passwords don't match, try again." + done } # Setting up a password for the root account (function). rootpass_selector () { -while true; do - read -r -s -p "Set a root password: " rootpass - while [ -z "$rootpass" ]; do - echo - print "You need to enter a root password." - read -r -s -p "Set a root password: " rootpass - [ -n "$rootpass" ] && break - done - echo - read -r -s -p "Password (again): " rootpass2 - echo - [ "$rootpass" = "$rootpass2" ] && break - echo "Passwords don't match, try again." -done + while true; do + read -r -s -p "Set a root password: " rootpass + while [ -z "$rootpass" ]; do + echo + print "You need to enter a root password." + read -r -s -p "Set a root password: " rootpass + [ -n "$rootpass" ] && break + done + echo + read -r -s -p "Password (again): " rootpass2 + echo + [ "$rootpass" = "$rootpass2" ] && break + echo "Passwords don't match, try again." + done } # Microcode detector (function). From 22d6cdf8bca50077fe081f8207dd0c65bceaafdc Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Wed, 27 Apr 2022 02:53:57 +0000 Subject: [PATCH 07/31] move mount options to variable --- easy-arch.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index 042756e..7a8e457 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -262,13 +262,14 @@ done # Mounting the newly created subvolumes. umount /mnt print "Mounting the newly created subvolumes." -mount -o ssd,noatime,compress-force=zstd:3,discard=async,subvol=@ $BTRFS /mnt +mountopts="ssd,noatime,compress-force=zstd:3,discard=async" +mount -o $mountopts,subvol=@ $BTRFS /mnt mkdir -p /mnt/{home,root,srv,.snapshots,var/{log,cache/pacman/pkg},boot} for subvol in ${subvols[@]:2}; do # ":2" excludes first two subvols (@snapshots and @var_pkgs) from loop -mount -o ssd,noatime,compress-force=zstd:3,discard=async,subvol=@$subvol $BTRFS /mnt/$(sed 's,_,/,g' <<< $subvol) +mount -o $mountopts,subvol=@$subvol $BTRFS /mnt/$(sed 's,_,/,g' <<< $subvol) done -mount -o ssd,noatime,compress-force=zstd:3,discard=async,subvol=@snapshots $BTRFS /mnt/.snapshots -mount -o ssd,noatime,compress-force=zstd:3,discard=async,subvol=@var_pkgs $BTRFS /mnt/var/cache/pacman/pkg +mount -o $mountopts,subvol=@snapshots $BTRFS /mnt/.snapshots +mount -o $mountopts,subvol=@var_pkgs $BTRFS /mnt/var/cache/pacman/pkg chattr +C /mnt/var/log mount $ESP /mnt/boot/ From 165a2c03f62670a3e470be624c6389c5195b52ca Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Wed, 27 Apr 2022 08:23:34 +0000 Subject: [PATCH 08/31] Update easy-arch.sh edited some functions related to user input so that their formatting/installing won't take place until after questions are over to prevent having to wait in between questions. also moved the order of the microcode virt check functions run to prevent installing stuff before questions are over, and some other funcs to just be more convenient (keyboard layout is now selected first incase the user isn't using US qwerty) and now there are options to search for locales and keymaps before making a selection. --- easy-arch.sh | 142 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 83 insertions(+), 59 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index 7a8e457..d6cfcfe 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -50,8 +50,8 @@ kernel_selector () { print "2) Hardened: A security-focused Linux kernel" print "3) LTS: Long-term support (LTS) Linux kernel" print "4) Zen: A Linux kernel optimized for desktop usage" - read -r -p "Insert the number of the corresponding kernel: " choice - case $choice in + read -r -p "Insert the number of the corresponding kernel: " kernel_choice + case $kernel_choice in 1 ) kernel="linux" ;; 2 ) kernel="linux-hardened" @@ -73,8 +73,16 @@ network_selector () { print "3) wpa_supplicant: Cross-platform supplicant with support for WEP, WPA and WPA2 (WiFi-only, a DHCP client will be automatically installed as well)" print "4) dhcpcd: Basic DHCP client (Ethernet only or VMs)" print "5) I will do this on my own (only advanced users)" - read -r -p "Insert the number of the corresponding networking utility: " choice - case $choice in + read -r -p "Insert the number of the corresponding networking utility: " network_choice + if ! ((1 <= network_choice <= 5)); then + print "You did not enter a valid selection." + network_selector + fi +} + +# Installing the chosen networking method to the system. +network_installer () { + case $network_choice in 1 ) print "Installing IWD." pacstrap /mnt iwd >/dev/null print "Enabling IWD." @@ -95,10 +103,6 @@ network_selector () { pacstrap /mnt dhcpcd >/dev/null print "Enabling dhcpcd." systemctl enable dhcpcd --root=/mnt &>/dev/null - ;; - 5 ) ;; - * ) print "You did not enter a valid selection." - network_selector esac } @@ -118,9 +122,6 @@ lukspass_selector () { [ "$password" = "$password2" ] && break echo "Passwords don't match, try again." done - echo -n "$password" | cryptsetup luksFormat "$CRYPTROOT" -d - - echo -n "$password" | cryptsetup open "$CRYPTROOT" cryptroot -d - - BTRFS="/dev/mapper/cryptroot" } # Setting up a password for the user account (function). @@ -183,27 +184,44 @@ hostname_selector () { # Setting up the locale (function). locale_selector () { - read -r -p "Please insert the locale you use (format: xx_XX or enter empty to use en_US): " locale - if [ -z "$locale" ]; then - print "en_US will be used as default locale." - locale="en_US" - fi - echo "$locale.UTF-8 UTF-8" > /mnt/etc/locale.gen - echo "LANG=$locale.UTF-8" > /mnt/etc/locale.conf + read -r -p "Please insert the locale you use (format: xx_XX. Enter empty to use en_US, or type a "/" to search avaliable locales): " locale + case $kblayout in + '') print "en_US will be used as default locale." + locale="en_US.UTF-8";; + '/') sed -E '/^# +|^#$/d;s/^#| *$//g;s/ .*/ (Charset:&)/' /etc/locale.gen | less -M;; + *) if ! grep -Fxq $locale /etc/locale.gen; then + print "The specified locale doesn't exist or isn't supported." + locale_selector + fi + sed -i "$locale/s/^#//" /etc/locale.gen + echo "LANG=$locale" > /mnt/etc/locale.conf + esac } # Setting up the keyboard layout (function). keyboard_selector () { - read -r -p "Please insert the keyboard layout you use (enter empty to use US keyboard layout): " kblayout - if [ -z "$kblayout" ]; then - print "US keyboard layout will be used by default." - kblayout="us" - fi - echo "KEYMAP=$kblayout" > /mnt/etc/vconsole.conf + read -r -p "Please insert the keyboard layout you use (enter empty to use US keyboard layout, or enter "/" to search avaliable layouts): " kblayout + case $kblayout in + '') print "US keyboard layout will be used by default." + kblayout="us";; + '/') localectl list-keymaps;; + *) if ! $(localectl list-keymaps | grep -Fxq $locale); then + print "The specified keymap doesn't exist." + keyboard_selector + fi + print "Changing layout to $kblayout." + loadkeys $kblayout + echo "KEYMAP=$kblayout" > /mnt/etc/vconsole.conf;; + esac + } # Selecting the target for the installation. print "Welcome to easy-arch, a script made in order to simplify the process of installing Arch Linux." + +# Setting up keyboard layout. +keyboard_selector + PS3="Please select the disk NUMBER e.g. 1 where Arch Linux is going to be installed: " select ENTRY in $(lsblk -dpnoNAME|grep -P "/dev/sd|nvme|vd"); do @@ -212,18 +230,39 @@ do break done -# Deleting old partition scheme. -read -r -p "This will delete the current partition table on $DISK. Do you agree [y/N]? " response -response=${response,,} -if [[ "$response" =~ ^(yes|y)$ ]]; then - print "Wiping $DISK." - wipefs -af "$DISK" &>/dev/null - sgdisk -Zo "$DISK" &>/dev/null -else +# Warn user about deletion of old partition scheme. +read -r -p "This will delete the current partition table on $DISK once installation starts. Do you agree [y/N]? " disk_response +disk_response=${disk_response,,} +if ! [[ "$disk_response" =~ ^(yes|y)$ ]]; then print "Quitting." exit fi +# Setting up LUKS password. +lukspass_selector + +# Setting up the kernel. +kernel_selector + +# User choses the network. +network_selector + +# Setting up the locale. +locale_selector + +# Setting up the hostname. +hostname_selector + +# Setting username. +read -r -p "Please enter name for a user account (enter empty to not create one): " username +userpass_selector +rootpass_selector + +# Deleting old partition scheme. +print "Wiping $DISK." +wipefs -af "$DISK" &>/dev/null +sgdisk -Zo "$DISK" &>/dev/null + # Creating a new partition scheme. print "Creating the partitions on $DISK." parted -s "$DISK" \ @@ -245,7 +284,9 @@ mkfs.fat -F 32 $ESP &>/dev/null # Creating a LUKS Container for the root partition. print "Creating LUKS Container for the root partition." -lukspass_selector +echo -n "$password" | cryptsetup luksFormat "$CRYPTROOT" -d - +echo -n "$password" | cryptsetup open "$CRYPTROOT" cryptroot -d - +BTRFS="/dev/mapper/cryptroot" # Formatting the LUKS Container as BTRFS. print "Formatting the LUKS container as BTRFS." @@ -273,40 +314,14 @@ mount -o $mountopts,subvol=@var_pkgs $BTRFS /mnt/var/cache/pacman/pkg chattr +C /mnt/var/log mount $ESP /mnt/boot/ -# Setting up the kernel. -kernel_selector - -# Checking the microcode to install. -microcode_detector - -# Virtualization check. -virt_check - -# Setting up the network. -network_selector - # Pacstrap (setting up a base sytem onto the new root). print "Installing the base system (it may take a while)." pacstrap /mnt --needed base $kernel $microcode linux-firmware $kernel-headers btrfs-progs grub grub-btrfs rsync efibootmgr snapper reflector base-devel snap-pac zram-generator >/dev/null -# Setting up the hostname. -hostname_selector - # Generating /etc/fstab. print "Generating a new fstab." genfstab -U /mnt >> /mnt/etc/fstab -# Setting username. -read -r -p "Please enter name for a user account (enter empty to not create one): " username -userpass_selector -rootpass_selector - -# Setting up the locale. -locale_selector - -# Setting up keyboard layout. -keyboard_selector - # Setting hosts file. print "Setting hosts file." cat > /mnt/etc/hosts < /mnt/etc/hosts < /mnt/etc/mkinitcpio.conf < Date: Wed, 27 Apr 2022 09:13:19 +0000 Subject: [PATCH 09/31] cleanup paralleldownloads regex because the pattern ends with ".*" using "$" is pointless --- easy-arch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy-arch.sh b/easy-arch.sh index d6cfcfe..4f15cde 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -430,7 +430,7 @@ EOF # Pacman eye-candy features. print "Enabling colours, animations, and parallel in pacman." -sed -i 's/#Color/Color\nILoveCandy/;s/^#ParallelDownloads.*$/ParallelDownloads = 10/' /mnt/etc/pacman.conf +sed -i 's/#Color/Color\nILoveCandy/;s/^#ParallelDownloads.*/ParallelDownloads = 10/' /mnt/etc/pacman.conf # Enabling various services. print "Enabling Reflector, automatic snapshots, BTRFS scrubbing and systemd-oomd." From c990c0f9a0c221e87ff26e8bff0f1e437da5cfaa Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Wed, 27 Apr 2022 10:34:56 +0000 Subject: [PATCH 10/31] shorten sed for adding ILoveCandy sed's "a" command can be used for this (ty LARBS :P) --- easy-arch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy-arch.sh b/easy-arch.sh index 4f15cde..0f3b9d6 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -430,7 +430,7 @@ EOF # Pacman eye-candy features. print "Enabling colours, animations, and parallel in pacman." -sed -i 's/#Color/Color\nILoveCandy/;s/^#ParallelDownloads.*/ParallelDownloads = 10/' /mnt/etc/pacman.conf +sed -i '/#Color/a ILoveCandy;s/^#ParallelDownloads.*/ParallelDownloads = 10/' /mnt/etc/pacman.conf # Enabling various services. print "Enabling Reflector, automatic snapshots, BTRFS scrubbing and systemd-oomd." From 2fb11dbfb1db052354a98466d5aa1cc0042352aa Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Thu, 28 Apr 2022 00:49:26 +0000 Subject: [PATCH 11/31] fix pacman sed sed expressions using the a, c or i commands cant be separated with ; and require a newline or -e to do so instead. since the ILoveCandy is the only expression in the sequence that uses one of those commands i just moved it to the end which seemed to fix the problem. also shortened the parallel downloads sed. chaining expressions is addressed in section 3.8.1 of the gnu sed manual --- easy-arch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy-arch.sh b/easy-arch.sh index 0f3b9d6..8fc8541 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -430,7 +430,7 @@ EOF # Pacman eye-candy features. print "Enabling colours, animations, and parallel in pacman." -sed -i '/#Color/a ILoveCandy;s/^#ParallelDownloads.*/ParallelDownloads = 10/' /mnt/etc/pacman.conf +sed -i '/^#ParallelDownloads/s/=.*/= 10/;/#Color/a ILoveCandy' /mnt/etc/pacman.conf # Enabling various services. print "Enabling Reflector, automatic snapshots, BTRFS scrubbing and systemd-oomd." From 0a379f40f18f1050af348c86c8d5ca9a388ae3c1 Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Thu, 28 Apr 2022 02:33:08 +0000 Subject: [PATCH 12/31] fix keyboard/locale not being installed, and kb select function use the right var when checking if the selected keymap exists, don't skip prompt for keyboard layout if the user entered "/" and don't include the installation of the keymap/locale in the selection functions since no subvolumes are mounted when they're called --- easy-arch.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index 8fc8541..e6d06be 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -194,7 +194,6 @@ locale_selector () { locale_selector fi sed -i "$locale/s/^#//" /etc/locale.gen - echo "LANG=$locale" > /mnt/etc/locale.conf esac } @@ -204,14 +203,14 @@ keyboard_selector () { case $kblayout in '') print "US keyboard layout will be used by default." kblayout="us";; - '/') localectl list-keymaps;; - *) if ! $(localectl list-keymaps | grep -Fxq $locale); then + '/') localectl list-keymaps + keyboard_selector;; + *) if ! $(localectl list-keymaps | grep -Fxq $kblayout); then print "The specified keymap doesn't exist." keyboard_selector fi print "Changing layout to $kblayout." loadkeys $kblayout - echo "KEYMAP=$kblayout" > /mnt/etc/vconsole.conf;; esac } @@ -314,6 +313,10 @@ mount -o $mountopts,subvol=@var_pkgs $BTRFS /mnt/var/cache/pacman/pkg chattr +C /mnt/var/log mount $ESP /mnt/boot/ +# Configure selected keyboard layout and locale +echo "KEYMAP=$kblayout" > /mnt/etc/vconsole.conf +echo "LANG=$locale" > /mnt/etc/locale.conf + # Pacstrap (setting up a base sytem onto the new root). print "Installing the base system (it may take a while)." pacstrap /mnt --needed base $kernel $microcode linux-firmware $kernel-headers btrfs-progs grub grub-btrfs rsync efibootmgr snapper reflector base-devel snap-pac zram-generator >/dev/null From 93f2caeb3b856a40665d5b9cb0407d7d6847b854 Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Thu, 28 Apr 2022 03:10:37 +0000 Subject: [PATCH 13/31] fix locale selector, clear screen after listing keymaps/locales fix another var typo and clear the screen after the user searches for locales/keymaps with / (since less floods the screen) --- easy-arch.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index e6d06be..d95a398 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -185,10 +185,12 @@ hostname_selector () { # Setting up the locale (function). locale_selector () { read -r -p "Please insert the locale you use (format: xx_XX. Enter empty to use en_US, or type a "/" to search avaliable locales): " locale - case $kblayout in + case $locale in '') print "en_US will be used as default locale." locale="en_US.UTF-8";; - '/') sed -E '/^# +|^#$/d;s/^#| *$//g;s/ .*/ (Charset:&)/' /etc/locale.gen | less -M;; + '/') sed -E '/^# +|^#$/d;s/^#| *$//g;s/ .*/ (Charset:&)/' /etc/locale.gen | less -M + clear + locale_selector;; *) if ! grep -Fxq $locale /etc/locale.gen; then print "The specified locale doesn't exist or isn't supported." locale_selector @@ -204,6 +206,7 @@ keyboard_selector () { '') print "US keyboard layout will be used by default." kblayout="us";; '/') localectl list-keymaps + clear keyboard_selector;; *) if ! $(localectl list-keymaps | grep -Fxq $kblayout); then print "The specified keymap doesn't exist." From f281da1821e1a5a801b8921db58a51c8043f9b44 Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Thu, 28 Apr 2022 07:27:56 +0000 Subject: [PATCH 14/31] Update easy-arch.sh mainly changed functions with user input (except password-related ones since i don't know how to apply it to those) to use a different method for repeating questions to fix the issue of commands repeating if incorrect answers were given before a correct one (this is the reason why the password selection functions use while loops for incorrect answers instead of re-running the function). the method used is described in this StackExchange answer: https://unix.stackexchange.com/a/268769 --- easy-arch.sh | 95 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 37 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index d95a398..a2791c2 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -3,9 +3,23 @@ # Cleaning the TTY. clear +# Colors/formatting for echo + BOLD='\e[1m' + UNDERLINE='\e[4m' + RESET='\e[0m' # Reset text to default appearance +# High intensity colors: + BRED='\e[91m' + BGREEN='\e[92m' + BYELLOW='\e[93m' + BPURPLE='\e[95m' + # Pretty print (function). print () { - echo -e "\e[1m\e[93m[ \e[92m•\e[93m ] \e[4m$1\e[0m" + echo -e "${BOLD}${BYELLOW}[ ${BGREEN}•${BYELLOW} ] ${UNDERLINE}$1${RESET}" +} +# Alert user of bad input (function). +incEcho () { + echo -e "${BPURPLE}$1${RESET}" } # Virtualization check (function). @@ -53,15 +67,15 @@ kernel_selector () { read -r -p "Insert the number of the corresponding kernel: " kernel_choice case $kernel_choice in 1 ) kernel="linux" - ;; + return 0;; 2 ) kernel="linux-hardened" - ;; + return 0;; 3 ) kernel="linux-lts" - ;; + return 0;; 4 ) kernel="linux-zen" - ;; - * ) print "You did not enter a valid selection." - kernel_selector + return 0;; + * ) incecho "You did not enter a valid selection." + return 1 esac } @@ -75,12 +89,12 @@ network_selector () { print "5) I will do this on my own (only advanced users)" read -r -p "Insert the number of the corresponding networking utility: " network_choice if ! ((1 <= network_choice <= 5)); then - print "You did not enter a valid selection." - network_selector + incEcho "You did not enter a valid selection." + return 1 fi } -# Installing the chosen networking method to the system. +# Installing the chosen networking method to the system (function). network_installer () { case $network_choice in 1 ) print "Installing IWD." @@ -112,7 +126,7 @@ lukspass_selector () { read -r -s -p "Insert password for the LUKS container (you're not going to see the password): " password while [ -z "$password" ]; do echo - print "You need to enter a password for the LUKS Container in order to continue." + incEcho "You need to enter a password for the LUKS Container in order to continue." read -r -s -p "Insert password for the LUKS container (you're not going to see the password): " password [ -n "$password" ] && break done @@ -120,7 +134,7 @@ lukspass_selector () { read -r -s -p "Password (again): " password2 echo [ "$password" = "$password2" ] && break - echo "Passwords don't match, try again." + incEcho "Passwords don't match, try again." done } @@ -130,7 +144,7 @@ userpass_selector () { read -r -s -p "Set a user password for $username: " userpass while [ -z "$userpass" ]; do echo - print "You need to enter a password for $username." + incEcho "You need to enter a password for $username." read -r -s -p "Set a user password for $username: " userpass [ -n "$userpass" ] && break done @@ -138,7 +152,7 @@ userpass_selector () { read -r -s -p "Insert password again: " userpass2 echo [ "$userpass" = "$userpass2" ] && break - echo "Passwords don't match, try again." + incEcho "Passwords don't match, try again." done } @@ -148,7 +162,7 @@ rootpass_selector () { read -r -s -p "Set a root password: " rootpass while [ -z "$rootpass" ]; do echo - print "You need to enter a root password." + incEcho "You need to enter a root password." read -r -s -p "Set a root password: " rootpass [ -n "$rootpass" ] && break done @@ -156,7 +170,7 @@ rootpass_selector () { read -r -s -p "Password (again): " rootpass2 echo [ "$rootpass" = "$rootpass2" ] && break - echo "Passwords don't match, try again." + incEcho "Passwords don't match, try again." done } @@ -172,14 +186,14 @@ microcode_detector () { fi } -# Setting up the hostname (function). +# User chooses the hostname (function). hostname_selector () { read -r -p "Please enter the hostname: " hostname if [ -z "$hostname" ]; then - print "You need to enter a hostname in order to continue." - hostname_selector + incEcho "You need to enter a hostname in order to continue." + return 1 fi - echo "$hostname" > /mnt/etc/hostname + return 0 } # Setting up the locale (function). @@ -190,12 +204,13 @@ locale_selector () { locale="en_US.UTF-8";; '/') sed -E '/^# +|^#$/d;s/^#| *$//g;s/ .*/ (Charset:&)/' /etc/locale.gen | less -M clear - locale_selector;; + return 1;; *) if ! grep -Fxq $locale /etc/locale.gen; then - print "The specified locale doesn't exist or isn't supported." - locale_selector + incEcho "The specified locale doesn't exist or isn't supported." + return 1 fi sed -i "$locale/s/^#//" /etc/locale.gen + return 0 esac } @@ -204,16 +219,18 @@ keyboard_selector () { read -r -p "Please insert the keyboard layout you use (enter empty to use US keyboard layout, or enter "/" to search avaliable layouts): " kblayout case $kblayout in '') print "US keyboard layout will be used by default." - kblayout="us";; + kblayout="us" + return 0;; '/') localectl list-keymaps clear - keyboard_selector;; + return 1;; *) if ! $(localectl list-keymaps | grep -Fxq $kblayout); then - print "The specified keymap doesn't exist." - keyboard_selector + incEcho "The specified keymap doesn't exist." + return 1 fi print "Changing layout to $kblayout." loadkeys $kblayout + return 0 esac } @@ -222,7 +239,7 @@ keyboard_selector () { print "Welcome to easy-arch, a script made in order to simplify the process of installing Arch Linux." # Setting up keyboard layout. -keyboard_selector +until keyboard_selector; do : ; done PS3="Please select the disk NUMBER e.g. 1 where Arch Linux is going to be installed: " select ENTRY in $(lsblk -dpnoNAME|grep -P "/dev/sd|nvme|vd"); @@ -233,7 +250,8 @@ do done # Warn user about deletion of old partition scheme. -read -r -p "This will delete the current partition table on $DISK once installation starts. Do you agree [y/N]? " disk_response +echo -en "${BOLD}${UNDERLINE}${BRED}This will delete the current partition table on $DISK once installation starts. Do you agree [y/N]?${RESET} " +read -r disk_response disk_response=${disk_response,,} if ! [[ "$disk_response" =~ ^(yes|y)$ ]]; then print "Quitting." @@ -244,18 +262,18 @@ fi lukspass_selector # Setting up the kernel. -kernel_selector +until kernel_selector; do : ; done # User choses the network. -network_selector +until network_selector; do : ; done -# Setting up the locale. -locale_selector +# User choses the locale. +until locale_selector; do : ; done -# Setting up the hostname. -hostname_selector +# User choses the hostname. +until hostname_selector; do : ; done -# Setting username. +# User chooses username. read -r -p "Please enter name for a user account (enter empty to not create one): " username userpass_selector rootpass_selector @@ -324,6 +342,9 @@ echo "LANG=$locale" > /mnt/etc/locale.conf print "Installing the base system (it may take a while)." pacstrap /mnt --needed base $kernel $microcode linux-firmware $kernel-headers btrfs-progs grub grub-btrfs rsync efibootmgr snapper reflector base-devel snap-pac zram-generator >/dev/null +# Setting up the hostname. +echo "$hostname" > /mnt/etc/hostname + # Generating /etc/fstab. print "Generating a new fstab." genfstab -U /mnt >> /mnt/etc/fstab @@ -342,7 +363,7 @@ microcode_detector # Virtualization check. virt_check -# Set up the network. +# Setting up the network. network_installer # Configuring /etc/mkinitcpio.conf. From 804c2ca5093d7da76eb24bc91cca0729b4f5ea1b Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Thu, 28 Apr 2022 07:34:54 +0000 Subject: [PATCH 15/31] delete tab character and trailing whitespace accidentally used a literal tab for when defining a color instead of 4 spaces --- easy-arch.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index a2791c2..1074ee3 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -8,7 +8,7 @@ clear UNDERLINE='\e[4m' RESET='\e[0m' # Reset text to default appearance # High intensity colors: - BRED='\e[91m' + BRED='\e[91m' BGREEN='\e[92m' BYELLOW='\e[93m' BPURPLE='\e[95m' @@ -57,7 +57,7 @@ virt_check () { esac } -# Selecting a kernel to install (function). +# Selecting a kernel to install (function). kernel_selector () { print "List of kernels:" print "1) Stable: Vanilla Linux kernel with a few specific Arch Linux patches applied" @@ -79,7 +79,7 @@ kernel_selector () { esac } -# Selecting a way to handle internet connection (function). +# Selecting a way to handle internet connection (function). network_selector () { print "Network utilities:" print "1) IWD: iNet wireless daemon is a wireless daemon for Linux written by Intel (WiFi-only)" @@ -232,7 +232,7 @@ keyboard_selector () { loadkeys $kblayout return 0 esac - + } # Selecting the target for the installation. @@ -378,25 +378,25 @@ print "Setting up grub config." UUID=$(blkid -s UUID -o value $CRYPTROOT) sed -i "s,^GRUB_CMDLINE_LINUX=\",&rd.luks.name=$UUID=cryptroot root=$BTRFS\",g" /mnt/etc/default/grub -# Configuring the system. +# Configuring the system. arch-chroot /mnt /bin/bash -e </dev/null - + # Setting up clock. echo "Setting up the system clock." hwclock --systohc - + # Generating locales. echo "Generating locales." locale-gen &>/dev/null - + # Generating a new initramfs. echo "Creating a new initramfs." mkinitcpio -P &>/dev/null - + # Snapper configuration echo "Configuring Snapper." umount /.snapshots @@ -406,7 +406,7 @@ arch-chroot /mnt /bin/bash -e </dev/null @@ -426,7 +426,7 @@ if [ -n "$username" ]; then print "Adding the user $username to the system with root privilege." arch-chroot /mnt useradd -m -G wheel -s /bin/bash "$username" sed -i '/%wheel ALL=(ALL) ALL/s/^# //' /mnt/etc/sudoers - print "Setting user password for $username." + print "Setting user password for $username." echo "$username:$userpass" | arch-chroot /mnt chpasswd fi From c6d418995d68b78d3656c25b59a4f3f7b4c48f40 Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Thu, 28 Apr 2022 07:56:10 +0000 Subject: [PATCH 16/31] Update easy-arch.sh changed some comments/prompts to make more sense and make it more obvious that the keyboard layout chosen is only for the console and won't apply in a graphical environment. --- easy-arch.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index 1074ee3..4488486 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -120,7 +120,7 @@ network_installer () { esac } -# Setting up a password for the LUKS Container (function). +# User enters a password for the LUKS Container (function). lukspass_selector () { while true; do read -r -s -p "Insert password for the LUKS container (you're not going to see the password): " password @@ -138,7 +138,7 @@ lukspass_selector () { done } -# Setting up a password for the user account (function). +# User enters a password for the user account (function). userpass_selector () { while true; do read -r -s -p "Set a user password for $username: " userpass @@ -156,7 +156,7 @@ userpass_selector () { done } -# Setting up a password for the root account (function). +# User enters a password for the root account (function). rootpass_selector () { while true; do read -r -s -p "Set a root password: " rootpass @@ -186,7 +186,7 @@ microcode_detector () { fi } -# User chooses the hostname (function). +# User enters a hostname (function). hostname_selector () { read -r -p "Please enter the hostname: " hostname if [ -z "$hostname" ]; then @@ -196,9 +196,9 @@ hostname_selector () { return 0 } -# Setting up the locale (function). +# User chooses the locale (function). locale_selector () { - read -r -p "Please insert the locale you use (format: xx_XX. Enter empty to use en_US, or type a "/" to search avaliable locales): " locale + read -r -p "Please insert the locale you use (format: xx_XX. Enter empty to use en_US, or "/" to search locales): " locale case $locale in '') print "en_US will be used as default locale." locale="en_US.UTF-8";; @@ -214,11 +214,11 @@ locale_selector () { esac } -# Setting up the keyboard layout (function). +# User chooses the console keyboard layout (function). keyboard_selector () { - read -r -p "Please insert the keyboard layout you use (enter empty to use US keyboard layout, or enter "/" to search avaliable layouts): " kblayout + read -r -p "Please insert the keyboard keymap/layout to use in console (enter empty to use us, or "/" to search keymaps): " kblayout case $kblayout in - '') print "US keyboard layout will be used by default." + '') print "The us keymap will be used in console by default." kblayout="us" return 0;; '/') localectl list-keymaps @@ -228,7 +228,7 @@ keyboard_selector () { incEcho "The specified keymap doesn't exist." return 1 fi - print "Changing layout to $kblayout." + print "Changing console layout to $kblayout." loadkeys $kblayout return 0 esac From 4ee0ffabdda8037a368fec482110be4cd0bf6974 Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Thu, 28 Apr 2022 08:05:54 +0000 Subject: [PATCH 17/31] typo in subvol creation --- easy-arch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy-arch.sh b/easy-arch.sh index 4488486..515e6b2 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -317,7 +317,7 @@ mount $BTRFS /mnt print "Creating BTRFS subvolumes." subvols=(snapshots var_pkgs var_log home root srv) for subvol in '' ${subvols[@]}; do - btrfs su cr /mnt/@$volume + btrfs su cr /mnt/@$subvol done # Mounting the newly created subvolumes. From ea300d55609b06da55760d5f55eed08eb8a1f1ab Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Thu, 28 Apr 2022 09:50:30 +0000 Subject: [PATCH 18/31] fix locales, shorten virt_check, change some prompts, fix incEcho typo --- easy-arch.sh | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index 515e6b2..01f42f3 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -52,8 +52,6 @@ virt_check () { systemctl enable hv_fcopy_daemon --root=/mnt &>/dev/null systemctl enable hv_kvp_daemon --root=/mnt &>/dev/null systemctl enable hv_vss_daemon --root=/mnt &>/dev/null - ;; - * ) ;; esac } @@ -74,7 +72,7 @@ kernel_selector () { return 0;; 4 ) kernel="linux-zen" return 0;; - * ) incecho "You did not enter a valid selection." + * ) incEcho "You did not enter a valid selection." return 1 esac } @@ -209,7 +207,6 @@ locale_selector () { incEcho "The specified locale doesn't exist or isn't supported." return 1 fi - sed -i "$locale/s/^#//" /etc/locale.gen return 0 esac } @@ -241,16 +238,16 @@ print "Welcome to easy-arch, a script made in order to simplify the process of i # Setting up keyboard layout. until keyboard_selector; do : ; done -PS3="Please select the disk NUMBER e.g. 1 where Arch Linux is going to be installed: " +PS3="Please select the disk NUMBER (e.g. 1) where Arch Linux is going to be installed: " select ENTRY in $(lsblk -dpnoNAME|grep -P "/dev/sd|nvme|vd"); do DISK=$ENTRY - print "Installing Arch Linux on $DISK." + print "Arch Linux will be installed to $DISK." break done # Warn user about deletion of old partition scheme. -echo -en "${BOLD}${UNDERLINE}${BRED}This will delete the current partition table on $DISK once installation starts. Do you agree [y/N]?${RESET} " +echo -en "${BOLD}${UNDERLINE}${BRED}This will delete the current partition table on $DISK once installation starts. Do you agree [y/N]?:${RESET} " read -r disk_response disk_response=${disk_response,,} if ! [[ "$disk_response" =~ ^(yes|y)$ ]]; then @@ -334,10 +331,6 @@ mount -o $mountopts,subvol=@var_pkgs $BTRFS /mnt/var/cache/pacman/pkg chattr +C /mnt/var/log mount $ESP /mnt/boot/ -# Configure selected keyboard layout and locale -echo "KEYMAP=$kblayout" > /mnt/etc/vconsole.conf -echo "LANG=$locale" > /mnt/etc/locale.conf - # Pacstrap (setting up a base sytem onto the new root). print "Installing the base system (it may take a while)." pacstrap /mnt --needed base $kernel $microcode linux-firmware $kernel-headers btrfs-progs grub grub-btrfs rsync efibootmgr snapper reflector base-devel snap-pac zram-generator >/dev/null @@ -349,6 +342,11 @@ echo "$hostname" > /mnt/etc/hostname print "Generating a new fstab." genfstab -U /mnt >> /mnt/etc/fstab +# Configure selected locale and console keymap +sed -i "s/^#$locale/$locale/" /mnt/etc/locale.gen +echo "LANG=$locale" > /mnt/etc/locale.conf +echo "KEYMAP=$kblayout" > /mnt/etc/vconsole.conf + # Setting hosts file. print "Setting hosts file." cat > /mnt/etc/hosts < Date: Thu, 28 Apr 2022 10:10:30 +0000 Subject: [PATCH 19/31] change permissions of /mnt/root from 755 to 750 --- easy-arch.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/easy-arch.sh b/easy-arch.sh index 01f42f3..650fa6a 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -326,6 +326,7 @@ mkdir -p /mnt/{home,root,srv,.snapshots,var/{log,cache/pacman/pkg},boot} for subvol in ${subvols[@]:2}; do # ":2" excludes first two subvols (@snapshots and @var_pkgs) from loop mount -o $mountopts,subvol=@$subvol $BTRFS /mnt/$(sed 's,_,/,g' <<< $subvol) done +chmod -R 750 /mnt/root mount -o $mountopts,subvol=@snapshots $BTRFS /mnt/.snapshots mount -o $mountopts,subvol=@var_pkgs $BTRFS /mnt/var/cache/pacman/pkg chattr +C /mnt/var/log From 1375897e53b043d916a87f904e37a4e0e2974a10 Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Thu, 28 Apr 2022 23:59:40 +0000 Subject: [PATCH 20/31] fix sudoers and pacman.conf sed expressions the paralleldownloads sed in 2fb11db changes the value without actually uncommenting it, and the change the the "Color" sed in adds ILoveCandy without actually uncommenting Color. also made the color regex match "^#Color$" instead of "#Color" to make it more specific --- easy-arch.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index 650fa6a..1569ff4 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -424,7 +424,7 @@ echo "root:$rootpass" | arch-chroot /mnt chpasswd if [ -n "$username" ]; then print "Adding the user $username to the system with root privilege." arch-chroot /mnt useradd -m -G wheel -s /bin/bash "$username" - sed -i '/%wheel ALL=(ALL) ALL/s/^# //' /mnt/etc/sudoers + sed -i '/^ #%wheel ALL=(ALL) ALL/s/^ #//' /mnt/etc/sudoers print "Setting user password for $username." echo "$username:$userpass" | arch-chroot /mnt chpasswd fi @@ -456,7 +456,7 @@ EOF # Pacman eye-candy features. print "Enabling colours, animations, and parallel in pacman." -sed -i '/^#ParallelDownloads/s/=.*/= 10/;/#Color/a ILoveCandy' /mnt/etc/pacman.conf +sed -i 's/#Color/Color\nILoveCandy/;s/^#ParallelDownloads.*/ParallelDownloads = 10/' /mnt/etc/pacman.conf # Enabling various services. print "Enabling Reflector, automatic snapshots, BTRFS scrubbing and systemd-oomd." From 540a503f287b14ad280d6b3ecbf2975f0cf7eae1 Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Fri, 29 Apr 2022 00:01:50 +0000 Subject: [PATCH 21/31] fix last commit didnt actually fix the sudoers expression... --- easy-arch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy-arch.sh b/easy-arch.sh index 1569ff4..3dd000a 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -424,7 +424,7 @@ echo "root:$rootpass" | arch-chroot /mnt chpasswd if [ -n "$username" ]; then print "Adding the user $username to the system with root privilege." arch-chroot /mnt useradd -m -G wheel -s /bin/bash "$username" - sed -i '/^ #%wheel ALL=(ALL) ALL/s/^ #//' /mnt/etc/sudoers + sed -i '/^# %wheel ALL=(ALL) ALL/s/^# //' /mnt/etc/sudoers print "Setting user password for $username." echo "$username:$userpass" | arch-chroot /mnt chpasswd fi From 632d40c5c534d7b3154faf1275e2514c5adb275a Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Fri, 29 Apr 2022 00:07:19 +0000 Subject: [PATCH 22/31] forgot to do in 1375897 said that I changed the Color sed to match "1375897" but then didnt actually change it --- easy-arch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy-arch.sh b/easy-arch.sh index 3dd000a..5da45fa 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -456,7 +456,7 @@ EOF # Pacman eye-candy features. print "Enabling colours, animations, and parallel in pacman." -sed -i 's/#Color/Color\nILoveCandy/;s/^#ParallelDownloads.*/ParallelDownloads = 10/' /mnt/etc/pacman.conf +sed -i 's/^#Color$/Color\nILoveCandy/;s/^#ParallelDownloads.*/ParallelDownloads = 10/' /mnt/etc/pacman.conf # Enabling various services. print "Enabling Reflector, automatic snapshots, BTRFS scrubbing and systemd-oomd." From c06241dc46e16d549c2049c3fa6e31b0451aba8f Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Fri, 29 Apr 2022 05:11:52 +0000 Subject: [PATCH 23/31] fix unescaped quotes, etc for syntax check --- easy-arch.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index 5da45fa..4689c53 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -196,7 +196,7 @@ hostname_selector () { # User chooses the locale (function). locale_selector () { - read -r -p "Please insert the locale you use (format: xx_XX. Enter empty to use en_US, or "/" to search locales): " locale + read -r -p "Please insert the locale you use (format: xx_XX. Enter empty to use en_US, or \"/\" to search locales): " locale case $locale in '') print "en_US will be used as default locale." locale="en_US.UTF-8";; @@ -213,7 +213,7 @@ locale_selector () { # User chooses the console keyboard layout (function). keyboard_selector () { - read -r -p "Please insert the keyboard keymap/layout to use in console (enter empty to use us, or "/" to search keymaps): " kblayout + read -r -p "Please insert the keyboard keymap/layout to use in console (enter empty to use us, or \"/\" to search keymaps): " kblayout case $kblayout in '') print "The us keymap will be used in console by default." kblayout="us" @@ -221,7 +221,7 @@ keyboard_selector () { '/') localectl list-keymaps clear return 1;; - *) if ! $(localectl list-keymaps | grep -Fxq $kblayout); then + *) if ! localectl list-keymaps | grep -Fxq $kblayout; then incEcho "The specified keymap doesn't exist." return 1 fi @@ -313,8 +313,8 @@ mount $BTRFS /mnt # Creating BTRFS subvolumes. print "Creating BTRFS subvolumes." subvols=(snapshots var_pkgs var_log home root srv) -for subvol in '' ${subvols[@]}; do - btrfs su cr /mnt/@$subvol +for subvol in '' "${subvols[@]}"; do + btrfs su cr /mnt/@"$subvol" done # Mounting the newly created subvolumes. @@ -323,8 +323,8 @@ print "Mounting the newly created subvolumes." mountopts="ssd,noatime,compress-force=zstd:3,discard=async" mount -o $mountopts,subvol=@ $BTRFS /mnt mkdir -p /mnt/{home,root,srv,.snapshots,var/{log,cache/pacman/pkg},boot} -for subvol in ${subvols[@]:2}; do # ":2" excludes first two subvols (@snapshots and @var_pkgs) from loop -mount -o $mountopts,subvol=@$subvol $BTRFS /mnt/$(sed 's,_,/,g' <<< $subvol) +for subvol in "${subvols[@]:2}"; do # ":2" excludes first two subvols (@snapshots and @var_pkgs) from loop +mount -o "$mountopts",subvol=@"$subvol" "$BTRFS" /mnt/$(sed 's,_,/,g' <<< "$subvol") done chmod -R 750 /mnt/root mount -o $mountopts,subvol=@snapshots $BTRFS /mnt/.snapshots From 31acfd3b0c0731c7923427f4b3cdef089f323531 Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Fri, 29 Apr 2022 05:13:51 +0000 Subject: [PATCH 24/31] Update easy-arch.sh --- easy-arch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy-arch.sh b/easy-arch.sh index 4689c53..fab4f71 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -324,7 +324,7 @@ mountopts="ssd,noatime,compress-force=zstd:3,discard=async" mount -o $mountopts,subvol=@ $BTRFS /mnt mkdir -p /mnt/{home,root,srv,.snapshots,var/{log,cache/pacman/pkg},boot} for subvol in "${subvols[@]:2}"; do # ":2" excludes first two subvols (@snapshots and @var_pkgs) from loop -mount -o "$mountopts",subvol=@"$subvol" "$BTRFS" /mnt/$(sed 's,_,/,g' <<< "$subvol") +mount -o "$mountopts",subvol=@"$subvol" "$BTRFS" /mnt/"$(sed 's,_,/,g' <<< "$subvol")" done chmod -R 750 /mnt/root mount -o $mountopts,subvol=@snapshots $BTRFS /mnt/.snapshots From fd49d164de4231fbf6ef113a68298f366ea6f331 Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Fri, 29 Apr 2022 06:21:43 +0000 Subject: [PATCH 25/31] fix locale existence check shouldn't be using the -x option since locales always appear with the charset on the same line, making matches impossible. Also removed -F since some regex is needed to ensure only locales are matched, and added a sed to escape regex characters in $locale before its sent to grep so the user can't type something like "e." and match the "eo" locale accidentally. --- easy-arch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy-arch.sh b/easy-arch.sh index fab4f71..df8ff91 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -203,7 +203,7 @@ locale_selector () { '/') sed -E '/^# +|^#$/d;s/^#| *$//g;s/ .*/ (Charset:&)/' /etc/locale.gen | less -M clear return 1;; - *) if ! grep -Fxq $locale /etc/locale.gen; then + *) if ! grep -q "^#\?$(sed 's/[].*[]/\\&/g' <<< $locale) " /etc/locale.gen; then incEcho "The specified locale doesn't exist or isn't supported." return 1 fi From e6daa6f659bbcd180a51a4df895611cae01a08be Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Fri, 29 Apr 2022 07:23:28 +0000 Subject: [PATCH 26/31] remove -R flag from /mnt/root chmod, fix grub sed from 7797b19 grub's sed change in 7797b19 caused the kernel parameters to be enclosed in 3 quotes instead of 2. this fixes it (first delimiter has to be escaped if not /; see GNU sed manual section 4.3) --- easy-arch.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index df8ff91..27e3353 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -326,7 +326,7 @@ mkdir -p /mnt/{home,root,srv,.snapshots,var/{log,cache/pacman/pkg},boot} for subvol in "${subvols[@]:2}"; do # ":2" excludes first two subvols (@snapshots and @var_pkgs) from loop mount -o "$mountopts",subvol=@"$subvol" "$BTRFS" /mnt/"$(sed 's,_,/,g' <<< "$subvol")" done -chmod -R 750 /mnt/root +chmod 750 /mnt/root mount -o $mountopts,subvol=@snapshots $BTRFS /mnt/.snapshots mount -o $mountopts,subvol=@var_pkgs $BTRFS /mnt/var/cache/pacman/pkg chattr +C /mnt/var/log @@ -375,7 +375,7 @@ EOF # Setting up LUKS2 encryption in grub. print "Setting up grub config." UUID=$(blkid -s UUID -o value $CRYPTROOT) -sed -i "s,^GRUB_CMDLINE_LINUX=\",&rd.luks.name=$UUID=cryptroot root=$BTRFS\",g" /mnt/etc/default/grub +sed -i "\,^GRUB_CMDLINE_LINUX=\"\",s,\",&rd.luks.name=$UUID=cryptroot root=$BTRFS," /mnt/etc/default/grub # Configuring the system. arch-chroot /mnt /bin/bash -e < Date: Fri, 29 Apr 2022 08:31:29 +0000 Subject: [PATCH 27/31] remove underline text formatting from script if the script is being run in the live arch iso's terminal and not through ssh, text underlines don't appear and the text just becomes blue, so they've been removed to make the appearance on both more alike. --- easy-arch.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index 27e3353..ebddd9b 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -5,7 +5,6 @@ clear # Colors/formatting for echo BOLD='\e[1m' - UNDERLINE='\e[4m' RESET='\e[0m' # Reset text to default appearance # High intensity colors: BRED='\e[91m' @@ -15,7 +14,7 @@ clear # Pretty print (function). print () { - echo -e "${BOLD}${BYELLOW}[ ${BGREEN}•${BYELLOW} ] ${UNDERLINE}$1${RESET}" + echo -e "${BOLD}${BYELLOW}[ ${BGREEN}•${BYELLOW} ] $1${RESET}" } # Alert user of bad input (function). incEcho () { @@ -247,7 +246,7 @@ do done # Warn user about deletion of old partition scheme. -echo -en "${BOLD}${UNDERLINE}${BRED}This will delete the current partition table on $DISK once installation starts. Do you agree [y/N]?:${RESET} " +echo -en "${BOLD}${BRED}This will delete the current partition table on $DISK once installation starts. Do you agree [y/N]?:${RESET} " read -r disk_response disk_response=${disk_response,,} if ! [[ "$disk_response" =~ ^(yes|y)$ ]]; then From 4c5ea199c457dc7b52a81b35823976c5c831f2e3 Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Fri, 29 Apr 2022 08:44:25 +0000 Subject: [PATCH 28/31] use bash var sub instead of sed --- easy-arch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy-arch.sh b/easy-arch.sh index ebddd9b..7d59636 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -323,7 +323,7 @@ mountopts="ssd,noatime,compress-force=zstd:3,discard=async" mount -o $mountopts,subvol=@ $BTRFS /mnt mkdir -p /mnt/{home,root,srv,.snapshots,var/{log,cache/pacman/pkg},boot} for subvol in "${subvols[@]:2}"; do # ":2" excludes first two subvols (@snapshots and @var_pkgs) from loop -mount -o "$mountopts",subvol=@"$subvol" "$BTRFS" /mnt/"$(sed 's,_,/,g' <<< "$subvol")" +mount -o "$mountopts",subvol=@"$subvol" "$BTRFS" /mnt/"${subvol//_//}" done chmod 750 /mnt/root mount -o $mountopts,subvol=@snapshots $BTRFS /mnt/.snapshots From c07aee4269688172b45baa4c774bb1f0ab344d32 Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Fri, 29 Apr 2022 12:12:50 +0000 Subject: [PATCH 29/31] change pass creation funcs to new repeating method changes functions prompting the user to create passwords to use the new method for repeating questions from f281da1. also changed the message given after choosing the default locale to be shorter/more accurate. --- easy-arch.sh | 83 +++++++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index 7d59636..0b8dae6 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -119,56 +119,53 @@ network_installer () { # User enters a password for the LUKS Container (function). lukspass_selector () { - while true; do - read -r -s -p "Insert password for the LUKS container (you're not going to see the password): " password - while [ -z "$password" ]; do - echo - incEcho "You need to enter a password for the LUKS Container in order to continue." - read -r -s -p "Insert password for the LUKS container (you're not going to see the password): " password - [ -n "$password" ] && break - done - echo - read -r -s -p "Password (again): " password2 - echo - [ "$password" = "$password2" ] && break + read -r -s -p "Insert password for the LUKS container (you're not going to see the password): " password + if [ -z "$password" ]; then + incEcho "\nYou need to enter a password for the LUKS Container in order to continue." + return 1 + fi + echo + read -r -s -p "Password (again): " password2 + echo + if [ "$password" != "$password2" ]; then incEcho "Passwords don't match, try again." - done + return 1 + fi + return 0 } # User enters a password for the user account (function). userpass_selector () { - while true; do - read -r -s -p "Set a user password for $username: " userpass - while [ -z "$userpass" ]; do - echo - incEcho "You need to enter a password for $username." - read -r -s -p "Set a user password for $username: " userpass - [ -n "$userpass" ] && break - done - echo - read -r -s -p "Insert password again: " userpass2 - echo - [ "$userpass" = "$userpass2" ] && break + read -r -s -p "Set a user password for $username: " userpass + if [ -z "$userpass" ]; then + incEcho "\nYou need to enter a password for $username." + return 1 + fi + echo + read -r -s -p "Insert password again: " userpass2 + echo + if [ "$userpass" != "$userpass2" ]; then incEcho "Passwords don't match, try again." - done + return 1 + fi + return 0 } # User enters a password for the root account (function). rootpass_selector () { - while true; do - read -r -s -p "Set a root password: " rootpass - while [ -z "$rootpass" ]; do - echo - incEcho "You need to enter a root password." - read -r -s -p "Set a root password: " rootpass - [ -n "$rootpass" ] && break - done - echo - read -r -s -p "Password (again): " rootpass2 - echo - [ "$rootpass" = "$rootpass2" ] && break + read -r -s -p "Set a root password: " rootpass + if [ -z "$rootpass" ]; then + incEcho "\nYou need to enter a root password." + return 1 + fi + echo + read -r -s -p "Password (again): " rootpass2 + echo + if [ "$rootpass" != "$rootpass2" ]; then incEcho "Passwords don't match, try again." - done + return 1 + fi + return 0 } # Microcode detector (function). @@ -197,7 +194,7 @@ hostname_selector () { locale_selector () { read -r -p "Please insert the locale you use (format: xx_XX. Enter empty to use en_US, or \"/\" to search locales): " locale case $locale in - '') print "en_US will be used as default locale." + '') print "en_US.UTF-8 will be the default locale." locale="en_US.UTF-8";; '/') sed -E '/^# +|^#$/d;s/^#| *$//g;s/ .*/ (Charset:&)/' /etc/locale.gen | less -M clear @@ -255,7 +252,7 @@ if ! [[ "$disk_response" =~ ^(yes|y)$ ]]; then fi # Setting up LUKS password. -lukspass_selector +until lukspass_selector; do : ; done # Setting up the kernel. until kernel_selector; do : ; done @@ -271,8 +268,8 @@ until hostname_selector; do : ; done # User chooses username. read -r -p "Please enter name for a user account (enter empty to not create one): " username -userpass_selector -rootpass_selector +until userpass_selector; do : ; done +until rootpass_selector; do : ; done # Deleting old partition scheme. print "Wiping $DISK." From 0b6c961e724e6a98b176404efb042c3a5f55660d Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Fri, 29 Apr 2022 22:17:15 +0000 Subject: [PATCH 30/31] use layout/locale vars in print for default choice also added 2 missing return 0's and replaced the tabs my editor keeps adding in --- easy-arch.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index 0b8dae6..c420aed 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -89,6 +89,7 @@ network_selector () { incEcho "You did not enter a valid selection." return 1 fi + return 0 } # Installing the chosen networking method to the system (function). @@ -131,7 +132,7 @@ lukspass_selector () { incEcho "Passwords don't match, try again." return 1 fi - return 0 + return 0 } # User enters a password for the user account (function). @@ -148,7 +149,7 @@ userpass_selector () { incEcho "Passwords don't match, try again." return 1 fi - return 0 + return 0 } # User enters a password for the root account (function). @@ -165,7 +166,7 @@ rootpass_selector () { incEcho "Passwords don't match, try again." return 1 fi - return 0 + return 0 } # Microcode detector (function). @@ -194,8 +195,9 @@ hostname_selector () { locale_selector () { read -r -p "Please insert the locale you use (format: xx_XX. Enter empty to use en_US, or \"/\" to search locales): " locale case $locale in - '') print "en_US.UTF-8 will be the default locale." - locale="en_US.UTF-8";; + '') locale="en_US.UTF-8" + print "$locale will be the default locale." + return 0;; '/') sed -E '/^# +|^#$/d;s/^#| *$//g;s/ .*/ (Charset:&)/' /etc/locale.gen | less -M clear return 1;; @@ -211,8 +213,8 @@ locale_selector () { keyboard_selector () { read -r -p "Please insert the keyboard keymap/layout to use in console (enter empty to use us, or \"/\" to search keymaps): " kblayout case $kblayout in - '') print "The us keymap will be used in console by default." - kblayout="us" + '') kblayout="us" + print "$kblayout will be the default console keymap." return 0;; '/') localectl list-keymaps clear @@ -245,8 +247,7 @@ done # Warn user about deletion of old partition scheme. echo -en "${BOLD}${BRED}This will delete the current partition table on $DISK once installation starts. Do you agree [y/N]?:${RESET} " read -r disk_response -disk_response=${disk_response,,} -if ! [[ "$disk_response" =~ ^(yes|y)$ ]]; then +if ! [[ "${disk_response,,}" =~ ^(yes|y)$ ]]; then print "Quitting." exit fi From e82ced1bd9d337e87c23b3c6a5e376630c788003 Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Mon, 2 May 2022 06:21:33 +0000 Subject: [PATCH 31/31] shorten some seds --- easy-arch.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy-arch.sh b/easy-arch.sh index c420aed..8682043 100755 --- a/easy-arch.sh +++ b/easy-arch.sh @@ -341,7 +341,7 @@ print "Generating a new fstab." genfstab -U /mnt >> /mnt/etc/fstab # Configure selected locale and console keymap -sed -i "s/^#$locale/$locale/" /mnt/etc/locale.gen +sed -i "/^#$locale/s/^#//" /mnt/etc/locale.gen echo "LANG=$locale" > /mnt/etc/locale.conf echo "KEYMAP=$kblayout" > /mnt/etc/vconsole.conf @@ -453,7 +453,7 @@ EOF # Pacman eye-candy features. print "Enabling colours, animations, and parallel in pacman." -sed -i 's/^#Color$/Color\nILoveCandy/;s/^#ParallelDownloads.*/ParallelDownloads = 10/' /mnt/etc/pacman.conf +sed -Ei 's/^#(Color)$/\1\nILoveCandy/;s/^#(ParallelDownloads).*/\1 = 10/' /mnt/etc/pacman.conf # Enabling various services. print "Enabling Reflector, automatic snapshots, BTRFS scrubbing and systemd-oomd."