From 0dca8f7d8c8104e30af50d0c214003ade4bad5a0 Mon Sep 17 00:00:00 2001 From: mfgbhatti Date: Sat, 12 Feb 2022 22:36:58 +0000 Subject: [PATCH] minor updates and bootloaders --- 0-preinstall.sh | 5 ++- 1-setup.sh | 94 +++++++++++++++++++++++++++++++++++++++++-------- archtitus.sh | 2 +- startup.sh | 28 +++++++++++---- 4 files changed, 105 insertions(+), 24 deletions(-) diff --git a/0-preinstall.sh b/0-preinstall.sh index 2ee1961..fb621ec 100755 --- a/0-preinstall.sh +++ b/0-preinstall.sh @@ -155,7 +155,7 @@ else PART1=${DISK}1 PART2=${DISK}2 fi -_PART_UUID=$(blkid -s UUID -o value "$PART2") + if [[ "$LAYOUT" -eq 1 ]]; then do_partition @@ -186,7 +186,7 @@ elif [[ "$LUKS" -eq 1 ]]; then do_lvm lvm_mount mount_boot - set_option "ENCRYP_PART" "$_PART_UUID" + # set_option "ENCRYP_PART" "$_PART_UUID" # HOOKS=(base udev autodetect modconf block filesystems keyboard fsck) set_option "HOOKS" "(base udev autodetect keyboard keymap consolefont modconf block encrypt filesystems fsck)" @@ -225,7 +225,6 @@ genfstab -U "$MOUNTPOINT" >>"$MOUNTPOINT"/etc/fstab cp -R "${SCRIPT_DIR}" "$MOUNTPOINT"/root/ArchTitus cp /etc/pacman.d/mirrorlist "$MOUNTPOINT"/etc/pacman.d/mirrorlist - # TOTALMEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*') TOTALMEM="$(grep -i "memtotal" "/proc/meminfo" | grep -o '[[:digit:]]*')" if [[ $TOTALMEM -lt 8000000 ]]; then diff --git a/1-setup.sh b/1-setup.sh index 635d2c7..c70e939 100755 --- a/1-setup.sh +++ b/1-setup.sh @@ -12,32 +12,31 @@ fi title basic installations install_pkg networkmanager dhclient reflector \ - rsync grub btrfs-progs arch-install-scripts \ + rsync btrfs-progs arch-install-scripts \ git pacman-contrib curl -title Network Setup +echo "Network Setup" systemctl enable --now NetworkManager install_xorg() { install_pkg "xorg xorg-server" } +TOTALMEM="$(grep -i "memtotal" "/proc/meminfo" | grep -o '[[:digit:]]*')" CPU="$(grep -c ^processor /proc/cpuinfo)" -echo -ne " +if [[ $TOTALMEM -gt 8000000 ]]; then + echo -ne " ------------------------------------------------------------------------- You have \"$CPU\" cores. And changing the makeflags for \"$CPU\" cores. As well as changing the compression settings. ------------------------------------------------------------------------- " - -TOTALMEM="$(grep -i "memtotal" "/proc/meminfo" | grep -o '[[:digit:]]*')" -if [[ $TOTALMEM -gt 8000000 ]]; then sed -i "s/#MAKEFLAGS=\"-j2\"/MAKEFLAGS=\"-j$CPU\"/g" /etc/makepkg.conf sed -i "s/COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -T $CPU -z -)/g" /etc/makepkg.conf fi -title Setup Language and set locale +echo "Setup Language and set locale" # sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen echo "$LOCALE" | sed -i "s/\"//g" >>/etc/locale.gen @@ -59,7 +58,7 @@ sed -i "/\[multilib\]/,/Include/"'s/^#//' /etc/pacman.conf # pacman -Sy --noconfirm refresh_pacman -title Installing desktop +echo "Installing desktop" case "$DESKTOP" in "default") while IFS= read -r LINE; do @@ -127,7 +126,7 @@ case "$DESKTOP" in esac -title Installing Microcode +echo "Installing Microcode" # determine processor type and install microcode PROC_TYPE="$(lscpu | grep "Vendor ID:" | awk '{print $3}')" @@ -135,30 +134,97 @@ case "$PROC_TYPE" in "GenuineIntel") echo "Installing Intel microcode" install_pkg intel-ucode + IMG=intel-ucode.img ;; "AuthenticAMD") echo "Installing AMD microcode" install_pkg amd-ucode + IMG=amd-ucode.img ;; *) something_failed ;; esac -title Installing Graphics Drivers +echo "Installing Graphics Drivers" # Graphics Drivers find and install if [[ "$(lspci | grep -E '(NVIDIA|GeForce)' -c)" -gt "0" ]]; then - install_pkg "nvidia nvidia-utils libglvnd" + install_pkg "nvidia nvidia-utils libglvnd" elif [[ "$(lspci | grep -E '(Radeon|AMD)' -c)" -gt "0" ]]; then install_pkg "xf86-video-amdgpu mesa-libgl mesa-vdpau libvdpau-va-gl" elif [[ "$(lspci | grep -E '(Integrated Graphics Controller|Intel Corporation UHD)' -c)" -gt "0" ]]; then # install_pkg "libva-intel-driver libvdpau-va-gl lib32-vulkan-intel vulkan-intel libva-intel-driver libva-utils lib32-mesa" install_pkg "xf86-video-intel vulkan-radeon mesa-libgl mesa-vdpau libvdpau-va-gl" -else +else echo "No graphics card found!" fi -title Adding User +ENCRYP_UUID=$(blkid -s UUID -o value "$PART2") +PART_UUID=$(blkid -s PARTUUID -o value "$PART2") + +case "$BOOTLOADER" in +grub) + echo "Installing GRUB" + install_pkg grub os-prober + if [[ "$LUKS" -eq 1 ]]; then + echo "Installing GRUB for LUKS" + sed -i -e 's/GRUB_CMDLINE_LINUX="\(.\+\)"/GRUB_CMDLINE_LINUX="\1 cryptdevice=UUID='"${ENCRYP_UUID}"':luks"/g' -e 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="cryptdevice=UUID'"${ENCRYP_UUID}"':luks"/g' /etc/default/grub + fi + if [[ "$UEFI" -eq 1 ]]; then + grub-install --target=x86_64-efi --efi-directory="$MOUNTPOINT"/boot --bootloader-id=GRUB --recheck + else + grub-install --target=i386-pc --recheck "$DISK" + fi + grub-mkconfig -o /boot/grub/grub.cfg + ;; +systemd) + if [[ "$UEFI" -eq 1 ]]; then + echo "Installing systemd-boot" + bootctl --path=/boot install + + if [[ $LUKS -eq 1 ]]; then + echo -e "title\tArchTitus\nlinux\t/vmlinuz-linux\ninitrd\t/initramfs-linux.img\noptions\tcryptdevice=UUID=$ENCRYP_UUID:luks root=\/dev\/$LVM_VG\/${LVM_NAMES[0]} rw" >/boot/loader/entries/arch.conf + elif [[ $LVM -eq 1 ]]; then + echo -e "title\tArchTitus\nlinux\t/vmlinuz-linux\ninitrd\t/initramfs-linux.img\noptions\troot=\/dev\/$LVM_VG\/${LVM_NAMES[0]} rw" >/boot/loader/entries/arch.conf + else + echo -e "title\tArchTitus\nlinux\t/vmlinuz-linux\ninitrd\t/initramfs-linux.img\noptions\troot=PARTUUID=$PART_UUID rw" >/boot/loader/entries/arch.conf + fi + echo -e "default arch\ntimeout 5" >/boot/loader/loader.conf + else + echo "ERROR! Systemd-boot is not supported for BIOS systems" + exit 1 + fi + ;; +uefi) + if [[ "$UEFI" -eq 1 ]]; then + echo "Installing efistub" + if [[ "$LUKS" -eq 1 && "$FS" =~ "btrfs" ]]; then + efibootmgr --disk "$DISK" --part 1 --create --label "ArchTitus" --loader "/vmlinuz-linux" --unicode "cryptdevice=PARTUUID=$PART_UUID:luks:allow-discards root=\/dev\/$LVM_VG\/${LVM_NAMES[0]} rw rootflags=subvol=@ initrd=\\$IMG initrd=\initramfs-linux.img" + efibootmgr --disk "$DISK" --part 1 --create --label "ArchTitus-Fallback" --loader "/vmlinuz-linux" --unicode "cryptdevice=PARTUUID=$PART_UUID:luks:allow-discards root=\/dev\/$LVM_VG\/${LVM_NAMES[0]} rw rootflags=subvol=@ initrd=\\$IMG initrd=\initramfs-linux-fallback.img" + elif [[ "$LUKS" -eq 1 ]]; then + efibootmgr --disk "$DISK" --part 1 --create --label "ArchTitus" --loader "/vmlinuz-linux" --unicode "cryptdevice=PARTUUID=$PART_UUID:luks:allow-discards root=\/dev\/$LVM_VG\/${LVM_NAMES[0]} rw initrd=\\$IMG initrd=\initramfs-linux.img" + efibootmgr --disk "$DISK" --part 1 --create --label "ArchTitus-Fallback" --loader "/vmlinuz-linux" --unicode "cryptdevice=PARTUUID=$PART_UUID:luks:allow-discards root=\/dev\/$LVM_VG\/${LVM_NAMES[0]} rw initrd=\\$IMG initrd=\initramfs-linux-fallback.img" + elif [[ "$LVM" -eq 1 ]]; then + efibootmgr --disk "$DISK" --part 1 --create --label "ArchTitus" --loader "/vmlinuz-linux" --unicode "root=\/dev\/$LVM_VG\/${LVM_NAMES[0]} rw initrd=\\$IMG initrd=\initramfs-linux.img" + efibootmgr --disk "$DISK" --part 1 --create --label "ArchTitus-Fallback" --loader "/vmlinuz-linux" --unicode "root=\/dev\/$LVM_VG\/${LVM_NAMES[0]} rw initrd=\\$IMG initrd=\initramfs-linux-fallback.img" + else + efibootmgr --disk "$DISK" --part 1 --create --label "ArchTitus" --loader "/vmlinuz-linux" --unicode "root=PARTUUID=$PART_UUID rw initrd=\\$IMG initrd=\initramfs-linux.img" + efibootmgr --disk "$DISK" --part 1 --create --label "ArchTitus-Fallback" --loader "/vmlinuz-linux" --unicode "root=PARTUUID=$PART_UUID rw initrd=\\$IMG initrd=\initramfs-linux-fallback.img" + fi + else + echo "ERROR! efistub is not supported for BIOS systems" + exit 1 + fi + ;; +none) + echo "Skipping bootloader installation" + ;; +*) + something_failed + ;; +esac + +echo "Adding User" if [ "$(id -u)" = "0" ]; then if [[ "$LAYOUT" -eq 1 ]]; then groupadd libvirt @@ -182,7 +248,7 @@ elif [[ "$LUKS" -eq 1 ]]; then sed -i "s/^HOOK.*/HOOKS=(${HOOKS[*]})/" /etc/mkinitcpio.conf fi -if [[ -f "/etc/mkinitcpio.conf" ]];then +if [[ -f "/etc/mkinitcpio.conf" ]]; then # making mkinitcpio with linux kernel echo "Building initramfs" mkinitcpio -p linux diff --git a/archtitus.sh b/archtitus.sh index 3b04ba8..df866f8 100755 --- a/archtitus.sh +++ b/archtitus.sh @@ -2,11 +2,11 @@ # shellcheck disable=SC1091 # shellcheck source=./setup.conf -# Find the name of the folder the scripts are in pacman -Sy --noconfirm pacman -S --noconfirm --needed terminus-font setfont ter-v22b clear +# Find the name of the folder the scripts are in SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" CONFIG_FILE="$SCRIPT_DIR"/setup.conf diff --git a/startup.sh b/startup.sh index e1f4d69..3e2d297 100644 --- a/startup.sh +++ b/startup.sh @@ -126,7 +126,7 @@ elements_present() { } invalid_option() { - echo -ne "Your selected option is invalid, retry \n" + echo -ne "ERROR! Your selected option is invalid, retry \n" } set_password() { @@ -137,7 +137,7 @@ set_password() { if [[ "$PASSWORD1" == "$PASSWORD2" ]]; then set_option "$1" "$PASSWORD1" else - echo -ne "Passwords do not match \n" + echo -ne "ERROR! Passwords do not match \n" set_password fi } @@ -162,12 +162,9 @@ title () { } set_option() { - # Check if option exists if grep -Eq "^\${1}.*" "\$CONFIG_FILE"; then - # delete option if exists sed -i -e "/^\${1}.*/d" "\$CONFIG_FILE" fi - # Else add option echo "\${1}=\${2}" >>"\$CONFIG_FILE" } @@ -180,7 +177,7 @@ refresh_pacman() { } something_failed() { - echo "Something is not right. Exiting." + echo "ERROR! Something is not right. Exiting." exit 1 } @@ -479,6 +476,24 @@ set_desktop() { } +set_bootloader() { + title "Select your bootloader" + SELECTION=("GRUB" "Systemd" "UEFI" "None") + echo "Systemd and UEFI are only available on a UEFI system" + echo "None will skip a bootloader and you will not be able to boot" + PS3="$PROMPT" + select OPT in "${SELECTION[@]}"; do + if elements_present "$OPT" "${SELECTION[@]}"; then + set_option "BOOTLOADER" "${OPT,,}" + break + else + invalid_option + set_bootloader + break + fi + done +} + make_choice() { title "Your system choice" CHOICE=("Default Install" "Custom Install") @@ -525,6 +540,7 @@ make_choice() { ssd_drive # Advance options set_partion_layout + set_bootloader set_filesystem set_desktop break