#!/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 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" 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 () { echo " - Formatting disk..." #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 echo " - Mounting partitions..." mount ${DISK}2 /mnt mkdir /mnt/boot mount ${DISK}1 /mnt/boot } sysinstall () { pacstrap /mnt arch-chroot /mnt bootctl install genfstab -t PARTUUID /mnt >> /mnt/etc/fstab echo "HOSTNAME" > /mnt/etc/HOSTNAME arch-chroot /mnt useradd -mU -s /usr/bin/zsh -G wheel,uucp,video,audio,storage,games,input $USER arch-chroot /mnt chsh -s /usr/bin/zsh 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