Added command logging and refactored execution helpers.
This commit is contained in:
@@ -20,21 +20,14 @@
|
||||
# - Runs pacstrap with base packages defined in defaults.conf
|
||||
# - Detects CPU vendor and installs appropriate microcode (Intel/AMD)
|
||||
# - Generates /etc/fstab with UUIDs
|
||||
# - Provides chroot helper functions for running commands in new system
|
||||
# - Provides high-level chroot helpers for common operations
|
||||
# - Copies configuration files from installer to target system
|
||||
|
||||
# Run a command in the chroot environment
|
||||
# Arguments:
|
||||
# $@ - command and arguments
|
||||
chroot_run() {
|
||||
arch-chroot "${MOUNT_POINT}" "$@"
|
||||
}
|
||||
|
||||
# Install packages in the chroot environment using pacman
|
||||
# Arguments:
|
||||
# $@ - package names
|
||||
chroot_pacman_install() {
|
||||
run_visible_cmd chroot_run pacman --noconfirm -S "$@"
|
||||
run_visible_cmd_in_chroot pacman --noconfirm -S "$@"
|
||||
}
|
||||
|
||||
# Enable systemd units in the chroot environment
|
||||
@@ -44,7 +37,7 @@ chroot_systemd_enable() {
|
||||
for unit in "$@"; do
|
||||
print "Enabling ${unit}..."
|
||||
done
|
||||
run_visible_cmd chroot_run systemctl enable "$@"
|
||||
run_visible_cmd_in_chroot systemctl enable "$@"
|
||||
}
|
||||
|
||||
# Install base Arch Linux packages
|
||||
@@ -97,11 +90,11 @@ install_microcode() {
|
||||
# Generate /etc/fstab
|
||||
generate_fstab() {
|
||||
print "Generating /etc/fstab..."
|
||||
genfstab -U "${MOUNT_POINT}" >> "${MOUNT_POINT}/etc/fstab"
|
||||
run_cmd genfstab -U "${MOUNT_POINT}" >> "${MOUNT_POINT}/etc/fstab"
|
||||
}
|
||||
|
||||
# Copy configuration files from installer to target system
|
||||
copy_config_files() {
|
||||
print "Installing default configuration files..."
|
||||
cp -r "${CONFIG_SRC_DIR}" "${MOUNT_POINT}"
|
||||
run_visible_cmd cp -r "${CONFIG_SRC_DIR}" "${MOUNT_POINT}"
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
# Install systemd-boot bootloader
|
||||
install_bootloader() {
|
||||
print "Installing bootloader..."
|
||||
run_visible_cmd chroot_run bootctl install
|
||||
run_visible_cmd_in_chroot bootctl install
|
||||
}
|
||||
|
||||
# Create boot entry for single-disk installation
|
||||
@@ -34,7 +34,7 @@ install_bootloader() {
|
||||
create_boot_entry_single() {
|
||||
local luks_uuid="$1"
|
||||
|
||||
chroot_run sh -c "cat > /boot/loader/entries/arch.conf" <<EOF
|
||||
run_cmd_in_chroot sh -c "cat > /boot/loader/entries/arch.conf" <<EOF
|
||||
title Arch Linux
|
||||
linux /vmlinuz-linux
|
||||
initrd /initramfs-linux.img
|
||||
@@ -50,7 +50,7 @@ create_boot_entry_raid1() {
|
||||
local luks_uuid_1="$1"
|
||||
local luks_uuid_2="$2"
|
||||
|
||||
chroot_run sh -c "cat > /boot/loader/entries/arch.conf" <<EOF
|
||||
run_cmd_in_chroot sh -c "cat > /boot/loader/entries/arch.conf" <<EOF
|
||||
title Arch Linux
|
||||
linux /vmlinuz-linux
|
||||
initrd /initramfs-linux.img
|
||||
@@ -73,7 +73,7 @@ create_boot_entry() {
|
||||
|
||||
# Configure loader.conf timeout
|
||||
configure_loader() {
|
||||
chroot_run sed -i '/^#timeout 3/s/^#//' /boot/loader/loader.conf
|
||||
run_cmd_in_chroot sed -i '/^#timeout 3/s/^#//' /boot/loader/loader.conf
|
||||
}
|
||||
|
||||
# Full bootloader setup
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
configure_locale() {
|
||||
print "Setting up locale..."
|
||||
|
||||
chroot_run sed -i '/^#.*en_US.UTF-8 UTF-8/s/^#//' /etc/locale.gen
|
||||
run_visible_cmd chroot_run locale-gen
|
||||
chroot_run systemd-firstboot --locale=en_US.UTF-8
|
||||
run_cmd_in_chroot sed -i '/^#.*en_US.UTF-8 UTF-8/s/^#//' /etc/locale.gen
|
||||
run_visible_cmd_in_chroot locale-gen
|
||||
run_cmd_in_chroot systemd-firstboot --locale=en_US.UTF-8
|
||||
}
|
||||
|
||||
# Run interactive firstboot setup for timezone, keymap, hostname
|
||||
@@ -33,7 +33,7 @@ run_firstboot() {
|
||||
print "Entering first time setup..."
|
||||
print "Your keymap is probably 'us' and the time zone is probably 'America/New_York'."
|
||||
|
||||
run_visible_cmd chroot_run systemd-firstboot --prompt
|
||||
run_visible_cmd_in_chroot systemd-firstboot --prompt
|
||||
}
|
||||
|
||||
# Full locale and timezone setup
|
||||
|
||||
@@ -58,7 +58,7 @@ configure_mirrorlist() {
|
||||
# Enable systemd-resolved and configure resolv.conf symlink
|
||||
enable_resolved() {
|
||||
chroot_systemd_enable systemd-resolved.service
|
||||
ln -sf ../run/systemd/resolve/stub-resolv.conf "${MOUNT_POINT}/etc/resolv.conf"
|
||||
run_visible_cmd ln -sf ../run/systemd/resolve/stub-resolv.conf "${MOUNT_POINT}/etc/resolv.conf"
|
||||
}
|
||||
|
||||
# Prompt and install iwd for Wi-Fi support
|
||||
|
||||
@@ -32,8 +32,8 @@ configure_initramfs() {
|
||||
local default_line="HOOKS=(base systemd autodetect microcode modconf kms keyboard keymap sd-vconsole block filesystems fsck)"
|
||||
local new_line="HOOKS=(systemd autodetect microcode modconf kms keyboard sd-vconsole block sd-encrypt filesystems fsck)"
|
||||
|
||||
chroot_run sed -i "s|^${default_line}|${new_line}|" /etc/mkinitcpio.conf
|
||||
run_visible_cmd chroot_run mkinitcpio -P
|
||||
run_cmd_in_chroot sed -i "s|^${default_line}|${new_line}|" /etc/mkinitcpio.conf
|
||||
run_visible_cmd_in_chroot mkinitcpio -P
|
||||
}
|
||||
|
||||
# Enable BTRFS scrub timer if using BTRFS filesystem
|
||||
@@ -50,13 +50,13 @@ enable_btrfs_scrub() {
|
||||
# Configure sudo access for wheel group
|
||||
configure_sudo() {
|
||||
print "Enabling sudo access for wheel group..."
|
||||
chroot_run sed -i "s|^# %wheel ALL=(ALL:ALL) ALL|%wheel ALL=(ALL:ALL) ALL|" /etc/sudoers
|
||||
run_cmd_in_chroot sed -i "s|^# %wheel ALL=(ALL:ALL) ALL|%wheel ALL=(ALL:ALL) ALL|" /etc/sudoers
|
||||
}
|
||||
|
||||
# Disable root account login
|
||||
disable_root() {
|
||||
print "Disabling root account..."
|
||||
chroot_run passwd -l root
|
||||
run_cmd_in_chroot passwd -l root
|
||||
}
|
||||
|
||||
# Configure SSH server
|
||||
@@ -67,15 +67,15 @@ configure_ssh() {
|
||||
|
||||
print "Setting up and enabling OpenSSH server..."
|
||||
|
||||
chroot_run sed -i "s|PLACEHOLDER|${username}|" /etc/ssh/sshd_config
|
||||
run_visible_cmd chroot_run ssh-keygen -t ed25519 -C "" -N "" -f /etc/ssh/ssh_host_ed25519_key
|
||||
run_cmd_in_chroot sed -i "s|PLACEHOLDER|${username}|" /etc/ssh/sshd_config
|
||||
run_visible_cmd_in_chroot ssh-keygen -t ed25519 -C "" -N "" -f /etc/ssh/ssh_host_ed25519_key
|
||||
chroot_systemd_enable sshd.service
|
||||
}
|
||||
|
||||
# Display SSH host key fingerprint
|
||||
show_ssh_fingerprint() {
|
||||
print "Public SSH key fingerprint of this host:"
|
||||
run_visible_cmd chroot_run ssh-keygen -lvf /etc/ssh/ssh_host_ed25519_key.pub
|
||||
run_visible_cmd_in_chroot ssh-keygen -lvf /etc/ssh/ssh_host_ed25519_key.pub
|
||||
}
|
||||
|
||||
# Install custom CA certificates from certs directory
|
||||
@@ -92,9 +92,9 @@ install_ca_certificates() {
|
||||
cert_name=$(basename "$cert")
|
||||
print "Adding ${cert_name} to system CA store..."
|
||||
|
||||
cp "$cert" "${MOUNT_POINT}/${cert_name}"
|
||||
chroot_run trust anchor --store "/${cert_name}"
|
||||
chroot_run rm "/${cert_name}"
|
||||
run_visible_cmd cp "$cert" "${MOUNT_POINT}/${cert_name}"
|
||||
run_cmd_in_chroot trust anchor --store "/${cert_name}"
|
||||
run_cmd_in_chroot rm "/${cert_name}"
|
||||
done
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ configure_usbguard() {
|
||||
print "When ready to proceed, press enter."
|
||||
read -r
|
||||
|
||||
chroot_run sh -c "usbguard generate-policy > /etc/usbguard/rules.conf"
|
||||
run_cmd_in_chroot sh -c "usbguard generate-policy > /etc/usbguard/rules.conf"
|
||||
chroot_systemd_enable usbguard.service
|
||||
}
|
||||
|
||||
|
||||
@@ -47,9 +47,9 @@ copy_home_skel() {
|
||||
local username="$1"
|
||||
local home_dir="${MOUNT_POINT}/home/${username}"
|
||||
|
||||
cp -r "${HOME_SKEL_DIR}/." "${home_dir}/"
|
||||
rm -f "${home_dir}/.gitkeep"
|
||||
chown -R 1000:1000 "${home_dir}"
|
||||
run_visible_cmd cp -r "${HOME_SKEL_DIR}/." "${home_dir}/"
|
||||
run_visible_cmd rm -f "${home_dir}/.gitkeep"
|
||||
run_visible_cmd chown -R 1000:1000 "${home_dir}"
|
||||
}
|
||||
|
||||
# Create a user account
|
||||
@@ -61,9 +61,9 @@ create_user() {
|
||||
local display_name="${2:-}"
|
||||
|
||||
if [[ -n "$display_name" ]]; then
|
||||
chroot_run useradd -m -G wheel -c "$display_name" "$username"
|
||||
run_cmd_in_chroot useradd -m -G wheel -c "$display_name" "$username"
|
||||
else
|
||||
chroot_run useradd -m -G wheel "$username"
|
||||
run_cmd_in_chroot useradd -m -G wheel "$username"
|
||||
fi
|
||||
copy_home_skel "$username"
|
||||
}
|
||||
@@ -75,7 +75,7 @@ set_user_password() {
|
||||
local username="$1"
|
||||
|
||||
print "Please set the password for your new account."
|
||||
chroot_run passwd "$username"
|
||||
run_visible_cmd_in_chroot passwd "$username"
|
||||
}
|
||||
|
||||
# Full user setup
|
||||
|
||||
Reference in New Issue
Block a user