Yeet's Automatic Arch Setup Scripts. Or YAASS for short.
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.

270 lines
7.2 KiB

  1. #!/bin/bash
  2. ln -sf /bin/bash /bin/sh
  3. if [ ! -f "/install/device" ]; then
  4. mkdir -p /install
  5. echo "Now you will specify the partitions you have created"
  6. echo "Please enter the suffix for each partition. For Ex:"
  7. echo "1 if boot partition is /dev/sda1 or p1 if boot is on /dev/nvme0n1p1 and the disk is /dev/nvme0n1"
  8. echo -n "Please enter boot partition suffix: "
  9. read boot_p
  10. boot=$device$boot_p
  11. echo -n "Please enter root partition suffix: "
  12. read root_p
  13. root=$device$root_p
  14. echo -n "Please enter swap partition suffix: "
  15. read swap_p
  16. swap=$device$swap_p
  17. echo -n "Did you create a home partition as well?(y/N): "
  18. read home_s
  19. if [ "$home_s" = "y" ]; then
  20. echo -n "Please enter home partition suffix: "
  21. read home_p
  22. home=$device$home_p
  23. echo -en "$boot\n$root\n$swap\n$home" > /install/device
  24. else
  25. echo -en "$boot\n$root\n$swap" > /install/device
  26. fi
  27. fi
  28. clear
  29. boot=$(head -n 1 /install/device | tail -n 1)
  30. root=$(head -n 2 /install/device | tail -n 1)
  31. swap=$(head -n 3 /install/device | tail -n 1)
  32. if [ ! "$(wc -l /install/device)" = "3" ]; then
  33. home=$(head -n 4 /install/device | tail -n 1)
  34. fi
  35. ln -sf /usr/share/zoneinfo/Europe/Istanbul /etc/localtime
  36. hwclock --systohc
  37. echo -e "en_US.UTF-8 UTF-8\ntr_TR.UTF-8 UTF-8" > /etc/locale.gen
  38. locale-gen
  39. echo "LANG=en_US.UTF-8" > /etc/locale.conf
  40. if [ ! -f "/tmp/.blackarch" ]; then
  41. curl https://blackarch.org/strap.sh > /tmp/strap.sh
  42. chmod +x /tmp/strap.sh
  43. /tmp/strap.sh
  44. if [ -f "/install/artix" ]; then
  45. echo -e "\n[multilib]\nInclude = /etc/pacman.d/mirrorlist-arch" >> /etc/pacman.conf
  46. echo -e "\n[lib32]\nInclude = /etc/pacman.d/mirrorlist\n\n[options]\nILoveCandy\nTotalDownload\nColor" >> /etc/pacman.conf
  47. else
  48. echo -e "\n[multilib]\nInclude = /etc/pacman.d/mirrorlist\n\n[options]\nILoveCandy\nTotalDownload\nColor" >> /etc/pacman.conf
  49. fi
  50. echo -n "Are you going to use a flexo server?(y/N): "
  51. read flexo
  52. if [ "$flexo" = "y" ]; then
  53. echo -n "Please enter ip address of flexo server: "
  54. read flexo_ip
  55. echo -e "\nServer = http://$flexo_ip:7878/\$repo/os/\$arch\n" >> /etc/pacman.d/mirrorlist
  56. fi
  57. pacman -Syy
  58. echo -n "Did any errors occur?(y/N): "
  59. read errors
  60. if [ "$errors" = "y" ]; then
  61. echo "Dropping you into a shell so that you can fix them, once you quit the shell, the installation will continue from where you left off."
  62. bash
  63. fi
  64. touch /tmp/.blackarch
  65. fi
  66. clear
  67. echo "Please enter hostname: "
  68. read hostname
  69. echo $hostname > /etc/hostname
  70. echo "Set password for root: "
  71. passwd root
  72. echo "Please enter name for regular user:"
  73. read username
  74. useradd -m $username
  75. echo "Set password for user $username: "
  76. passwd $username
  77. usermod -aG wheel $username
  78. echo -e "127.0.0.1 localhost\n::1 localhost\n127.0.0.1 $hostname.localdomain $hostname" > /etc/hosts
  79. if [ -f "/install/encrypted" ]; then
  80. cat << EOF > /etc/initcpio/hooks/openswap
  81. run_hook ()
  82. {
  83. x=0;
  84. while [ ! -b /dev/mapper/root ] && [ \$x -le 10 ]; do
  85. x=$((x+1))
  86. sleep .2
  87. done
  88. mkdir crypto_key_device
  89. mount /dev/mapper/root crypto_key_device
  90. cryptsetup open --key-file crypto_key_device/root/.keys/swap-keyfile $swap swap
  91. umount crypto_key_device
  92. }
  93. EOF
  94. cat << EOF > /etc/initcpio/install/openswap
  95. build ()
  96. {
  97. add_runscript
  98. }
  99. help ()
  100. {
  101. cat<<HELPEOF
  102. This opens the swap encrypted partition $swap in /dev/mapper/swap
  103. HELPEOF
  104. }
  105. EOF
  106. if [ ! "$home" = "" ]; then
  107. cat << EOF > /etc/initcpio/hooks/openhome
  108. run_hook ()
  109. {
  110. x=0;
  111. while [ ! -b /dev/mapper/root ] && [ \$x -le 10 ]; do
  112. x=$((x+1))
  113. sleep .2
  114. done
  115. mkdir crypto_key_device
  116. mount /dev/mapper/root crypto_key_device
  117. cryptsetup open --key-file crypto_key_device/root/.keys/home-keyfile $home home
  118. umount crypto_key_device
  119. }
  120. EOF
  121. cat << EOF > /etc/initcpio/install/openhome
  122. build ()
  123. {
  124. add_runscript
  125. }
  126. help ()
  127. {
  128. cat<<HELPEOF
  129. This opens the swap encrypted partition $home in /dev/mapper/home
  130. HELPEOF
  131. }
  132. EOF
  133. cat << EOF > /etc/mkinitcpio.conf
  134. MODULES=(vfat i915)
  135. BINARIES=()
  136. FILES=()
  137. HOOKS=(base udev plymouth autodetect keyboard keymap consolefont modconf block plymouth-encrypt openswap openhome resume filesystems fsck)
  138. EOF
  139. else
  140. cat << EOF > /etc/mkinitcpio.conf
  141. MODULES=(vfat i915)
  142. BINARIES=()
  143. FILES=()
  144. HOOKS=(base udev plymouth autodetect keyboard keymap consolefont modconf block plymouth-encrypt openswap resume filesystems fsck)
  145. EOF
  146. fi
  147. else
  148. cat << EOF > /etc/mkinitcpio.conf
  149. MODULES=(vfat i915)
  150. BINARIES=()
  151. FILES=()
  152. HOOKS=(base udev plymouth autodetect keyboard keymap consolefont modconf block plymouth resume filesystems fsck)
  153. EOF
  154. fi
  155. pacman -Syu --noconfirm $(cat /install/packages.base | xargs)
  156. refind-install
  157. if [ -f "/install/encrypted" ]; then
  158. line=1
  159. blkid | while IFS= read -r i; do
  160. echo "$line: $i"
  161. ((line=line+1))
  162. done
  163. echo -n "Please select the device you will save the LUKS key to: "
  164. read keydev
  165. uuid=$(blkid | sed -n 's/.*UUID=\"\([^\"]*\)\".*/\1/p' | sed -n "$keydev"p)
  166. cat << EOF > /boot/refind_linux.conf
  167. "Boot with encryption" "root=/dev/mapper/root resume=/dev/mapper/swap cryptdevice=UUID=$(blkid -s UUID -o value $root):root:allow-discards cryptkey=UUID=$uuid:vfat:key.yeet rw loglevel=3 quiet splash"
  168. EOF
  169. clear
  170. else
  171. cat << EOF > /boot/refind_linux.conf
  172. "Boot without encryption" "root=UUID=$(blkid -s UUID -o value $root) resume=UUID=$(blkid -s UUID -o value $swap) rw loglevel=3 quiet splash"
  173. EOF
  174. fi
  175. mkdir -p /etc/sudoers.d
  176. echo "%wheel ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/nopwd
  177. sudo -u $username bash -c "git clone https://aur.archlinux.org/yay.git /tmp/yay"
  178. sudo -u $username bash -c "(cd /tmp/yay; makepkg --noconfirm -si)"
  179. sudo -u $username bash -c "yay --noconfirm -S plymouth"
  180. if [ -f "/install/artix" ]; then
  181. sudo -u $username bash -c "yay --noconfirm -S plymouth-openrc-plugin"
  182. fi
  183. clear
  184. echo -n "Would you like to automatically install my dotfiles?(y/N): "
  185. read dotfiles
  186. if [ "$dotfiles" = "y" ]; then
  187. pacman -R --noconfirm vim
  188. sudo -u $username bash -c "git clone --recurse-submodules https://github.com/theFr1nge/dotfiles.git ~/.dotfiles"
  189. sudo -u $username bash -c "(cd ~/.dotfiles; ./install.sh)"
  190. clear
  191. fi
  192. git clone https://github.com/adi1090x/plymouth-themes.git /tmp/pthemes
  193. cat << EOF > /etc/plymouth/plymouthd.conf
  194. [Daemon]
  195. Theme=sphere
  196. ShowDelay=0
  197. DeviceTimeout=8
  198. EOF
  199. cp -r /tmp/pthemes/pack_4/sphere /usr/share/plymouth/themes
  200. clear
  201. echo -e "/boot/EFI/refind\n2\n2" | sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/bobafetthotmail/refind-theme-regular/master/install.sh)"
  202. if [ -f "/install/artix" ]; then
  203. sudo rc-update add cronie
  204. sudo rc-update add acpi
  205. sudo rc-update add dbus
  206. sudo rc-update add connmand
  207. sudo rc-update add syslog-ng
  208. else
  209. systemctl enable connman
  210. systemctl enable cronie
  211. fi
  212. clear
  213. mkinitcpio -P
  214. if [ -f "/install/encrypted" ]; then
  215. vim /etc/fstab
  216. fi
  217. pacman --noconfirm -R nano # uninstall nano, eww
  218. clear
  219. rm -rf /etc/sudoers.d/nopwd
  220. echo "Defaults env_reset,pwfeedback" > /etc/sudoers.d/wheel
  221. echo "%wheel ALL=(ALL) ALL" >> /etc/sudoers.d/wheel
  222. echo "$username $hostname =NOPASSWD: /sbin/shutdown ,/sbin/halt,/sbin/reboot,/sbin/hibernate, /bin/pacman -Syyuw --noconfirm" >> /etc/sudoers.d/wheel
  223. ln -sf /bin/dash /bin/sh
  224. clear
  225. echo "SETUP COMPLETE"
  226. bash
  227. rm -rf /install