chroot.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. error_exit() {
  3. echo "$1"
  4. exit 1
  5. }
  6. mkdir /etc/systemd/system/getty@tty1.service.d
  7. echo '[Service]
  8. ExecStart=
  9. ExecStart=-/sbin/agetty -o "-p -f -- \\u" --noclear --autologin root %I $TERM' > /etc/systemd/system/getty@tty1.service.d/autologin.conf
  10. DRIVE=$(cat drive)
  11. ln -sf /usr/share/zoneinfo/Europe/Zurich /etc/localtime
  12. hwclock --systohc
  13. echo "LANG=en_GB.UTF-8" >> /etc/locale.conf
  14. echo "en_GB.UTF-8 UTF-8" >> /etc/locale.gen
  15. locale-gen
  16. systemctl enable NetworkManager
  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. root_uuid="$(grep ext4 /etc/fstab | sed 's/^UUID=//; s/\s\/.*$//')"
  21. drive2_uuid="$(blkid | grep "$DRIVE"2 | tr ' ' '\n' | grep ^UUID= | sed 's/^UUID="//; s/"//')"
  22. echo "pti=on page_alloc.shuffle=1 BOOT_IMAGE=/boot/vmlinuz-linux root=UUID=$root_uuid rw cryptdevice=UUID=$drive2_uuid:cryptroot loglevel=7" > /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 change UEFI settings."
  26. echo "$sb_status" | grep "^Secure Boot:" | grep -q "Disabled" || error_exit "Error: Secure Boot enabled. Please change 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 || error_exit "Error: Could not enroll secure boot keys to UEFI."
  37. efibootmgr --create \
  38. --disk /dev/"$DRIVE" \
  39. --part 1 \
  40. --label "videopc signed efi bundle" \
  41. --loader /EFI/Linux/ArchBundle.efi || error_exit "Error: Could not create efi boot entry."
  42. mkinitcpio -P
  43. sbctl ls
  44. error_exit "Error: Test Error."
  45. rm drive