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