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.

217 lines
6.5 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. #!/bin/bash
  2. # Learn distro
  3. echo -n "Is this an arch or artix installation?(1: Arch, 2: Artix): "
  4. read distro
  5. # Disk setup
  6. echo -n "What is the install device: "
  7. read device
  8. echo "Installing to $device... (Enter to continue)"
  9. read _
  10. echo -n "Would you like to wipe and re-partition the disk $device?(Y/n): "
  11. read wipe
  12. if [ ! "$wipe" = "n" ]; then
  13. # Disk wipe
  14. echo -n "Should I do a secure wipe?(y/N): "
  15. read secure
  16. if [ "$secure" = "y" ]; then
  17. echo "[INFO]: Writing random data to disk, this might take a while if you have a large drive..."
  18. cryptsetup open -q --type plain -d /dev/urandom $device wipe
  19. dd if=/dev/zero of=/dev/mapper/wipe status=progress
  20. cryptsetup -q close wipe
  21. fi
  22. echo "[INFO]: Wiping the partition table..."
  23. cryptsetup erase $device
  24. wipefs -a -f $device
  25. sleep 1
  26. fi
  27. clear
  28. # Run cfdisk for manual partitioning
  29. cfdisk $device
  30. clear
  31. sleep 2
  32. [ ! $(command -v partprobe) = "" ] && partprobe
  33. lsblk $device
  34. echo -n "Are you satisfied with your partitions?(Y/n): "
  35. read satisfied
  36. while [ "$satisfied" = "n" ]; do
  37. cfdisk $device
  38. clear
  39. [ ! $(command -v partprobe) = "" ] && partprobe
  40. lsblk $device
  41. echo -n "Are you satisfied with your partitions?(Y/n): "
  42. read satisfied
  43. done
  44. clear
  45. lsblk $device
  46. echo ""
  47. echo "Now you will specify the partitions you have created"
  48. echo "Please enter the suffix for each partition. For Ex:"
  49. echo "1 if boot partition is /dev/sda1 or p1 if boot is on /dev/nvme0n1p1 and the disk is /dev/nvme0n1"
  50. echo -n "Please enter boot partition suffix: "
  51. read boot_p
  52. boot=$device$boot_p
  53. echo -n "Please enter root partition suffix: "
  54. read root_p
  55. root=$device$root_p
  56. echo -n "Please enter swap partition suffix: "
  57. read swap_p
  58. swap=$device$swap_p
  59. echo -n "Did you create a home partition as well?(y/N): "
  60. read home_s
  61. if [ "$home_s" = "y" ]; then
  62. echo -n "Please enter home partition suffix: "
  63. read home_p
  64. home=$device$home_p
  65. fi
  66. clear
  67. # Create the boot partition
  68. echo "[INFO]: Formatting boot partition"
  69. mkfs.fat -F32 $boot
  70. echo -n "[INFO]: Would you like to enrypt your disks?(y/N): "
  71. read encryption
  72. if [ "$encryption" = "y" ]; then
  73. clear
  74. echo "Running benchmark"
  75. cryptsetup benchmark
  76. echo -n "Please select the ciphering algorithm(aes-xts-plain64): "
  77. read cipher
  78. if [ "$cipher" = "" ]; then
  79. cipher="aes-xts-plain64"
  80. fi
  81. echo -n "Please select the iter time(750): "
  82. read iter
  83. if [ "$iter" = "" ]; then
  84. iter="750"
  85. fi
  86. echo -n "Please select the key size(512): "
  87. read keysize
  88. if [ "$keysize" = "" ]; then
  89. keysize="512"
  90. fi
  91. # Create the swap partition
  92. echo "[INFO]: Enter password for swap encryption"
  93. read swap_pass
  94. echo $swap_pass | cryptsetup --key-size "$keysize" --cipher "$cipher" --iter-time "$iter" -q luksFormat "$swap"
  95. mkdir /root/.keys
  96. dd if=/dev/urandom of=/root/.keys/swap-keyfile bs=1024 count=4
  97. chmod 600 /root/.keys/swap-keyfile
  98. echo $swap_pass | cryptsetup luksAddKey "$swap" /root/.keys/swap-keyfile
  99. echo "[INFO]: Keyfile saved to /root/.keys/swap-keyfile"
  100. cryptsetup open --key-file="/root/.keys/swap-keyfile" "$swap" swap
  101. mkswap /dev/mapper/swap
  102. swapon /dev/mapper/swap
  103. # Create the root partition
  104. echo "[INFO]: Enter password for root encryption"
  105. read root_pass
  106. echo $root_pass | cryptsetup --key-size "$keysize" --cipher "$cipher" --iter-time "$iter" -q luksFormat "$root"
  107. dd bs=512 count=4 if=/dev/random of=/root/.keys/root-keyfile iflag=fullblock
  108. chmod 600 /root/.keys/root-keyfile
  109. echo $root_pass | cryptsetup luksAddKey "$root" /root/.keys/root-keyfile
  110. echo "[INFO]: Keyfile saved to /root/.keys/root-keyfile"
  111. cryptsetup open --key-file="/root/.keys/root-keyfile" "$root" root
  112. mkfs.ext4 -F /dev/mapper/root
  113. mkdir /mnt/sys
  114. mount /dev/mapper/root /mnt/sys
  115. if [ "$home_s" = "y" ]; then
  116. echo "[INFO]: Enter password for home encryption"
  117. read home_pass
  118. echo $home_pass | cryptsetup --key-size "$keysize" --cipher "$cipher" --iter-time "$iter" -q luksFormat "$home"
  119. dd bs=512 count=4 if=/dev/random of=/root/.keys/home-keyfile iflag=fullblock
  120. chmod 600 /root/.keys/home-keyfile
  121. echo $home_pass | cryptsetup luksAddKey "$home" /root/.keys/home-keyfile
  122. echo "[INFO]: Keyfile saved to /root/.keys/home-keyfile"
  123. cryptsetup open --key-file="/root/.keys/home-keyfile" "$home" home
  124. mkfs.ext4 -F /dev/mapper/home
  125. mkdir /mnt/sys/home
  126. mount "/dev/mapper/home" /mnt/sys/home
  127. fi
  128. else
  129. mkswap $swap
  130. swapon $swap
  131. mkfs.ext4 -F $root
  132. mkdir /mnt/sys
  133. mount $root /mnt/sys
  134. if [ "$home_s" = "y" ]; then
  135. mkfs.ext4 -F $home
  136. mkdir /mnt/sys/home
  137. mount "$home" /mnt/sys/home
  138. fi
  139. fi
  140. mkdir /mnt/sys/boot
  141. mount "$boot" /mnt/sys/boot
  142. clear
  143. if [ "$distro" = "1" ];then
  144. pacstrap /mnt/sys base linux linux-firmware base-devel vi nano
  145. genfstab -U /mnt/sys >> /mnt/sys/etc/fstab
  146. else
  147. basestrap /mnt/sys base linux linux-firmware base-devel vi nano openrc
  148. fstabgen -U /mnt/sys >> /mnt/sys/etc/fstab
  149. fi
  150. echo -n "Would you like to use tmpfs (This can drastically improve performance)?(Y/n): "
  151. read tmpfs_ok
  152. if [ ! "$tmpfs_ok" = "n" ]; then
  153. echo -n "How big should the tmpfs be?(end with G or M): "
  154. read tmpfs_size
  155. echo -e "\n#tmpfs\ntmpfs /tmp tmpfs rw,nodev,nosuid,size=$tmpfs_size""G 0 0\n" >> /mnt/sys/etc/fstab
  156. fi
  157. clear
  158. # Run on chrooted arch install
  159. mkdir /mnt/sys/install
  160. if [ "$distro" = "1" ];then
  161. curl https://raw.githubusercontent.com/theFr1nge/dotfiles/main/arch-setup/packages.base.arch > /mnt/sys/install/packages.base
  162. else
  163. curl https://raw.githubusercontent.com/theFr1nge/dotfiles/main/arch-setup/packages.base.artix > /mnt/sys/install/packages.base
  164. fi
  165. curl https://raw.githubusercontent.com/theFr1nge/dotfiles/main/arch-setup/chroot.sh > /mnt/sys/install/chroot.sh
  166. chmod +x /mnt/sys/install/chroot.sh
  167. if [ "$home_s" = "y" ]; then
  168. echo -en "$boot\n$root\n$swap\n$home" > /mnt/sys/install/device
  169. else
  170. echo -en "$boot\n$root\n$swap" > /mnt/sys/install/device
  171. fi
  172. if [ ! "$encryption" = "n" ]; then
  173. touch /mnt/sys/install/encrypted
  174. cp -r /root/.keys /mnt/sys/root
  175. fi
  176. if [ "$distro" = "2" ];then
  177. touch /mnt/sys/install/artix
  178. fi
  179. pacman -Sy --noconfirm tmux
  180. if [ "$distro" = "1" ];then
  181. tmux new-session -s "arch-setup" 'arch-chroot /mnt/sys /install/chroot.sh' || arch-chroot /mnt/sys /install/chroot.sh
  182. else
  183. tmux new-session -s "artix-setup" 'artix-chroot /mnt/sys /install/chroot.sh' || artix-chroot /mnt/sys /install/chroot.sh
  184. fi