larbs

Luke's Auto-Rice Bootstrapping Scripts: Auto-Setup & Configure Arch Linux
Log | Files | Refs | README | LICENSE

arch.sh (2456B)


      1 #!/bin/bash
      2 
      3 #This is a lazy script I have for auto-installing Arch.
      4 #It's not officially part of LARBS, but I use it for testing.
      5 #DO NOT RUN THIS YOURSELF because Step 1 is it reformatting /dev/sda WITHOUT confirmation,
      6 #which means RIP in peace qq your data unless you've already backed up all of your drive.
      7 
      8 pacman -Sy --noconfirm dialog || { echo "Error at script start: Are you sure you're running this as the root user? Are you sure you have an internet connection?"; exit; }
      9 
     10 dialog --defaultno --title "DON'T BE A BRAINLET!" --yesno "This is an Arch install script that is very rough around the edges.\n\nOnly run this script if you're a big-brane who doesn't mind deleting your entire /dev/sda drive.\n\nThis script is only really for me so I can autoinstall Arch.\n\nt. Luke"  15 60 || exit
     11 
     12 dialog --defaultno --title "DON'T BE A BRAINLET!" --yesno "Do you think I'm meming? Only select yes to DELET your entire /dev/sda and reinstall Arch.\n\nTo stop this script, press no."  10 60 || exit
     13 
     14 dialog --no-cancel --inputbox "Enter a name for your computer." 10 60 2> comp
     15 
     16 dialog --defaultno --title "Time Zone select" --yesno "Do you want use the default time zone(America/New_York)?.\n\nPress no for select your own time zone"  10 60 && echo "America/New_York" > tz.tmp || tzselect > tz.tmp
     17 
     18 dialog --no-cancel --inputbox "Enter partitionsize in gb, separated by space (swap & root)." 10 60 2>psize
     19 
     20 IFS=' ' read -ra SIZE <<< $(cat psize)
     21 
     22 re='^[0-9]+$'
     23 if ! [ ${#SIZE[@]} -eq 2 ] || ! [[ ${SIZE[0]} =~ $re ]] || ! [[ ${SIZE[1]} =~ $re ]] ; then
     24     SIZE=(12 25);
     25 fi
     26 
     27 timedatectl set-ntp true
     28 
     29 cat <<EOF | fdisk /dev/sda
     30 o
     31 n
     32 p
     33 
     34 
     35 +200M
     36 n
     37 p
     38 
     39 
     40 +${SIZE[0]}G
     41 n
     42 p
     43 
     44 
     45 +${SIZE[1]}G
     46 n
     47 p
     48 
     49 
     50 w
     51 EOF
     52 partprobe
     53 
     54 yes | mkfs.ext4 /dev/sda4
     55 yes | mkfs.ext4 /dev/sda3
     56 yes | mkfs.ext4 /dev/sda1
     57 mkswap /dev/sda2
     58 swapon /dev/sda2
     59 mount /dev/sda3 /mnt
     60 mkdir -p /mnt/boot
     61 mount /dev/sda1 /mnt/boot
     62 mkdir -p /mnt/home
     63 mount /dev/sda4 /mnt/home
     64 
     65 pacman -Sy --noconfirm archlinux-keyring
     66 
     67 pacstrap /mnt base base-devel
     68 
     69 genfstab -U /mnt >> /mnt/etc/fstab
     70 cat tz.tmp > /mnt/tzfinal.tmp
     71 rm tz.tmp
     72 mv comp /mnt/etc/hostname
     73 curl https://raw.githubusercontent.com/LukeSmithxyz/LARBS/master/testing/chroot.sh > /mnt/chroot.sh && arch-chroot /mnt bash chroot.sh && rm /mnt/chroot.sh
     74 
     75 
     76 dialog --defaultno --title "Final Qs" --yesno "Reboot computer?"  5 30 && reboot
     77 dialog --defaultno --title "Final Qs" --yesno "Return to chroot environment?"  6 30 && arch-chroot /mnt
     78 clear