chroot.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/bash
  2. error_exit() {
  3. echo "$1"
  4. exit 1
  5. }
  6. while true; do
  7. passwd && break
  8. done
  9. DRIVE=$(cat drive)
  10. ln -sf /usr/share/zoneinfo/Europe/Zurich /etc/localtime
  11. hwclock --systohc
  12. echo "LANG=en_GB.UTF-8" >> /etc/locale.conf
  13. echo "en_GB.UTF-8 UTF-8" >> /etc/locale.gen
  14. locale-gen
  15. systemctl enable NetworkManager
  16. # mount /dev/"$DRIVE"1 /efi
  17. mkdir -p /efi/EFI/Linux
  18. test -d /efi/EFI || error_exit "Error: EFI partition could not be mounted correctly."
  19. sed -i 's/block filesystems/block encrypt filesystems/' /etc/mkinitcpio.conf
  20. mkinitcpio -p linux
  21. root_uuid="$(grep UUID /etc/fstab | sed 's/^UUID=//; s/\s\/.*$//')"
  22. echo "BOOT_IMAGE=/boot/vmlinuz-linux root=UUID=$root_uuid rw cryptdevice=/dev/sda2:cryptroot loglevel=0 quiet udev.log_level=3" > /etc/kernel/cmdline
  23. chmod +w /etc/kernel/cmdline
  24. sb_status="$(sbctl status)"
  25. echo "$sb_status" | grep "^Setup Mode:" | grep -q "Enabled" || error_exit "Error: Secure Boot not in Setup Mode. Please chane UEFI settings."
  26. echo "$sb_status" | grep "^Secure Boot:" | grep -q "Disabled" || error_exit "Error: Secure Boot enabled. Please chane UEFI settings."
  27. echo "$sb_status" | grep "^Vendor Keys:" | grep -q "none" || error_exit "Error: Vendor Keys present. Please change UEFI settings."
  28. sbctl bundle -s \
  29. -a /boot/amd-ucode.img \
  30. -k /boot/vmlinuz-linux \
  31. -f /boot/initramfs-linux.img \
  32. -c /etc/kernel/cmdline \
  33. /efi/EFI/Linux/ArchBundle.efi
  34. sbctl create-keys
  35. sbctl generate-bundles --sign
  36. sbctl enroll-keys -m
  37. efibootmgr --create \
  38. --disk /dev/"$DRIVE" \
  39. --part 1 \
  40. --label "videopc signed efi bundle" \
  41. --loader /EFI/Linux/ArchBundle.efi
  42. mkinitcpio -p linux
  43. rm drive