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.

151 lines
4.6 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. clear
  49. # Create the boot partition
  50. echo "[INFO]: Formatting boot partition"
  51. mkfs.fat -F32 $boot
  52. echo -n "[INFO]: Would you like to enrypt your disks?(Y/n): "
  53. read encryption
  54. if [ ! "$encryption" = "n" ]; then
  55. # Create the swap partition
  56. echo "[INFO]: Enter password for swap encryption"
  57. read swap_pass
  58. echo $swap_pass | cryptsetup -q luksFormat "$swap"
  59. mkdir /root/.keys
  60. dd if=/dev/urandom of=/root/.keys/swap-keyfile bs=1024 count=4
  61. chmod 600 /root/.keys/swap-keyfile
  62. echo $swap_pass | cryptsetup luksAddKey "$swap" /root/.keys/swap-keyfile
  63. echo "[INFO]: Keyfile saved to /root/.keys/swap-keyfile"
  64. cryptsetup open --key-file="/root/.keys/swap-keyfile" "$swap" swap
  65. mkswap /dev/mapper/swap
  66. swapon /dev/mapper/swap
  67. # Create the root partition
  68. echo "[INFO]: Enter password for root encryption"
  69. read root_pass
  70. echo $root_pass | cryptsetup -q luksFormat "$root"
  71. dd bs=512 count=4 if=/dev/random of=/root/.keys/root-keyfile iflag=fullblock
  72. chmod 600 /root/.keys/root-keyfile
  73. echo $root_pass | cryptsetup luksAddKey "$root" /root/.keys/root-keyfile
  74. echo "[INFO]: Keyfile saved to /root/.keys/root-keyfile"
  75. cryptsetup open --key-file="/root/.keys/root-keyfile" "$root" root
  76. mkfs.ext4 /dev/mapper/root
  77. mkdir /mnt/sys
  78. mount /dev/mapper/root /mnt/sys
  79. if [ "$home_s" = "y" ]; then
  80. echo "[INFO]: Enter password for home encryption"
  81. read home_pass
  82. echo $home_pass | cryptsetup -q luksFormat "$home"
  83. dd bs=512 count=4 if=/dev/random of=/root/.keys/home-keyfile iflag=fullblock
  84. chmod 600 /root/.keys/home-keyfile
  85. echo $home_pass | cryptsetup luksAddKey "$home" /root/.keys/home-keyfile
  86. echo "[INFO]: Keyfile saved to /root/.keys/home-keyfile"
  87. cryptsetup open --key-file="/root/.keys/home-keyfile" "$home" home
  88. mkfs.ext4 /dev/mapper/home
  89. mkdir /mnt/sys/home
  90. mount "/dev/mapper/home" /mnt/sys/home
  91. fi
  92. else
  93. mkswap $swap
  94. swapon $swap
  95. mkfs.ext4 $root
  96. mkdir /mnt/sys
  97. mount $root /mnt/sys
  98. if [ "$home_s" = "y" ]; then
  99. mkfs.ext4 $home
  100. mkdir /mnt/sys/home
  101. mount "/dev/mapper/home" /mnt/sys/home
  102. fi
  103. fi
  104. mkdir /mnt/sys/boot
  105. mount "$boot" /mnt/sys/boot
  106. clear
  107. pacstrap /mnt/sys base linux linux-firmware base-devel git nano sudo
  108. genfstab -U /mnt/sys >> /mnt/sys/etc/fstab
  109. clear
  110. # Run on chrooted arch install
  111. mkdir /mnt/sys/install
  112. cp -r /root/.keys /mnt/sys/root
  113. curl https://raw.githubusercontent.com/theFr1nge/dotfiles/main/arch-setup/packages.minimal > /mnt/sys/install/packages.minimal
  114. curl https://raw.githubusercontent.com/theFr1nge/dotfiles/main/arch-setup/packages.full > /mnt/sys/install/packages.full
  115. curl https://raw.githubusercontent.com/theFr1nge/dotfiles/main/arch-setup/chroot.sh > /mnt/sys/install/chroot.sh
  116. chmod +x /mnt/sys/install/chroot.sh
  117. if [ "$home_s" = "y" ]; then
  118. echo -en "$boot\n$root\n$swap\n$home" > /mnt/sys/install/device
  119. else
  120. echo -en "$boot\n$root\n$swap" > /mnt/sys/install/device
  121. fi
  122. if [ ! "$encryption" = "n" ]; then
  123. touch /mnt/sys/install/encrypted
  124. fi
  125. pacman -Sy --noconfirm tmux
  126. tmux new-session -s "arch-setup" 'arch-chroot /mnt/sys /install/chroot.sh'