diff --git a/setup.sh b/setup.sh index e6149c1..888ef5d 100644 --- a/setup.sh +++ b/setup.sh @@ -289,13 +289,6 @@ function copy_zpool_cache () { zpool set 'cachefile=/etc/zfs/'"${zpool_name}"'.cache' "${zpool_name}" } -function pacman_dl_parallel () { - #2.4 - # We're setting this in Arch Linux ISO CD while we install proper Arch. - # No need to revert this later as it is ephemeral anyway. - sed -ri -e 's'$'\x1''^.*?(ParallelDownloads)[^\r\n\f]*'$'\x1''\1 = 20'$'\x1''g' '/etc/pacman.conf' -} - function pacman_dont_check_space () { # See pacman bug comment # https://bugs.archlinux.org/task/45070#comment142712 @@ -406,13 +399,6 @@ function add_zfs_files_to_new_os () { done } -function enter_chroot () { - #2.1 - arch-chroot /mnt /bin/bash -xe < "${path_unit}" <<"EOF" +[Unit] +Description=chmod initramfs to be root-read-writable only + +[Path] +PathChanged=/boot/initramfs-linux.img + +[Install] +WantedBy=multi-user.target +WantedBy=system-update.target +EOF + + cat > "${service_unit}" <<"EOF" +[Unit] +Description=chmod initramfs to be root-read-writable only + +[Service] +Type=oneshot +ExecStart=/usr/bin/chmod 600 /boot/initramfs-linux.img +EOF + + systemctl enable "${path_unit}" +} + +function pacman_dl_parallel () { + #2.4 + # We're setting this in Arch Linux ISO CD while we install proper Arch. + # No need to revert this later as it is ephemeral anyway. + sed -ri -e 's'$'\x1''^.*?(ParallelDownloads)[^\r\n\f]*'$'\x1''\1 = 20'$'\x1''g' '/etc/pacman.conf' +} + function unleash_makepkg () { #2.5 local path_prefix @@ -436,6 +468,25 @@ function unleash_makepkg () { "${path_prefix}"'/etc/makepkg.conf' } +function add_motd_getting_started_msg () { + #2.6 + cat > '/etc/motd' <<"EOF" + +#################### + +GUI basics: + + paru -S xorg plasma-meta kde-applications-meta sddm + localectl set-x11-keymap de + useradd --create-home --shell /bin/bash --user-group --groups wheel + passwd + systemctl enable --now sddm.service + +#################### + +EOF +} + function get_aur_helper () { #2.7 create_unpriv_user 'build' @@ -519,55 +570,17 @@ EOF zfs set org.zfsbootmenu:commandline='rw nowatchdog rd.vconsole.keymap=de-latin1' "${zpool_name}"'/root/'"${zfs_arch_dataset_name}" } -function keep_initiramfs_root_only_rw () { - #2.3 - declare systemd_local_admin_override_path unit_name - systemd_local_admin_override_path='/etc/systemd/system' - unit_name='chmod-initramfs' - path_unit="${systemd_local_admin_override_path%/}"'/'"${unit_name}"'.path' - service_unit="${systemd_local_admin_override_path%/}"'/'"${unit_name}"'.service' - - cat > "${path_unit}" <<"EOF" -[Unit] -Description=chmod initramfs to be root-read-writable only - -[Path] -PathChanged=/boot/initramfs-linux.img - -[Install] -WantedBy=multi-user.target -WantedBy=system-update.target -EOF - - cat > "${service_unit}" <<"EOF" -[Unit] -Description=chmod initramfs to be root-read-writable only - -[Service] -Type=oneshot -ExecStart=/usr/bin/chmod 600 /boot/initramfs-linux.img -EOF - - systemctl enable "${path_unit}" -} - -function add_motd_getting_started_msg () { - #2.6 - cat > '/etc/motd' <<"EOF" - -#################### - -GUI basics: - - paru -S xorg plasma-meta kde-applications-meta sddm - localectl set-x11-keymap de - useradd --create-home --shell /bin/bash --user-group --groups wheel - passwd - systemctl enable --now sddm.service - -#################### - -EOF +function get_disks_with_one_efipart () { + local disks_with_one_efipart + # Find disks that have exactly one EFI partition and where that EFI + # partition is partition number 1. We expect exactly one disk to meet + # these criteria. Anything else and we bail. + disks_with_one_efipart="$(lsblk --output PATH,PARTTYPE --json --tree | jq --raw-output '.[][] | select(.children | length > 0) | select( any (.children[]; (.path | test("^[^[:digit:]]+1")) and (.parttype=="c12a7328-f81f-11d2-ba4b-00a0c93ec93b")) and ([select(.children[].parttype=="c12a7328-f81f-11d2-ba4b-00a0c93ec93b")] | length == 1) ) | .path')" + if [[ "$(wc -l <<<"${disks_with_one_efipart}")" -eq '1' ]] && [[ "$(wc -c <<<"${disks_with_one_efipart}")" -gt '1' ]]; then + printf -- '%s' "${disks_with_one_efipart}" + return 0 + fi + return 1 } function install_os_in_chroot () {