AALI/archinstall.sh

196 lines
4.6 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 14:14:28 -04:00
PASSWD='$6$xyz$qss5rNcJjj5Efn1tSkCaplTQXVbQlmXkjxOd/FQvZzlKSRg/DUalJkPaoiJZkAS.wDCt9b1eA3CWePHvQDi5T.'
2021-06-30 15:29:01 -04:00
ROOTPASSWD='$6$xyz$gEODDI4x8qnkooLncD8E6cWTgh546DtGoIva9qKqOcon.XA.lBFhq2mvQLlOhA1k9W7.gnTwoMCNlPa6MZt9R.'
2021-06-30 09:14:26 -04:00
2021-06-30 15:58:17 -04:00
PACKAGES=(
networkmanager
2021-07-01 15:16:14 -04:00
xorg-server
2021-07-01 14:58:22 -04:00
xfce4
lightdm-gtk-greeter
2021-07-06 09:15:15 -04:00
arc-gtk-theme
chromium
noto-fonts
noto-fonts-emoji
noto-fonts-extra
2021-06-30 15:58:17 -04:00
)
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
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
2021-06-30 11:49:03 -04:00
return -1
2021-06-29 09:35:04 -04:00
else
echoc " - Internet connectivity check passed." $GREEN
fi
2021-06-30 11:49:03 -04:00
return 1
2021-06-29 09:35:04 -04:00
}
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 500MiB set 1 boot on mkpart primary ext4 500MiB 100%
2021-06-29 09:35:04 -04:00
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 15:17:42 -04:00
return 1
2021-06-29 09:35:04 -04:00
}
2021-06-30 08:50:34 -04:00
sysinstall () {
2021-06-30 15:17:42 -04:00
echoc " - Updating mirror list. This might take a while." $GREEN
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 15:58:17 -04:00
pacstrap /mnt base linux linux-firmware nano
2021-06-30 08:52:02 -04:00
2021-06-30 09:36:31 -04:00
echoc " - Installing bootloader." $GREEN
arch-chroot /mnt pacman -Sy --noconfirm grub efibootmgr os-prober
echo "GRUB_DISABLE_OS_PROBER=false" > /mnt/etc/default/grub
2021-06-30 11:49:03 -04:00
arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
2021-06-30 11:41:25 -04:00
arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg
2021-06-30 09:14:26 -04:00
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
2021-06-30 15:17:42 -04:00
echoc " - Setting shell." $GREEN
arch-chroot /mnt chsh -s /bin/bash
2021-06-30 09:14:26 -04:00
2021-06-30 15:17:42 -04:00
echoc " - Adding Users." $GREEN
arch-chroot /mnt useradd -mU -s /bin/bash -G wheel,uucp,video,audio,storage,games,input $USER
2021-06-30 14:09:10 -04:00
echo "$USER:$PASSWD" | chpasswd -e --root /mnt
2021-06-30 14:18:59 -04:00
echo "root:$ROOTPASSWD" | chpasswd -e --root /mnt
2021-06-30 15:17:42 -04:00
return 1
2021-06-30 08:50:34 -04:00
}
2021-06-30 15:58:17 -04:00
setup () {
echoc " - Installing packages." $GREEN
PKG=${PACKAGES[@]}
arch-chroot /mnt pacman -Sy --noconfirm $PKG
2021-07-01 15:07:38 -04:00
arch-chroot /mnt systemctl enable NetworkManager
arch-chroot /mnt systemctl enable lightdm
2021-07-01 14:58:22 -04:00
2021-07-06 09:55:35 -04:00
curl https://git.thomaspcole.com/thomascole/AALI/raw/branch/master/firstboot.sh > /mnt/home/clc/firstboot.sh
2021-07-07 20:42:27 -04:00
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
2021-07-06 09:58:49 -04:00
chmod +x /mnt/home/clc/firstboot.sh
2021-07-07 20:42:27 -04:00
chmod +x /mnt/home/clc/fb.desktop
2021-07-06 09:58:49 -04:00
2021-07-07 08:50:57 -04:00
return 1
2021-06-30 15:58:17 -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"
2021-06-30 15:17:42 -04:00
#run each step and check output for completion
2021-06-29 09:35:04 -04:00
prechecks
if [ $? -eq 1 ]; then
echo "Prechecks passed!"
partition
else
echoc "Prechecks failed!" $RED
2021-06-30 15:17:42 -04:00
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!"
2021-06-30 15:58:17 -04:00
setup
2021-06-30 15:17:42 -04:00
else
echoc "System installation failed!" $RED
2021-07-07 08:16:32 -04:00
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
2021-06-29 09:35:04 -04:00
fi