cryptarch.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/bash
  2. # This a lazy and DANGEROUS way to install Arch.
  3. # I do not recommend this to other people, ONLY
  4. # do this if you exactly understand EVERY SINGLE
  5. # LINE of this bash script. You'll thank me later.
  6. pacman -Sy --noconfirm dialog || { printf "Error at script start:\n\nAre you sure you're running this as the root user?\n\t(Tip: run 'whoami' to check)\n\nAre you sure you have an internet connection?\n\t(Tip: run 'ip a' to check)\n"; exit; }
  7. dialog --defaultno --title "WARNING!" --yesno "Do only run this script if you're a big brain who doesn't mind deleting one or more (this depends on your level of stupidity in the following steps) of his /dev/sd[x] drives. \n\nThis script is only really for me so I can save some of my precious time.\n\nNoah" 15 60 || { clear; exit; }
  8. dialog --no-cancel --inputbox "Enter the hostname." 10 60 2>comp
  9. clear
  10. lsblk -d | sed 's/0 disk/0 disk\\n/;s/POINT/POINT\\n/'
  11. read -p "Press any key to continue"
  12. dialog --no-cancel --inputbox "Enter the drive you want do install Arch on." 10 60 2>drive
  13. dialog --defaultno --title "Time Zone select" --yesno "Do you want use the default time zone(Europe/Zurich)?.\n\nPress no for select your own time zone" 10 60 && echo "Europe/Zurich" > tz.tmp || tzselect > tz.tmp
  14. dialog --no-cancel --inputbox "Enter swapsize in gb (only type in numbers)." 10 60 2>swapsize
  15. SIZE=$(cat swapsize)
  16. DRIVE=$(cat drive)
  17. timedatectl set-ntp true
  18. cat <<EOF | fdisk -W always /dev/${DRIVE}
  19. p
  20. g
  21. n
  22. +300M
  23. t
  24. 1
  25. n
  26. +${SIZE}G
  27. t
  28. 2
  29. 19
  30. p
  31. n
  32. t
  33. 3
  34. 20
  35. p
  36. w
  37. EOF
  38. partprobe
  39. mkfs.fat -F32 /dev/${DRIVE}1
  40. mkswap /dev/${DRIVE}2
  41. swapon /dev/${DRIVE}2
  42. lsblk
  43. cryptsetup luksFormat /dev/${DRIVE}3
  44. cryptsetup luksOpen /dev/${DRIVE}3 cryptroot || exit 1
  45. mkfs.btrfs /dev/mapper/cryptroot
  46. mount /dev/mapper/cryptroot /mnt
  47. cd /mnt
  48. btrfs subvolume create @
  49. btrfs subvolume create @home
  50. cd
  51. umount /mnt
  52. mount -t btrfs -o subvol=@ /dev/mapper/cryptroot /mnt
  53. mkdir /mnt/home
  54. mount -t btrfs -o subvol=@home /dev/mapper/cryptroot /mnt/home
  55. mkdir /mnt/boot
  56. mount /dev/${DRIVE}1 /mnt/boot
  57. lsblk
  58. pacman -Sy --noconfirm archlinux-keyring
  59. pacstrap /mnt base base-devel linux linux-firmware networkmanager git neovim btrfs-progs cryptsetup efibootmgr
  60. genfstab -U /mnt >> /mnt/etc/fstab
  61. cat tz.tmp > /mnt/tzfinal.tmp
  62. rm tz.tmp
  63. mv drive /mnt
  64. mv comp /mnt/etc/hostname
  65. cp cryptchroot.sh /mnt/chroot.sh && arch-chroot /mnt bash chroot.sh && rm /mnt/chroot.sh /mnt/drive /mnt/tzfinal.tmp
  66. dialog --defaultno --title "Final Qs" --yesno "Reboot computer?" 5 30 && reboot
  67. dialog --defaultno --title "Final Qs" --yesno "Return to chroot environment?" 6 30 && arch-chroot /mnt
  68. clear