From 2a19062b15d411ecebb436d753272226835269b2 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 16 Dec 2016 22:24:26 -0500 Subject: [PATCH] os/arch: add bootstrap script for new Arch builds --- os/arch/bootstrap | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 os/arch/bootstrap diff --git a/os/arch/bootstrap b/os/arch/bootstrap new file mode 100755 index 00000000..3e7223ab --- /dev/null +++ b/os/arch/bootstrap @@ -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"