mirror of
https://github.com/donovanglover/nix-config.git
synced 2025-01-17 19:38:54 +01:00
meta: Refactor install scripts
Lots of changes here with the goal of streamlining the installation process. The install scripts work very well now, although there are still some final changes that I would like to make (notably the removal of the unzip requirement and the inclusion of more options to automate the process even further).
This commit is contained in:
commit
082ff6bb12
@ -1,7 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# This script assumes you already have an active internet connection
|
# Make partitions
|
||||||
# (preferably through Ethernet).
|
|
||||||
#
|
#
|
||||||
# https://wiki.archlinux.org/index.php/Installation_guide
|
# 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
|
# enable boot for it. Then, create a primary swap partition with
|
||||||
# the remaining disk space.
|
# the remaining disk space.
|
||||||
parted /dev/sda mklabel msdos
|
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 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
|
# Format sda1 with ext4 and sda2 with swap
|
||||||
mkfs -t ext4 /dev/sda1
|
mkfs -t ext4 /dev/sda1
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Install the base packages to the mounted partition (the newly
|
# Install packages to new filesystem
|
||||||
# created filesystem).
|
|
||||||
#
|
|
||||||
# We also install grub and fish since grub is the boot loader
|
|
||||||
# and fish is the preferred shell.
|
|
||||||
#
|
#
|
||||||
# https://wiki.archlinux.org/index.php/Installation_guide
|
# https://wiki.archlinux.org/index.php/Installation_guide
|
||||||
|
|
||||||
set -xe
|
set -xe
|
||||||
|
|
||||||
pacstrap /mnt base base-devel grub fish
|
pacstrap /mnt base base-devel grub fish polkit rng-tools
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Once this script finishes, change the root password with passwd,
|
# Core system configs
|
||||||
# then unmount /mnt (with umount) and restart the system.
|
|
||||||
#
|
#
|
||||||
# https://wiki.archlinux.org/index.php/Installation_guide
|
# https://wiki.archlinux.org/index.php/Installation_guide
|
||||||
|
|
||||||
set -xe
|
set -xe
|
||||||
|
|
||||||
echo -n "Enter a hostname for this machine: "
|
|
||||||
read HOSTNAME
|
|
||||||
|
|
||||||
# Generate the fstab file (so the filesystem is mounted on boot)
|
# Generate the fstab file (so the filesystem is mounted on boot)
|
||||||
genfstab -U /mnt > /mnt/etc/fstab
|
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 "::1 localhost" >> /mnt/etc/hosts
|
||||||
echo "127.0.1.1 $HOSTNAME.localdomain $HOSTNAME" >> /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.
|
# Declare which locales we want to generate and generate them
|
||||||
echo "LANG=en_US.UTF-8" > /mnt/etc/locale.conf
|
sed -i '/#en_US.UTF-8 UTF-8/s/^#//g' /mnt/etc/locale.gen
|
||||||
echo "en_US.UTF-8 UTF-8" > /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
|
||||||
# Generate the locale.
|
|
||||||
arch-chroot /mnt locale-gen
|
arch-chroot /mnt locale-gen
|
||||||
|
|
||||||
# Explicitly set the keymap to US.
|
# Set the system locale to the generated en_US.UTF-8
|
||||||
echo "KEYMAP=us" > /mnt/etc/vconsole.conf
|
echo "LANG=en_US.UTF-8" > /mnt/etc/locale.conf
|
||||||
|
|
||||||
# Change the terminal font to a larger one (`latarcyrheb-sun32` is also an option)
|
# Set the tty font to a larger one (same as the default setfont, but larger)
|
||||||
echo "FONT=ter-132n" >> /mnt/etc/vconsole.conf
|
if [ "$HIDPI" == "YES" ]; then
|
||||||
|
echo "FONT=latarcyrheb-sun32" > /mnt/etc/vconsole.conf
|
||||||
|
fi
|
||||||
|
|
||||||
# Install grub to the primary partition.
|
# Install grub to the primary partition.
|
||||||
arch-chroot /mnt grub-install /dev/sda
|
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.
|
# Change the shell of the root account to fish.
|
||||||
arch-chroot /mnt chsh -s /usr/bin/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
|
|
||||||
|
@ -1,30 +1,38 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Common post-install system configuration that doesn't involve any
|
# Higher-level configs
|
||||||
# external packages (besides fish)
|
|
||||||
#
|
#
|
||||||
# https://wiki.archlinux.org/index.php/General_recommendations
|
# https://wiki.archlinux.org/index.php/General_recommendations
|
||||||
|
|
||||||
set -xe
|
set -xe
|
||||||
|
|
||||||
echo -n "Enter a username for the local account with administrative rights: "
|
# Create the output directories if they don't exist yet
|
||||||
read USERNAME
|
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
|
# Enable the DHCP client daemon service
|
||||||
systemctl enable --now dhcpcd.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
|
# Enable the timesync daemon service (sync the time periodically with a remote server)
|
||||||
timedatectl set-ntp true
|
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.
|
# Enable colors in pacman by uncommenting the Color line.
|
||||||
sed -i '/Color/s/^#//g' /etc/pacman.conf
|
sed -i '/Color/s/^#//g' /mnt/etc/pacman.conf
|
||||||
sed -i '/VerbosePkgLists/s/^#//g' /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
|
# 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.
|
# 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"
|
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).
|
# Lock the root account (i.e. disable root login)
|
||||||
echo "$USERNAME:$USERNAME" | chpasswd
|
arch-chroot /mnt passwd -l root
|
||||||
|
49
.archlinux/install-scripts/install.sh
Executable file
49
.archlinux/install-scripts/install.sh
Executable file
@ -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!"
|
Loading…
Reference in New Issue
Block a user