os/arch: add bootstrap script for new Arch builds

This commit is contained in:
Henrik Lissner 2016-12-16 22:24:26 -05:00
parent 9cb8ce5625
commit 2a19062b15

61
os/arch/bootstrap Executable file
View file

@ -0,0 +1,61 @@
#!/usr/bin/env bash
# This script bootstraps arch linux with the utmost essentials. It expects an internet
# connection, and the harddrives to be set up (and one of the mounted to /mnt).
MOUNT=/mnt
USERNAME=hlissner
exists() { command -v "$1" >/dev/null; }
arch() { arch-chroot "$MOUNT" /bin/bash -c "$1"; }
pac() { pacstrap "$MOUNT" $@; }
if ! exists arch-chroot; then
>&2 echo "Meant to be run from the Arch Linux installer"
exit 1
elif ! grep "$MOUNT " /proc/mounts >/dev/null; then
>&2 echo "$MOUNT isn't mounted"
exit 2
elif ! echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1; then
>&2 echo "No internet connection detected!"
exit 3
fi
# bootstrap
pac base base-devel intel-ucode
# device mounting drivers
pac dosfstools ntfs-3g exfat-utils hfsprogs
# hostname
read -p "Enter computer hostname: " host
echo "$host" > "$MOUNT/etc/hostname"
# networking support
WIRELESS_DEV=$(ip link | grep wlp | awk '{print $2}'| sed 's/://' | sed '1!d')
if [[ $WIRELESS_DEV ]]; then
echo "==> ${WIRELESS_DEV} interface detected"
pac iw wireless_tools wpa_actiond wpa_supplicant dialog
fi
WIRED_DEV=$(ip link | grep "en[sop]" | awk '{print $2}'| sed 's/://' | sed '1!d')
if [[ $WIRED_DEV ]]; then
echo "==> ${WIRED_DEV} interface detected"
arch "systemctl enable dhcpcd@${WIRED_DEV}.service"
fi
# Speed up connections on boot
if ! grep "^noarp$" $MOUNT/etc/dhcpcd.conf; then
echo -e "\nnoarp" >> $MOUNT/etc/dhcpcd.conf
fi
# locale
sed -i '/^#en_US\.UTF-8/s/^#//' $MOUNT/etc/locale.gen
arch "locale-gen"
# datetime
pac ntp
arch "systemctl enable ntpd.service"
arch "ln -sfv /usr/share/zoneinfo/America/Toronto /etc/localtime"
# finalization
genfstab -U "$MOUNT" >> "$MOUNT/etc/fstab"
arch "bootctl --path=/boot install"
arch "mkinitcpio -p linux"