Files
arch-i3/scripts/00-preflight.sh
T

51 lines
1.6 KiB
Bash
Raw Normal View History

2026-09-14 15:31:20 -05:00
#!/usr/bin/env bash
# Stage 00 — sanity checks, mirror refresh, pacman quality-of-life.
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
log "Preflight"
require_arch
require_not_root
require_sudo
step "checking network connectivity"
if ! ping -c1 -W3 archlinux.org >/dev/null 2>&1; then
warn "cannot reach archlinux.org — package installation will fail"
confirm "continue anyway?" || die "aborted"
else
ok "network reachable"
fi
# --- pacman.conf niceties --------------------------------------------------
step "enabling pacman colour output + parallel downloads"
if [[ "$DRY_RUN" != "1" ]]; then
sudo sed -i \
-e 's/^#\(Color\)$/\1/' \
-e 's/^#\(VerbosePkgLists\)$/\1/' \
-e 's/^#\?ParallelDownloads.*/ParallelDownloads = 8/' \
/etc/pacman.conf
grep -q '^ParallelDownloads' /etc/pacman.conf || \
sudo sed -i '/^\[options\]/a ParallelDownloads = 8' /etc/pacman.conf
fi
ok "pacman.conf tuned"
# --- multilib (optional, off by default) ----------------------------------
if [[ "${ENABLE_MULTILIB:-0}" == "1" ]]; then
step "enabling [multilib]"
run sudo sed -i '/^#\[multilib\]$/,+1 s/^#//' /etc/pacman.conf
fi
# --- mirrors ---------------------------------------------------------------
if have reflector; then
step "refreshing mirrorlist with reflector (this can take a minute)"
run sudo reflector --protocol https --latest 20 --sort rate \
--save /etc/pacman.d/mirrorlist || warn "reflector failed; keeping existing mirrorlist"
else
skip "reflector not installed yet — mirrors will be refreshed on the next run"
fi
step "synchronising package databases"
run sudo pacman -Syu --noconfirm
ok "preflight complete"