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.

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