stage1.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 -d | sed 's/0 disk/0 disk\\n/;s/POINT/POINT\\n/'
  9. read -rp "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 --type luks2 /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 cryptsetup 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 /mnt
  46. arch-chroot /mnt bash chroot.sh
  47. rm /mnt/chroot.sh
  48. cp stage2.sh /mnt