Initial commit
This commit is contained in:
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2023 seajee
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
15
README.md
Normal file
15
README.md
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# archquick
|
||||||
|
|
||||||
|
archquick is a set of scripts to facilitate the process of quickly installing
|
||||||
|
Arch Linux in new systems.
|
||||||
|
|
||||||
|
# Quick start
|
||||||
|
|
||||||
|
To use the scripts run the following on a live Arch Linux environment:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ pacman -Sy git
|
||||||
|
$ git clone https://github.com/seajee/archquick
|
||||||
|
$ cd archquick
|
||||||
|
$ ./install.sh
|
||||||
|
```
|
||||||
52
chroot.sh
Executable file
52
chroot.sh
Executable file
@@ -0,0 +1,52 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
input=""
|
||||||
|
timezone="Europe/Amsterdam"
|
||||||
|
hostname="arch"
|
||||||
|
password=""
|
||||||
|
|
||||||
|
# Set the time zone
|
||||||
|
read -p "Enter timezone (${timezone}): " input
|
||||||
|
if [[ -n "$input" ]]; then
|
||||||
|
timezone="$input"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f "/usr/share/zoneinfo/${timezone}" ]]; then
|
||||||
|
echoerr "[ERROR] The selected time zone does not exist"
|
||||||
|
exit 5
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[INFO] Settings ${timezone} as the time zone"
|
||||||
|
ln -sf "/usr/share/zoneinfo/${timezone}" /etc/localtime
|
||||||
|
hwclock --systohc
|
||||||
|
|
||||||
|
# Localization
|
||||||
|
echo "[INFO] Setting locale to en_US"
|
||||||
|
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
|
||||||
|
locale-gen &>/dev/null
|
||||||
|
echo "LANG=en_US.UTF-8" >> /etc/locale.conf
|
||||||
|
|
||||||
|
# Network configuration
|
||||||
|
read -p "Enter a valid hostname (${hostname}): " input
|
||||||
|
if [[ -n "$input" ]]; then
|
||||||
|
hostname="$input"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[INFO] Enabling NetworkManager to start at boot"
|
||||||
|
systemctl enable NetworkManager &>/dev/null
|
||||||
|
|
||||||
|
# Set the root password
|
||||||
|
read -p "Enter a new password for the root user: " password
|
||||||
|
echo "root:${password}" | chpasswd
|
||||||
|
|
||||||
|
# Install the boot loader
|
||||||
|
echo "[INFO] Installing the GRUB boot loader"
|
||||||
|
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB --removable &>/dev/null
|
||||||
|
grub-mkconfig -o /boot/grub/grub.cfg &>/dev/null
|
||||||
|
|
||||||
|
# TODO: Check for errors with grub-install
|
||||||
|
|
||||||
|
# Self-delete this script as it is no longer required
|
||||||
|
rm -- "$0"
|
||||||
|
|
||||||
|
exit 0
|
||||||
137
install.sh
Executable file
137
install.sh
Executable file
@@ -0,0 +1,137 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# For reference: https://wiki.archlinux.org/title/Installation_guide
|
||||||
|
|
||||||
|
# TODO:
|
||||||
|
# - Add support for BIOS platform
|
||||||
|
# - Add more filesystem options (defaults to ext4)
|
||||||
|
# - Make script recoverable from errors (save script stage)
|
||||||
|
# - Add support for custom localization configuration
|
||||||
|
|
||||||
|
platform="bios"
|
||||||
|
input=""
|
||||||
|
disk="/dev/sda"
|
||||||
|
timezone="Europe/Amsterdam"
|
||||||
|
hostname="arch"
|
||||||
|
password=""
|
||||||
|
|
||||||
|
echoerr() { cat <<< "$@" 1>&2; }
|
||||||
|
|
||||||
|
# Check is script is being run as root
|
||||||
|
if [[ $(id -u) -ne 0 ]]; then
|
||||||
|
echoerr "[ERROR] Please run this script as root or using sudo"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Verify the boot mode
|
||||||
|
if [[ ! -f "/sys/firmware/efi/fw_platform_size" ]]; then
|
||||||
|
echoerr "[ERROR] Non UEFI platforms are not supported by this script"
|
||||||
|
exit 2
|
||||||
|
else
|
||||||
|
platform=$(cat /sys/firmware/efi/fw_platform_size)
|
||||||
|
echo "[INFO] Platform: ${platform}-bit UEFI"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test internet connectivity
|
||||||
|
if ! ping -q -c1 archlinux.org &>/dev/null; then
|
||||||
|
echoerr "[ERROR] Not connected to the internet"
|
||||||
|
exit 3
|
||||||
|
else
|
||||||
|
echo "[INFO] Connected to the internet"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Select disk to be partitioned
|
||||||
|
echo "[INFO] Printing available disks"
|
||||||
|
fdisk -l
|
||||||
|
|
||||||
|
read -p "Enter installation disk (${disk}): " input
|
||||||
|
if [[ -n "$input" ]]; then
|
||||||
|
disk="$input"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -b "$disk" ]]; then
|
||||||
|
echoerr "[ERROR] The selected disk does not exist"
|
||||||
|
exit 4
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Partition the disk with the following layout:
|
||||||
|
# | Mount point | Partition Type | Size |
|
||||||
|
# |-------------|-----------------------|-------------------------|
|
||||||
|
# | /boot | EFI system partition | 1 GiB |
|
||||||
|
# | [SWAP] | Linux swap | 4 GiB |
|
||||||
|
# | / | Linux x86-64 root (/) | Remainder of the device |
|
||||||
|
echo "[INFO] Partitioning the disk"
|
||||||
|
(
|
||||||
|
echo g # Create a new empty GPT partition table
|
||||||
|
|
||||||
|
# EFI system partition
|
||||||
|
echo n # Add a new partition
|
||||||
|
echo 1 # Partition number
|
||||||
|
echo # First sector (accept default: 2048)
|
||||||
|
echo "+1GiB" # Last sector
|
||||||
|
echo t # Change partition type
|
||||||
|
echo "uefi" # "EFI system partition" type
|
||||||
|
|
||||||
|
# Swap partition
|
||||||
|
echo n # Add a new partition
|
||||||
|
echo 2 # Partition number
|
||||||
|
echo # First sector (accept default)
|
||||||
|
echo "+4GiB" # Last sector
|
||||||
|
echo t # Change partition type
|
||||||
|
echo 2 # Select partition
|
||||||
|
echo "swap" # "Linux swap partition" type
|
||||||
|
|
||||||
|
# Root partition
|
||||||
|
echo n # Add a new partition
|
||||||
|
echo 3 # Partition number
|
||||||
|
echo # First sector (accept default)
|
||||||
|
echo # Last sector (accept default)
|
||||||
|
echo t # Change partition type
|
||||||
|
echo 3 # Select partition
|
||||||
|
echo 23 # "Linux x86-64 root (/) Linux" partition type
|
||||||
|
|
||||||
|
echo w # Write changes
|
||||||
|
) | fdisk "$disk" &>/dev/null
|
||||||
|
|
||||||
|
# TODO: Check if fdisk terminated succesfully
|
||||||
|
|
||||||
|
# Format the partitions
|
||||||
|
echo "[INFO] Formatting the partitions"
|
||||||
|
mkfs.ext4 "${disk}3" &>/dev/null
|
||||||
|
mkswap "${disk}2" &>/dev/null
|
||||||
|
mkfs.fat -F 32 "${disk}1" &>/dev/null
|
||||||
|
|
||||||
|
# TODO: Check if formatting the partitions went correctly
|
||||||
|
|
||||||
|
# Mount the file systems
|
||||||
|
echo "[INFO] Mounting the file systems"
|
||||||
|
mount "${disk}3" /mnt
|
||||||
|
mount --mkdir "${disk}1" /mnt/boot
|
||||||
|
swapon "${disk}2"
|
||||||
|
|
||||||
|
# TODO: Select the mirrors for faster download speeds
|
||||||
|
|
||||||
|
# Install essential packages
|
||||||
|
echo "[INFO] Installing essential packages"
|
||||||
|
pacstrap -K /mnt base linux linux-firmware \
|
||||||
|
intel-ucode amd-ucode \
|
||||||
|
networkmanager \
|
||||||
|
grub efibootmgr
|
||||||
|
|
||||||
|
# Generate an fstab file
|
||||||
|
echo "[INFO] Generating fstab file"
|
||||||
|
genfstab -U /mnt >> /mnt/etc/fstab
|
||||||
|
|
||||||
|
# Change root into the new system
|
||||||
|
cp ./chroot.sh /mnt/chroot.sh
|
||||||
|
|
||||||
|
echo "[INFO] Changing root into the new system"
|
||||||
|
arch-chroot /mnt bash /chroot.sh
|
||||||
|
|
||||||
|
# Unmount partitions
|
||||||
|
umount -R /mnt
|
||||||
|
|
||||||
|
# Tell the user that it's ok to reboot now
|
||||||
|
echo "[INFO] Now you also can say \"I use Arch, BTW\". Reboot when you're ready"
|
||||||
|
|
||||||
|
exit 0
|
||||||
Reference in New Issue
Block a user