#!/bin/bash RED="\e[31m" GREEN="\e[32m" YELLOW="\e[33m" BLUE="\e[34m" MAGENTA="\e[35m" CYAN="\e[36m" ENDCOLOR="\e[0m" MACADDRS=( 52:54:00:2a:41:b1 52:54:00:a9:73:cb 1c:69:7a:63:ad:12 1c:69:7a:63:83:e1 1c:69:7a:63:ac:45 1c:69:7a:63:ac:b2 1c:69:7a:63:ad:5d 1c:69:7a:63:99:c4 1c:69:7a:63:ad:46 ) DISK="/dev/vda" HOSTNAME="arch-testing" USER="clc" PASSWD="$1$8nWcCPFE$SMC36PPfImzmQ9E3WEPvy1" ROOTPASSWD="$1$8g0M2I8t$GNnx5EkVhu1Ykw7NuKZos." #Echo text with a color passed as the second arguement echoc () { echo -e "$2$1${ENDCOLOR}" #Color, Text, Reset color } printhr () { for i in {0..80}; do echo -n "-"; done echo "" } prechecks () { echoc "Running Pre-checks" $GREEN #Check MAC whitelist DMAC=$(cat /sys/class/net/enp1s0/address) if [[ " ${MACADDRS[@]} " =~ " $DMAC " ]]; then echoc " - Matching MAC Address found." $GREEN return 1 else echoc " - No Matching MAC Address found. Abort!" $RED return -1 fi #Check internet pingIP=$(ping -c 5 -i 0.2 8.8.8.8 | grep -i received | awk '{print $4}') if [[ 0 -eq $pingIP ]]; then echoc " - Internet connectivity check failed. Abort!" $RED else echoc " - Internet connectivity check passed." $GREEN fi } partition () { echoc " - Formatting disk..." $GREEN #DANGER ZONE parted --script $DISK -- mklabel gpt mkpart ESP fat32 1Mib 129MiB set 1 boot on mkpart primary ext4 129MiB 100% wipefs ${DISK}1 wipefs ${DISK}2 mkfs.vfat -F32 ${DISK}1 mkfs.ext4 ${DISK}2 #END DANGER ZONE echoc " - Mounting partitions..." $GREEN mount ${DISK}2 /mnt mkdir /mnt/boot mount ${DISK}1 /mnt/boot } sysinstall () { echoc " - Updating mirror list. This might take a while." $YELLOW reflector --protocol https --sort rate --country 'United States' --save /etc/pacman.d/mirrorlist --verbose echoc " - Installing system." $GREEN pacstrap /mnt echoc " - Installing bootloader." $GREEN grub-install --target=x86_64-efi --efi-directory=esp --bootloader-id=GRUB grub-mkconfig -o /boot/grub/grub.cfg #arch-chroot /mnt bootctl install #echo "default arch timeout 4" > /mnt/boot/loader/loader.conf #echo "title Arch Linux linux /vmlinuz-linux initrd /initramfs-linux.img options root=PARTUUID=$(blkid -s PARTUUID -o value "$part_root") rw" > /mnt/boot/loader/entries/arch.conf echoc " - Updating fstab." $GREEN genfstab -t PARTUUID /mnt >> /mnt/etc/fstab echoc " - Setting Hostname." $GREEN echo "$HOSTNAME" > /mnt/etc/HOSTNAME arch-chroot /mnt useradd -mU -s /bin/bash -G wheel,uucp,video,audio,storage,games,input $USER arch-chroot /mnt chsh -s /bin/bash echo "$USER:$PASSWD" | chpasswd -e --root /mnt echo "root:$ROOTPASSWD" | chpasswd -e --root /mnt } ###################################################################################### #Check if root if [ $EUID -ne 0 ]; then echo "This script must be run as root" exit 1 fi echo "AALI - 1.0" prechecks if [ $? -eq 1 ]; then echo "Prechecks passed!" partition sysinstall else echoc "Prechecks failed!" $RED fi