diff --git a/.archlinux/install-scripts/001-preinstall b/.archlinux/install-scripts/001-preinstall index f973e3b4..fad7dd6f 100755 --- a/.archlinux/install-scripts/001-preinstall +++ b/.archlinux/install-scripts/001-preinstall @@ -1,7 +1,6 @@ #!/bin/sh # -# This script assumes you already have an active internet connection -# (preferably through Ethernet). +# Make partitions # # https://wiki.archlinux.org/index.php/Installation_guide @@ -14,9 +13,9 @@ timedatectl set-ntp true # enable boot for it. Then, create a primary swap partition with # the remaining disk space. parted /dev/sda mklabel msdos -parted /dev/sda mkpart primary ext4 1MiB 60GiB +parted /dev/sda mkpart primary ext4 1MiB "$DISTSIZE"GiB parted /dev/sda set 1 boot on -parted /dev/sda mkpart primary linux-swap 60GiB 100% +parted /dev/sda mkpart primary linux-swap "$DISTSIZE"GiB 100% # Format sda1 with ext4 and sda2 with swap mkfs -t ext4 /dev/sda1 diff --git a/.archlinux/install-scripts/002-install b/.archlinux/install-scripts/002-install index 4a6cfe43..0bbddbfa 100755 --- a/.archlinux/install-scripts/002-install +++ b/.archlinux/install-scripts/002-install @@ -1,13 +1,9 @@ #!/bin/sh # -# Install the base packages to the mounted partition (the newly -# created filesystem). -# -# We also install grub and fish since grub is the boot loader -# and fish is the preferred shell. +# Install packages to new filesystem # # https://wiki.archlinux.org/index.php/Installation_guide set -xe -pacstrap /mnt base base-devel grub fish +pacstrap /mnt base base-devel grub fish polkit rng-tools diff --git a/.archlinux/install-scripts/003-configure b/.archlinux/install-scripts/003-configure index 52826c35..e2d83010 100755 --- a/.archlinux/install-scripts/003-configure +++ b/.archlinux/install-scripts/003-configure @@ -1,15 +1,11 @@ #!/bin/sh # -# Once this script finishes, change the root password with passwd, -# then unmount /mnt (with umount) and restart the system. +# Core system configs # # https://wiki.archlinux.org/index.php/Installation_guide set -xe -echo -n "Enter a hostname for this machine: " -read HOSTNAME - # Generate the fstab file (so the filesystem is mounted on boot) genfstab -U /mnt > /mnt/etc/fstab @@ -27,18 +23,19 @@ echo "127.0.0.1 localhost" >> /mnt/etc/hosts echo "::1 localhost" >> /mnt/etc/hosts echo "127.0.1.1 $HOSTNAME.localdomain $HOSTNAME" >> /mnt/etc/hosts -# Set the language to English and use the en_US.UTF-8 locale. -echo "LANG=en_US.UTF-8" > /mnt/etc/locale.conf -echo "en_US.UTF-8 UTF-8" > /mnt/etc/locale.gen - -# Generate the locale. +# Declare which locales we want to generate and generate them +sed -i '/#en_US.UTF-8 UTF-8/s/^#//g' /mnt/etc/locale.gen +sed -i '/#fr_FR.UTF-8 UTF-8/s/^#//g' /mnt/etc/locale.gen +sed -i '/#ja_JP.UTF-8 UTF-8/s/^#//g' /mnt/etc/locale.gen arch-chroot /mnt locale-gen -# Explicitly set the keymap to US. -echo "KEYMAP=us" > /mnt/etc/vconsole.conf +# Set the system locale to the generated en_US.UTF-8 +echo "LANG=en_US.UTF-8" > /mnt/etc/locale.conf -# Change the terminal font to a larger one (`latarcyrheb-sun32` is also an option) -echo "FONT=ter-132n" >> /mnt/etc/vconsole.conf +# Set the tty font to a larger one (same as the default setfont, but larger) +if [ "$HIDPI" == "YES" ]; then + echo "FONT=latarcyrheb-sun32" > /mnt/etc/vconsole.conf +fi # Install grub to the primary partition. arch-chroot /mnt grub-install /dev/sda @@ -51,8 +48,3 @@ arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg # Change the shell of the root account to fish. arch-chroot /mnt chsh -s /usr/bin/fish - -# Save our hardware information with mkinitcpio. This creates -# an initial ramdisk environment that allows us to boot the -# Linux kernel. -arch-chroot /mnt mkinitcpio -p linux diff --git a/.archlinux/install-scripts/004-postinstall b/.archlinux/install-scripts/004-postinstall index 55c1a4de..844ab7ec 100755 --- a/.archlinux/install-scripts/004-postinstall +++ b/.archlinux/install-scripts/004-postinstall @@ -1,30 +1,38 @@ #!/bin/sh # -# Common post-install system configuration that doesn't involve any -# external packages (besides fish) +# Higher-level configs # # https://wiki.archlinux.org/index.php/General_recommendations set -xe -echo -n "Enter a username for the local account with administrative rights: " -read USERNAME +# Create the output directories if they don't exist yet +arch-chroot /mnt mkdir -p /etc/systemd/system/multi-user.target.wants +arch-chroot /mnt mkdir -p /etc/systemd/system/sysinit.target.wants -# Start and enable the DHCP client daemon service -systemctl enable --now dhcpcd.service +# Enable the DHCP client daemon service +arch-chroot /mnt ln -sf /usr/lib/systemd/system/dhcpcd.service \ + /etc/systemd/system/multi-user.target.wants/dhcpcd.service -# Sync the time periodically with a remote server -timedatectl set-ntp true +# Enable the timesync daemon service (sync the time periodically with a remote server) +arch-chroot /mnt ln -sf /usr/lib/systemd/system/systemd-timesyncd.service \ + /etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service + +# Enable the rng-tools daemon +arch-chroot /mnt ln -sf /usr/lib/systemd/system/rngd.service \ + /etc/systemd/system/sysinit.target.wants/rngd.service # Enable colors in pacman by uncommenting the Color line. -sed -i '/Color/s/^#//g' /etc/pacman.conf -sed -i '/VerbosePkgLists/s/^#//g' /etc/pacman.conf +sed -i '/Color/s/^#//g' /mnt/etc/pacman.conf + +# Show package upgrades as a list +sed -i '/VerbosePkgLists/s/^#//g' /mnt/etc/pacman.conf # Give users in the wheel group permission to use sudo -echo "%wheel ALL=(ALL) ALL" >> /etc/sudoers +echo "%wheel ALL=(ALL) ALL" > /mnt/etc/sudoers.d/01_wheel_all # Create a new user account with sudo privileges and the fish shell. arch-chroot /mnt useradd -m -g users -G wheel -s /usr/bin/fish "$USERNAME" -# Then, set the password equal to the username (change this later). -echo "$USERNAME:$USERNAME" | chpasswd +# Lock the root account (i.e. disable root login) +arch-chroot /mnt passwd -l root diff --git a/.archlinux/install-scripts/install.sh b/.archlinux/install-scripts/install.sh new file mode 100755 index 00000000..fca05463 --- /dev/null +++ b/.archlinux/install-scripts/install.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# Simple Arch Linux install scripts, tailored to my use case. + +# End the script on any errors +set -e + +# Change the working directory to this one +cd "$(dirname "$0")" + +# Prompt for the required information + +echo -n "Enter the size (in GiB) to give the primary partition: " +read DISTSIZE + +echo -n "Enter a username for the user with sudo rights: " +read USERNAME + +echo -n "Enter a hostname for this machine ($USERNAME@_____): " +read HOSTNAME + +echo -n "Type YES to enable HiDPI support in the virtual console: " +read HIDPI + +echo "-----------------------------------------------------" +echo "Arch Linux will be installed with the settings above." +echo "NOTE: You should not run this script if you do not" +echo " understand what it does. Bad things may happen." +echo -n "Type YES to continue, or Ctrl+C to abort. " +read CONFIRM + +if [ "$CONFIRM" != "YES" ]; then + echo "YES was not given, exiting..." + exit +fi + +echo "=====================================================" +echo "Running install scripts..." + +# Run the install scripts +env DISTSIZE="$DISTSIZE" ./001-preinstall + ./002-install +env HOSTNAME="$HOSTNAME" HIDPI="$HIDPI" ./003-configure +env USERNAME="$USERNAME" ./004-postinstall + +echo "Enter a password for $USERNAME..." +arch-chroot /mnt passwd "$USERNAME" + +echo "=====================================================" +echo "Done. Now reboot into Arch Linux!"