commit 791248abf009c967780a4b46613c8792f5aa5f8d Author: Thomas Cole Date: Tue Jun 29 09:35:04 2021 -0400 first commit diff --git a/archinstall.sh b/archinstall.sh new file mode 100755 index 0000000..996f427 --- /dev/null +++ b/archinstall.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +RED="\e[31m" +GREEN="\e[32m" +YELLOW="\e[33m" +BLUE="\e[34m" +MAGENTA="\e[35m" +CYAN="\e[36m" +ENDCOLOR="\e[0m" + +MACADDRS=( + 40:6c:8f:b8:ba:xx + 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 +) + +#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/enp10s0/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 () { + DISK="/dev/vda" + + 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 + +} + +###################################################################################### + +#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 +else + echoc "Prechecks failed!" $RED +fi \ No newline at end of file