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.

198 lines
5.9 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. wipefs -a -f $device
  24. sleep 1
  25. fi
  26. clear
  27. # Run cfdisk for manual partitioning
  28. cfdisk $device
  29. clear
  30. sleep 2
  31. [ ! $(command -v partprobe) = "" ] && partprobe
  32. lsblk $device
  33. echo -n "Are you satisfied with your partitions?(Y/n): "
  34. read satisfied
  35. while [ "$satisfied" = "n" ]; do
  36. cfdisk $device
  37. clear
  38. [ ! $(command -v partprobe) = "" ] && partprobe
  39. lsblk $device
  40. echo -n "Are you satisfied with your partitions?(Y/n): "
  41. read satisfied
  42. done
  43. clear
  44. lsblk $device
  45. echo ""
  46. echo "Now you will specify the partitions you have created"
  47. echo "Please enter the suffix for each partition. For Ex:"
  48. echo "1 if boot partition is /dev/sda1 or p1 if boot is on /dev/nvme0n1p1 and the disk is /dev/nvme0n1"
  49. echo -n "Please enter boot partition suffix: "
  50. read boot_p
  51. boot=$device$boot_p
  52. echo -n "Please enter root partition suffix: "
  53. read root_p
  54. root=$device$root_p
  55. echo -n "Please enter swap partition suffix: "
  56. read swap_p
  57. swap=$device$swap_p
  58. echo -n "Did you create a home partition as well?(y/N): "
  59. read home_s
  60. if [ "$home_s" = "y" ]; then
  61. echo -n "Please enter home partition suffix: "
  62. read home_p
  63. home=$device$home_p
  64. fi
  65. clear
  66. # Create the boot partition
  67. echo "[INFO]: Formatting boot partition"
  68. mkfs.fat -F32 $boot
  69. echo -n "[INFO]: Would you like to enrypt your disks?(Y/n): "
  70. read encryption
  71. if [ ! "$encryption" = "n" ]; then
  72. # Create the swap partition
  73. echo "[INFO]: Enter password for swap encryption"
  74. read swap_pass
  75. echo $swap_pass | cryptsetup -q luksFormat "$swap"
  76. mkdir /root/.keys
  77. dd if=/dev/urandom of=/root/.keys/swap-keyfile bs=1024 count=4
  78. chmod 600 /root/.keys/swap-keyfile
  79. echo $swap_pass | cryptsetup luksAddKey "$swap" /root/.keys/swap-keyfile
  80. echo "[INFO]: Keyfile saved to /root/.keys/swap-keyfile"
  81. cryptsetup open --key-file="/root/.keys/swap-keyfile" "$swap" swap
  82. mkswap /dev/mapper/swap
  83. swapon /dev/mapper/swap
  84. # Create the root partition
  85. echo "[INFO]: Enter password for root encryption"
  86. read root_pass
  87. echo $root_pass | cryptsetup -q luksFormat "$root"
  88. dd bs=512 count=4 if=/dev/random of=/root/.keys/root-keyfile iflag=fullblock
  89. chmod 600 /root/.keys/root-keyfile
  90. echo $root_pass | cryptsetup luksAddKey "$root" /root/.keys/root-keyfile
  91. echo "[INFO]: Keyfile saved to /root/.keys/root-keyfile"
  92. cryptsetup open --key-file="/root/.keys/root-keyfile" "$root" root
  93. mkfs.ext4 -F /dev/mapper/root
  94. mkdir /mnt/sys
  95. mount /dev/mapper/root /mnt/sys
  96. if [ "$home_s" = "y" ]; then
  97. echo "[INFO]: Enter password for home encryption"
  98. read home_pass
  99. echo $home_pass | cryptsetup -q luksFormat "$home"
  100. dd bs=512 count=4 if=/dev/random of=/root/.keys/home-keyfile iflag=fullblock
  101. chmod 600 /root/.keys/home-keyfile
  102. echo $home_pass | cryptsetup luksAddKey "$home" /root/.keys/home-keyfile
  103. echo "[INFO]: Keyfile saved to /root/.keys/home-keyfile"
  104. cryptsetup open --key-file="/root/.keys/home-keyfile" "$home" home
  105. mkfs.ext4 -F /dev/mapper/home
  106. mkdir /mnt/sys/home
  107. mount "/dev/mapper/home" /mnt/sys/home
  108. fi
  109. else
  110. mkswap $swap
  111. swapon $swap
  112. mkfs.ext4 -F $root
  113. mkdir /mnt/sys
  114. mount $root /mnt/sys
  115. if [ "$home_s" = "y" ]; then
  116. mkfs.ext4 -F $home
  117. mkdir /mnt/sys/home
  118. mount "$home" /mnt/sys/home
  119. fi
  120. fi
  121. mkdir /mnt/sys/boot
  122. mount "$boot" /mnt/sys/boot
  123. clear
  124. if [ "$distro" = "1" ];then
  125. pacstrap /mnt/sys base linux linux-firmware base-devel vi nano
  126. genfstab -U /mnt/sys >> /mnt/sys/etc/fstab
  127. else
  128. basestrap /mnt/sys base linux linux-firmware base-devel vi nano openrc
  129. fstabgen -U /mnt/sys >> /mnt/sys/etc/fstab
  130. fi
  131. echo -n "Would you like to use tmpfs (This can drastically improve performance)?(Y/n): "
  132. read tmpfs_ok
  133. if [ ! "$tmpfs_ok" = "n" ]; then
  134. echo -n "How big should the tmpfs be?(end with G or M): "
  135. read tmpfs_size
  136. echo -e "\n#tmpfs\ntmpfs /tmp tmpfs rw,nodev,nosuid,size=$tmpfs_size""G 0 0\n" >> /mnt/sys/etc/fstab
  137. fi
  138. clear
  139. # Run on chrooted arch install
  140. mkdir /mnt/sys/install
  141. if [ "$distro" = "1" ];then
  142. curl https://raw.githubusercontent.com/theFr1nge/dotfiles/main/arch-setup/packages.base.arch > /mnt/sys/install/packages.base
  143. else
  144. curl https://raw.githubusercontent.com/theFr1nge/dotfiles/main/arch-setup/packages.base.artix > /mnt/sys/install/packages.base
  145. fi
  146. curl https://raw.githubusercontent.com/theFr1nge/dotfiles/main/arch-setup/chroot.sh > /mnt/sys/install/chroot.sh
  147. chmod +x /mnt/sys/install/chroot.sh
  148. if [ "$home_s" = "y" ]; then
  149. echo -en "$boot\n$root\n$swap\n$home" > /mnt/sys/install/device
  150. else
  151. echo -en "$boot\n$root\n$swap" > /mnt/sys/install/device
  152. fi
  153. if [ ! "$encryption" = "n" ]; then
  154. touch /mnt/sys/install/encrypted
  155. cp -r /root/.keys /mnt/sys/root
  156. fi
  157. if [ "$distro" = "2" ];then
  158. touch /mnt/sys/install/artix
  159. fi
  160. pacman -Sy --noconfirm tmux
  161. if [ "$distro" = "1" ];then
  162. tmux new-session -s "arch-setup" 'arch-chroot /mnt/sys /install/chroot.sh' || arch-chroot /mnt/sys /install/chroot.sh
  163. else
  164. tmux new-session -s "artix-setup" 'artix-chroot /mnt/sys /install/chroot.sh' || artix-chroot /mnt/sys /install/chroot.sh
  165. fi