#!/bin/bash while getopts "p:n:d:" opt; do case $opt in p) PASSWD=${OPTARG} ;; n) NAME=${OPTARG} ;; d) DEV=${OPTARG} ;; \?) echo "-$OPTARG is not valid" >&2 && exit ;; esac done init() { [ -z "$NAME" ] && read -p "Hostname: " NAME while [ -z "$PASSWD" ] || [ ! "$PASSWD" = "$CHECK" ]; do read -sp "Root password: " PASSWD echo read -sp "Repeat: " CHECK done # Show some possible disks [ -z "$DEV" ] && lsblk -nrpo "name,size,model" && read -p "Provide installation medium (e.g. sda, nvme0n1): " DEV [[ "$DEV" =~ sd[a-z] ]] && SUF="1-3" && MODE="SATA" [[ "$DEV" =~ nvme[0-9]n[0-9] ]] && SUF="p1-3" && MODE="NVME" echo "+---------------------+" echo "| Archlinux Bootstrap |" echo "+---------------------+" echo "HOSTNAME = $NAME" echo "ROOTPASSWD = ${PASSWD:0:1}***${PASSWD: -1}" echo "DEVICEPARTS = $DEV$SUF" read -p "Do you want to continue with these values (y/n): " cont [ ! "$cont" = "y" ] && unset NAME PASSWD DEV && init echo "Let's GOOOO" } # stop on error set -e # initialize important values init # All values set, start bootstrapping gdisk /dev/$DEV < see good2know pacstrap /mnt base base-devel linux linux-firmware vi dhcpcd wpa_supplicant dialog git netctl curl genfstab -p /mnt > /mnt/etc/fstab cat < /mnt/root/bootstrap2.sh #!/bin/bash ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime echo "en_US.UTF-8 UTF-8" > /etc/locale.gen locale-gen echo "LANG=en_US.UTF-8" > /etc/locale.conf echo $NAME > /etc/hostname mkinitcpio -p linux pacman -Sy --noconfirm efibootmgr dosfstools gptfdisk bootctl install # MAYBE: add intel-ucode images, check for amd cat < /boot/loader/entries/arch-uefi.conf title Arch linux /vmlinuz-linux initrd /initramfs-linux.img options root=LABEL=P_ROOT rw resume=LABEL=P_SWAP EEE cat < /boot/loader/entries/arch-uefi-fallback.conf title Arch Linux Fallback linux /vmlinuz-linux initrd /initramfs-linux-fallback.img options root=LABEL=P_ROOT rw resume=LABEL=P_SWAP EEE cat < /boot/loader/loader.conf default arch-uefi timeout 1 EEE pacman --noconfirm -Sy reflector reflector --country 'Germany' --sort rate --protocol https --save /etc/pacman.d/mirrorlist printf "${PASSWD}\n${PASSWD}\n" | passwd root cd && curl -L https://g.phga.de/toerd/fresh/archive/master.tar.gz -o fresh.tar.gz && tar -xzf fresh.tar.gz # basically a shitty one time job echo '/root/fresh/fresh.sh' > .bashrc exit EOF chmod u+x /mnt/root/bootstrap2.sh arch-chroot /mnt /root/bootstrap2.sh rm /mnt/root/bootstrap2.sh && rm ./bootstrap.sh # reboot