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.

122 lines
4.0 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. sleep 1
  22. fi
  23. clear
  24. # Run cfdisk for manual partitioning
  25. cfdisk $device
  26. clear
  27. lsblk $device
  28. echo ""
  29. echo "Now you will specify the partitions you have created"
  30. echo "Please enter the suffix for each partition. For Ex:"
  31. echo "1 if boot partition is /dev/sda1 or p1 if boot is on /dev/nvme0n1p1 and the disk is /dev/nvme0n1"
  32. echo -n "Please enter boot partition suffix: "
  33. read boot_p
  34. boot=$device$boot_p
  35. echo -n "Please enter root partition suffix: "
  36. read root_p
  37. root=$device$root_p
  38. echo -n "Please enter swap partition suffix: "
  39. read swap_p
  40. swap=$device$swap_p
  41. echo -n "Did you create a home partition as well?(y/N): "
  42. read home_s
  43. if [ "$home_s" = "y" ]; then
  44. echo -n "Please enter home partition suffix: "
  45. read home_p
  46. home=$device$home_p
  47. fi
  48. # Create the boot partition
  49. echo "[INFO]: Formatting boot partition"
  50. mkfs.fat -F32 $boot
  51. # Create the swap partition
  52. echo "[INFO]: Enter password for swap encryption"
  53. read swap_pass
  54. echo $swap_pass | cryptsetup -q luksFormat "$swap"
  55. mkdir /root/.keys
  56. dd if=/dev/urandom of=/root/.keys/swap-keyfile bs=1024 count=4
  57. chmod 600 /root/.keys/swap-keyfile
  58. echo $swap_pass | cryptsetup luksAddKey "$swap" /root/.keys/swap-keyfile
  59. echo "[INFO]: Keyfile saved to /root/.keys/swap-keyfile"
  60. cryptsetup open --key-file="/root/.keys/swap-keyfile" "$swap" swap
  61. mkswap /dev/mapper/swap
  62. swapon /dev/mapper/swap
  63. # Create the root partition
  64. echo "[INFO]: Enter password for root encryption"
  65. read root_pass
  66. echo $root_pass | cryptsetup -q luksFormat "$root"
  67. dd bs=512 count=4 if=/dev/random of=/root/.keys/root-keyfile iflag=fullblock
  68. chmod 600 /root/.keys/root-keyfile
  69. echo $root_pass | cryptsetup luksAddKey "$root" /root/.keys/root-keyfile
  70. echo "[INFO]: Keyfile saved to /root/.keys/root-keyfile"
  71. cryptsetup open --key-file="/root/.keys/root-keyfile" "$root" root
  72. mkfs.ext4 /dev/mapper/root
  73. if [ "$home_s" = "y" ]; then
  74. echo "[INFO]: Enter password for home encryption"
  75. read home_pass
  76. echo $home_pass | cryptsetup -q luksFormat "$home"
  77. dd bs=512 count=4 if=/dev/random of=/root/.keys/home-keyfile iflag=fullblock
  78. chmod 600 /root/.keys/home-keyfile
  79. echo $home_pass | cryptsetup luksAddKey "$home" /root/.keys/home-keyfile
  80. echo "[INFO]: Keyfile saved to /root/.keys/home-keyfile"
  81. cryptsetup open --key-file="/root/.keys/home-keyfile" "$home" home
  82. mkfs.ext4 /dev/mapper/home
  83. mkdir /mnt/sys/home
  84. mount "/dev/mapper/home" /mnt/sys/home
  85. fi
  86. mkdir /mnt/sys
  87. mount /dev/mapper/root /mnt/sys
  88. mkdir /mnt/sys/boot
  89. mount "$boot" /mnt/sys/boot
  90. pacstrap /mnt/sys base linux linux-firmware base-devel git nano sudo
  91. genfstab -U /mnt/sys >> /mnt/sys/etc/fstab
  92. # Run on chrooted arch install
  93. mkdir /mnt/sys/install
  94. cp -r /root/.keys /mnt/sys/root
  95. curl https://raw.githubusercontent.com/theFr1nge/dotfiles/main/arch-setup/packages.minimal > /mnt/sys/install/packages.minimal
  96. curl https://raw.githubusercontent.com/theFr1nge/dotfiles/main/arch-setup/packages.full > /mnt/sys/install/packages.full
  97. curl https://raw.githubusercontent.com/theFr1nge/dotfiles/main/arch-setup/chroot.sh > /mnt/sys/install/chroot.sh
  98. chmod +x /mnt/sys/install/chroot.sh
  99. if [ "$home_s" = "y" ]; then
  100. echo -en "$boot\n$root\n$swap\n$home" > /mnt/sys/install/device
  101. else
  102. echo -en "$boot\n$root\n$swap" > /mnt/sys/install/device
  103. fi
  104. pacman -Sy --noconfirm tmux
  105. tmux new-session -s "arch-setup" 'arch-chroot /mnt/sys /install/chroot.sh'