stage1.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. error_exit() {
  3. echo "$1"
  4. exit 1
  5. }
  6. pacman -Sy --noconfirm dialog || error_exit "Error at script start:\n\nAre you sure you're running this as the root user?\n\t(Tip: run 'whoami' to check)\n\nAre you sure you have an internet connection?\n\t(Tip: run 'ip a' to check)\n"
  7. clear
  8. lsblk
  9. read -rp "After deciding which drive to install the system on, press any key to continue"
  10. dialog --no-cancel --inputbox "Enter the drive you want do install Arch Linux for the VIDEOPC on." 10 60 2>drive
  11. dialog --no-cancel --inputbox "Enter the RTMP key (only alphanumeric values allowed):" 10 60 2> videopc_rtmp_key
  12. dialog --no-cancel --inputbox "Enter the API key (only alphanumeric values allowed):" 10 60 2> videopc_api_key
  13. test -d /sys/firmware/efi/efivars || error_exit "Error: Please boot in UEFI mode. No efi vars detected."
  14. DRIVE=$(cat drive)
  15. cat <<EOF | fdisk -W always /dev/"${DRIVE}"
  16. g
  17. n
  18. p
  19. +1024M
  20. t
  21. 1
  22. n
  23. p
  24. p
  25. w
  26. EOF
  27. partprobe
  28. mkfs.fat -F32 /dev/"$DRIVE"1
  29. while true; do
  30. cryptsetup luksFormat -q /dev/"$DRIVE"2 && break
  31. done
  32. while true; do
  33. cryptsetup open /dev/"$DRIVE"2 cryptroot && break
  34. done
  35. yes | mkfs.ext4 /dev/mapper/cryptroot
  36. mount /dev/mapper/cryptroot /mnt
  37. mkdir -p /mnt/efi
  38. mount /dev/"$DRIVE"1 /mnt/efi
  39. pacman -Sy --noconfirm archlinux-keyring
  40. pacstrap /mnt base linux linux-firmware networkmanager sbctl amd-ucode efibootmgr tpm2-tss
  41. genfstab -U /mnt >> /mnt/etc/fstab
  42. mv drive /mnt
  43. mv videopc_api_key videopc_rtmp_key /mnt/etc
  44. echo "videopc" > /mnt/etc/hostname
  45. cp chroot.sh stage2.sh /mnt
  46. arch-chroot /mnt bash chroot.sh || exit 1
  47. systemctl reboot --firmware