Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.3 KiB

4 years ago
  1. #!/bin/bash
  2. # Disk setup
  3. echo -n "What is the install device: "
  4. read device
  5. echo "Installing to $device... (Enter to continue)"
  6. read _
  7. echo -n "Would you wipe and re-partition the disk $device?(Y/n): "
  8. read wipe
  9. if [ ! "$wipe" = "n" ]; then
  10. # Disk wipe
  11. echo "[INFO]: Wiping disk"
  12. cryptsetup open -q --type plain -d /dev/urandom $device wipe
  13. dd if=/dev/zero of=/dev/mapper/wipe status=progress
  14. cryptsetup -q close wipe
  15. wipefs -a -f $device
  16. # Run cfdisk for manual partitioning
  17. cfdisk $device
  18. fi
  19. # Create the boot partition
  20. echo "[INFO]: Formatting boot partition"
  21. mkfs.fat -F32 "$device"1
  22. # Create the swap partition
  23. echo "[INFO]: Enter password for swap encryption"
  24. read swap_pass
  25. echo $swap_pass | cryptsetup -q luksFormat "$device"2
  26. mkdir /root/.keys
  27. dd if=/dev/urandom of=/root/.keys/swap-keyfile bs=1024 count=4
  28. chmod 600 /root/.keys/swap-keyfile
  29. echo $swap_pass | cryptsetup luksAddKey "$device"2 /root/.keys/swap-keyfile
  30. echo "[INFO]: Keyfile saved to /root/.keys/swap-keyfile"
  31. cryptsetup open --key-file="/root/.keys/swap-keyfile" "$device"2 swap
  32. mkswap /dev/mapper/swap
  33. swapon /dev/mapper/swap
  34. # Create the root partition
  35. echo "[INFO]: Enter password for root encryption"
  36. read root_pass
  37. echo $root_pass | cryptsetup -q luksFormat "$device"3
  38. dd bs=512 count=4 if=/dev/random of=/root/.keys/root-keyfile iflag=fullblock
  39. chmod 600 /root/.keys/root-keyfile
  40. echo $root_pass | cryptsetup luksAddKey "$device"3 /root/.keys/root-keyfile
  41. echo "[INFO]: Keyfile saved to /root/.keys/root-keyfile"
  42. cryptsetup open --key-file="/root/.keys/root-keyfile" "$device"3 root
  43. mkfs.ext4 /dev/mapper/root
  44. mkdir /mnt/sys
  45. mount /dev/mapper/root /mnt/sys
  46. mkdir /mnt/sys/boot
  47. mount "$device"1 /mnt/sys/boot
  48. pacstrap /mnt/sys base linux linux-firmware base-devel git nano
  49. genfstab -U /mnt/sys >> /mnt/sys/etc/fstab
  50. # Run on chrooted arch install
  51. mkdir /mnt/sys/install
  52. cp -r /root/.keys /mnt/sys/root
  53. curl https://raw.githubusercontent.com/theFr1nge/dotfiles/main/arch-setup/AUR.txt > /mnt/sys/install/AUR.txt
  54. curl https://raw.githubusercontent.com/theFr1nge/dotfiles/main/arch-setup/nonAUR.txt > /mnt/sys/install/nonAUR.txt
  55. curl https://raw.githubusercontent.com/theFr1nge/dotfiles/main/arch-setup/chroot.sh > /mnt/sys/install/chroot.sh
  56. chmod +x /mnt/sys/install/chroot.sh
  57. echo -n "$device" > /mnt/sys/install/device
  58. arch-chroot /mnt/sys /install/chroot.sh