#!/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='$6$xyz$qss5rNcJjj5Efn1tSkCaplTQXVbQlmXkjxOd/FQvZzlKSRg/DUalJkPaoiJZkAS.wDCt9b1eA3CWePHvQDi5T.' ROOTPASSWD='$6$xyz$gEODDI4x8qnkooLncD8E6cWTgh546DtGoIva9qKqOcon.XA.lBFhq2mvQLlOhA1k9W7.gnTwoMCNlPa6MZt9R.' PACKAGES=( networkmanager xorg-server xfce4 lightdm-gtk-greeter arc-gtk-theme chromium noto-fonts noto-fonts-emoji noto-fonts-extra ) #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 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 return -1 else echoc " - Internet connectivity check passed." $GREEN fi return 1 } partition () { echoc " - Formatting disk..." $GREEN #DANGER ZONE parted --script $DISK -- mklabel gpt mkpart ESP fat32 1Mib 500MiB set 1 boot on mkpart primary ext4 500MiB 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 return 1 } sysinstall () { echoc " - Updating mirror list. This might take a while." $GREEN reflector --protocol https --sort rate --country 'United States' --save /etc/pacman.d/mirrorlist --verbose echoc " - Installing system." $GREEN pacstrap /mnt base linux linux-firmware nano echoc " - Installing bootloader." $GREEN arch-chroot /mnt pacman -Sy --noconfirm grub efibootmgr os-prober echo "GRUB_DISABLE_OS_PROBER=false" > /mnt/etc/default/grub arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg echoc " - Updating fstab." $GREEN genfstab -t PARTUUID /mnt >> /mnt/etc/fstab echoc " - Setting Hostname." $GREEN echo "$HOSTNAME" > /mnt/etc/HOSTNAME echoc " - Setting shell." $GREEN arch-chroot /mnt chsh -s /bin/bash echoc " - Adding Users." $GREEN arch-chroot /mnt useradd -mU -s /bin/bash -G wheel,uucp,video,audio,storage,games,input $USER echo "$USER:$PASSWD" | chpasswd -e --root /mnt echo "root:$ROOTPASSWD" | chpasswd -e --root /mnt return 1 } setup () { echoc " - Installing packages." $GREEN PKG=${PACKAGES[@]} arch-chroot /mnt pacman -Sy --noconfirm $PKG arch-chroot /mnt systemctl enable NetworkManager arch-chroot /mnt systemctl enable lightdm curl https://git.thomaspcole.com/thomascole/AALI/raw/branch/master/firstboot.sh > /mnt/home/clc/firstboot.sh curl https://git.thomaspcole.com/thomascole/AALI/raw/branch/master/fb.desktop > /mnt/home/clc/fb.desktop curl https://git.thomaspcole.com/thomascole/AALI/raw/branch/master/clclogo.png > /mnt/home/clc/clclogo.png chmod +x /mnt/home/clc/firstboot.sh chmod +x /mnt/home/clc/fb.desktop return 1 } ###################################################################################### #Check if root if [ $EUID -ne 0 ]; then echo "This script must be run as root" exit 1 fi echo "AALI - 1.0" #run each step and check output for completion prechecks if [ $? -eq 1 ]; then echo "Prechecks passed!" partition else echoc "Prechecks failed!" $RED return -1 fi #partition good if [ $? -eq 1 ]; then echo "Partitioning complete!" sysinstall else echoc "Partitioning failed." $RED return -1 fi #sysinstall good if [ $? -eq 1 ]; then echo "Base system installation complete!" setup else echoc "System installation failed!" $RED fi #sysinstall good if [ $? -eq 1 ]; then echo "Pre-boot setup complete." echo "A configuration script will be executed at first login." else echoc "Pre-boot setup failed!" $RED fi