stage1.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. curl -LO https://raw.githubusercontent.com/noahvogt/videopc-infra/master/chroot.sh --output-dir /mnt
  46. curl -LO https://raw.githubusercontent.com/noahvogt/videopc-infra/master/stage2.sh --output-dir /mnt || error_exit "Error: Failed to install stage2 script."
  47. arch-chroot /mnt bash chroot.sh || error_exit "Error: Installation failed."
  48. rm /mnt/chroot.sh
  49. systemctl reboot --firmware