chroot.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. mkinitcpio -P
  21. root_uuid="$(grep ext4 /etc/fstab | sed 's/^UUID=//; s/\s\/.*$//')"
  22. drive2_uuid="$(blkid | grep "$DRIVE"2 | tr ' ' '\n' | grep ^UUID= | sed 's/^UUID="//; s/"//')"
  23. echo "BOOT_IMAGE=/boot/vmlinuz-linux root=UUID=$root_uuid rw cryptdevice=UUID=$drive2_uuid:cryptroot loglevel=0 quiet udev.log_level=3" > /etc/kernel/cmdline
  24. chmod +w /etc/kernel/cmdline
  25. sb_status="$(sbctl status)"
  26. echo "$sb_status" | grep "^Setup Mode:" | grep -q "Enabled" || error_exit "Error: Secure Boot not in Setup Mode. Please change UEFI settings."
  27. echo "$sb_status" | grep "^Secure Boot:" | grep -q "Disabled" || error_exit "Error: Secure Boot enabled. Please change UEFI settings."
  28. echo "$sb_status" | grep "^Vendor Keys:" | grep -q "none" || error_exit "Error: Vendor Keys present. Please change UEFI settings."
  29. sbctl bundle -s \
  30. -a /boot/amd-ucode.img \
  31. -k /boot/vmlinuz-linux\
  32. -f /boot/initramfs-linux.img \
  33. -c /etc/kernel/cmdline \
  34. /efi/EFI/Linux/ArchBundle.efi
  35. sbctl create-keys
  36. sbctl generate-bundles --sign
  37. sbctl enroll-keys -m || error_exit "Error: Could not enroll secure boot keys to UEFI."
  38. efibootmgr --create \
  39. --disk /dev/"$DRIVE" \
  40. --part 1 \
  41. --label "videopc signed efi bundle" \
  42. --loader /EFI/Linux/ArchBundle.efi || error_exit "Error: Could not create efi boot entry."
  43. mkinitcpio -P
  44. rm drive