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.

116 lines
3.9 KiB

4 years ago
4 years ago
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 like to wipe and re-partition the disk $device?(Y/n): "
  8. read wipe
  9. if [ ! "$wipe" = "n" ]; then
  10. # Disk wipe
  11. echo -n "Should I do a secure wipe?(y/N): "
  12. read secure
  13. if [ "$secure" = "y" ]; then
  14. echo "[INFO]: Writing random data to disk, this might take a while if you have a large drive..."
  15. cryptsetup open -q --type plain -d /dev/urandom $device wipe
  16. dd if=/dev/zero of=/dev/mapper/wipe status=progress
  17. cryptsetup -q close wipe
  18. fi
  19. echo "[INFO]: Wiping the partition table..."
  20. wipefs -a -f $device
  21. fi
  22. # Run cfdisk for manual partitioning
  23. cfdisk $device
  24. echo "Now you will specify the partitions you have created"
  25. echo "Please enter the suffix for each partition. For Ex:"
  26. echo "1 if boot partition is /dev/sda1 or p1 if boot is on /dev/nvme0n1p1 and the disk is /dev/nvme0n1"
  27. echo -n "Please enter boot partition suffix: "
  28. read boot_p
  29. boot=$device$boot_p
  30. echo -n "Please enter root partition suffix: "
  31. read root_p
  32. root=$device$root_p
  33. echo -n "Please enter swap partition suffix: "
  34. read swap_p
  35. swap=$device$swap_p
  36. echo -n "Did you create a home partition as well?(y/N): "
  37. read home_s
  38. if [ "$home_s" = "y" ]; then
  39. echo -n "Please enter home partition suffix: "
  40. read home_p
  41. home=$device$home_p
  42. fi
  43. # Create the boot partition
  44. echo "[INFO]: Formatting boot partition"
  45. mkfs.fat -F32 $boot
  46. # Create the swap partition
  47. echo "[INFO]: Enter password for swap encryption"
  48. read swap_pass
  49. echo $swap_pass | cryptsetup -q luksFormat "$swap"
  50. mkdir /root/.keys
  51. dd if=/dev/urandom of=/root/.keys/swap-keyfile bs=1024 count=4
  52. chmod 600 /root/.keys/swap-keyfile
  53. echo $swap_pass | cryptsetup luksAddKey "$swap" /root/.keys/swap-keyfile
  54. echo "[INFO]: Keyfile saved to /root/.keys/swap-keyfile"
  55. cryptsetup open --key-file="/root/.keys/swap-keyfile" "$swap" swap
  56. mkswap /dev/mapper/swap
  57. swapon /dev/mapper/swap
  58. # Create the root partition
  59. echo "[INFO]: Enter password for root encryption"
  60. read root_pass
  61. echo $root_pass | cryptsetup -q luksFormat "$root"
  62. dd bs=512 count=4 if=/dev/random of=/root/.keys/root-keyfile iflag=fullblock
  63. chmod 600 /root/.keys/root-keyfile
  64. echo $root_pass | cryptsetup luksAddKey "$root" /root/.keys/root-keyfile
  65. echo "[INFO]: Keyfile saved to /root/.keys/root-keyfile"
  66. cryptsetup open --key-file="/root/.keys/root-keyfile" "$root" root
  67. mkfs.ext4 /dev/mapper/root
  68. if [ "$home_s" = "y" ]; then
  69. echo "[INFO]: Enter password for home encryption"
  70. read home_pass
  71. echo $home_pass | cryptsetup -q luksFormat "$home"
  72. dd bs=512 count=4 if=/dev/random of=/root/.keys/home-keyfile iflag=fullblock
  73. chmod 600 /root/.keys/home-keyfile
  74. echo $home_pass | cryptsetup luksAddKey "$home" /root/.keys/home-keyfile
  75. echo "[INFO]: Keyfile saved to /root/.keys/home-keyfile"
  76. cryptsetup open --key-file="/root/.keys/home-keyfile" "$home" root
  77. mkfs.ext4 /dev/mapper/home
  78. mkdir /mnt/sys/home
  79. mount "/dev/mapper/home" /mnt/sys/home
  80. fi
  81. mkdir /mnt/sys
  82. mount /dev/mapper/root /mnt/sys
  83. mkdir /mnt/sys/boot
  84. mount "$boot" /mnt/sys/boot
  85. pacstrap /mnt/sys base linux linux-firmware base-devel git nano tmux sudo
  86. genfstab -U /mnt/sys >> /mnt/sys/etc/fstab
  87. # Run on chrooted arch install
  88. mkdir /mnt/sys/install
  89. cp -r /root/.keys /mnt/sys/root
  90. curl https://raw.githubusercontent.com/theFr1nge/dotfiles/main/arch-setup/packages.minimal > /mnt/sys/install/packages.minimal
  91. curl https://raw.githubusercontent.com/theFr1nge/dotfiles/main/arch-setup/packages.full > /mnt/sys/install/packages.full
  92. curl https://raw.githubusercontent.com/theFr1nge/dotfiles/main/arch-setup/chroot.sh > /mnt/sys/install/chroot.sh
  93. chmod +x /mnt/sys/install/chroot.sh
  94. if [ "$home_s" = "y" ]; then
  95. echo -en "$boot\n$root\n$swap\n$home" > /mnt/sys/install/device
  96. else
  97. echo -en "$boot\n$root\n$swap" > /mnt/sys/install/device
  98. fi
  99. arch-chroot /mnt/sys bash -c 'tmux new-session -s "arch-setup" /install/chroot.sh'