Advertisement
JaKKo7

Untitled

Apr 2nd, 2021
537
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.78 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Set correct time
  4. timedatectl set-ntp true
  5.  
  6. # Show disks
  7. lsblk
  8.  
  9. # Disk setup
  10. echo -n "What is the install device: "
  11. read -r device
  12. echo "Installing to $device... (Enter to continue)"
  13. read -r _
  14.  
  15. echo -n "Would you like to wipe and re-partition the disk $device?(Y/n): "
  16. read -r wipe
  17.  
  18. if [ ! "$wipe" = "n" ]; then
  19.     echo "[INFO]: Wiping the partition table..."
  20.     wipefs -a -f "$device"
  21.     sleep 1
  22. fi
  23.  
  24. clear
  25.  
  26. echo "Please create /boot /root partitions"
  27.  
  28. # Run cfdisk for manual partitioning
  29. cfdisk "$device"
  30.  
  31. clear
  32.  
  33. lsblk "$device"
  34. echo ""
  35. echo "Now you will specify the partitions you have created"
  36.  
  37. # Boot partition
  38. echo -n "Please enter boot partition (example: /dev/sda1): "
  39. read -r boot
  40.  
  41. # Root partition
  42. echo -n "Please enter root partition (example: /dev/sda1): "
  43. read -r root
  44.  
  45. # Swap partition
  46. echo -n "Did you create a swap partition?(y/N): "
  47. read -r swap_s
  48. if [ "$swap_s" = "y" ]; then
  49.     echo -n "Please enter swap partition (example: /dev/sda3): "
  50.     read -r swap
  51. fi
  52.  
  53. # Home partition
  54. echo -n "Did you create a home partition?(y/N): "
  55. read -r home_s
  56. if [ "$home_s" = "y" ]; then
  57.     echo -n "Please enter home partition (example: /dev/sda4): "
  58.     read -r home
  59. fi
  60.  
  61. # Create root partition
  62. echo "[INFO] Formatting root partition"
  63. mkfs.ext4 "$root"
  64. echo "[INFO] Mounting root partition"
  65. mount "$root" /mnt
  66.  
  67. # Create the boot partition
  68. echo "Do you want to use efi or legacy bios? (e/L): "
  69. read -r bios_s
  70. if [ "$bios_s" = "e" ]; then # efi
  71.     echo "[INFO] Formatting boot partition"
  72.     mkfs.fat -F32 "$boot"
  73.     echo "[INFO] Mounting boot partition"
  74.     mkdir /mnt/boot/EFI
  75.     mount "$boot" /mnt/boot/EFI
  76. else # legacy
  77.     echo "[INFO] Formatting boot partition"
  78.     mkfs.ext4 "$boot"
  79.     echo "[INFO] Mounting boot partition"
  80.     mkdir /mnt/boot
  81.     mount "$boot" /mnt/boot  
  82. fi
  83.  
  84. # Create swap partition
  85. if [ "$swap_s" = "y" ]; then
  86.     echo "[INFO] Creating swap partition"
  87.     mkswap "$swap"
  88.     echo "[INFO] Mounting swap partition"
  89.     swapon "$swap"
  90. fi
  91.  
  92. # Create home partition
  93. if [ "$home_s" = "y" ]; then
  94.     echo "[INFO] Creating home partition"
  95.     mkfs.ext4 "$home"
  96.     echo "[INFO] Mounting home partition"
  97.     mkdir /mnt/home
  98.     mount "$home" /mnt/home
  99. fi
  100.  
  101. # Install
  102. echo "[INFO] Installing required packages"
  103. pacstrap /mnt base base-devel linux linux-firmware git vim
  104.  
  105. # Generate fstab entries for mounted partitions
  106. echo "[INFO] Generating fstab entries for mounted partitions"
  107. genfstab -U /mnt >> /mnt/etc/fstab
  108.  
  109. # Change root directory to arch
  110. echo "[INFO] Change arch root directory to /mnt"
  111. arch-chroot /mnt
  112.  
  113. # Set zoneinfo
  114. echo "Please enter you zoneinfo (example /usr/share/zoneinfo/Europe/Warsaw): "
  115. read -r zoneinfo
  116. ln -sf "$zoneinfo" /etc/localtime
  117.  
  118. # Sync hardware clock
  119. echo "[INFO] Setting hardware clock"
  120. hwclock --systohc
  121.  
  122. echo "Please configure you locale, press ENTER to continue"
  123. read -r _
  124.  
  125. # Set locale
  126. vim /etc/locale.gen
  127.  
  128. echo "Press ENTER to continue"
  129. read -r _
  130.  
  131. echo "Please enter locale that you specified (example: en_US.UTF-8): "
  132. read -r  locale
  133. echo "[INFO] Setting locale"
  134. echo "LANG=$locale" >> /etc/locale.conf
  135.  
  136. # Generate locales
  137. echo "[INFO] Generating locales"
  138. locale-gen
  139.  
  140. # Set keyboard
  141. echo "Do you want to set keyboard layout? (y/N): "
  142. read -r keyboard_s
  143. if [ "$keyboard_s" = "y" ]; then
  144.     echo "Do you want to see all possible keyboard layouts? (y/N): "
  145.     read -r layouts_s
  146.     if [ "$layouts_s" = "y" ]; then
  147.         localectl list-keymaps
  148.     fi
  149.     echo "Please enter you keymap (example: us): "
  150.     read -r keymap
  151.     echo "[INFO] Setting new keymap"
  152.     loocalectl set-keymap --noconvert "$keymap"
  153. fi
  154.  
  155. # Hostname
  156. echo "Do you want to change hostname? (Y/n): "
  157. read -r keyboard_s
  158. if [ ! "$keyboard_s" = "n" ]; then
  159.     echo "Please enter your hostname: "
  160.     read -r new_hostname
  161.     echo "[INFO] Setting new hostname"
  162.     echo "$new_hostname" > /etc/hostname
  163. fi
  164.  
  165. # Root password
  166. echo "Do you want to change root password? (Y/n): "
  167. read -r root_s
  168. if [ ! "$root_s" = "n" ]; then
  169.     echo "[INFO] Setting root password"
  170.     passwd
  171. fi
  172.  
  173. # Install network manager and grub
  174. echo "[INFO] Installing networkmanager and grub"
  175. pacman -S networkmanager grub
  176.  
  177. # Start network manager on start
  178. echo "[INFO] Setting network manager to run on start"
  179. systemctl enable NetworkManager
  180.  
  181. # Configure grub
  182. echo "[INFO] Configuring grub"
  183. if [ "$bios_s" = "e" ]; then # efi bios
  184.     pacman -S efibootmgr
  185.     grub-instalol --target=x86_64-efit --efi-directory=/boot/EFI --bootloader-id=GRUB
  186.     grub-mkconfig -o /boot/grub/grub.cfg
  187. else # legacy bios
  188.     grub-install "$device"
  189.     grub-mkconfig -o /boot/grub/grub.cfg
  190. fi
  191.  
  192. # end
  193. echo "Installation has finished, you can now unmount and reboot"
  194. echo "Look if there were any errors, GL&HF"
  195.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement