AALI/archinstall.sh

135 lines
3.2 KiB
Bash
Raw Normal View History

2021-06-29 09:35:04 -04:00
#!/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
2021-06-30 10:03:35 -04:00
52:54:00:a9:73:cb
2021-06-29 09:35:04 -04:00
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
)
2021-06-30 09:14:26 -04:00
DISK="/dev/vda"
HOSTNAME="arch-testing"
2021-06-30 09:36:31 -04:00
USER="clc"
2021-06-30 09:14:26 -04:00
PASSWD="$1$8nWcCPFE$SMC36PPfImzmQ9E3WEPvy1"
ROOTPASSWD="$1$8g0M2I8t$GNnx5EkVhu1Ykw7NuKZos."
2021-06-29 09:35:04 -04:00
#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
2021-06-30 08:50:34 -04:00
DMAC=$(cat /sys/class/net/enp1s0/address)
2021-06-29 09:35:04 -04:00
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 () {
2021-06-30 09:14:26 -04:00
2021-06-29 09:35:04 -04:00
2021-06-30 09:36:31 -04:00
echoc " - Formatting disk..." $GREEN
2021-06-29 09:35:04 -04:00
#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
2021-06-30 09:36:31 -04:00
echoc " - Mounting partitions..." $GREEN
2021-06-29 09:35:04 -04:00
mount ${DISK}2 /mnt
mkdir /mnt/boot
mount ${DISK}1 /mnt/boot
}
2021-06-30 08:50:34 -04:00
sysinstall () {
2021-06-30 09:36:31 -04:00
echoc " - Updating mirror list. This might take a while." $YELLOW
reflector --protocol https --sort rate --country 'United States' --save /etc/pacman.d/mirrorlist --verbose
2021-06-30 09:36:31 -04:00
echoc " - Installing system." $GREEN
2021-06-30 08:50:34 -04:00
pacstrap /mnt
2021-06-30 08:52:02 -04:00
2021-06-30 09:36:31 -04:00
echoc " - Installing bootloader." $GREEN
2021-06-30 11:36:51 -04:00
grub-install --target=x86_64-efi --efi-directory=esp --bootloader-id=GRUB --boot-directory=/mnt/boot
2021-06-30 10:03:35 -04:00
grub-mkconfig -o /boot/grub/grub.cfg
2021-06-30 09:14:26 -04:00
2021-06-30 10:03:35 -04:00
#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
2021-06-30 09:36:31 -04:00
echoc " - Updating fstab." $GREEN
2021-06-30 09:14:26 -04:00
genfstab -t PARTUUID /mnt >> /mnt/etc/fstab
2021-06-30 09:36:31 -04:00
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
2021-06-30 09:14:26 -04:00
echo "$USER:$PASSWD" | chpasswd -e --root /mnt
echo "root:$ROOTPASSWD" | chpasswd -e --root /mnt
2021-06-30 08:50:34 -04:00
}
2021-06-29 09:35:04 -04:00
######################################################################################
#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
2021-06-30 09:14:26 -04:00
sysinstall
2021-06-29 09:35:04 -04:00
else
echoc "Prechecks failed!" $RED
fi