Expand all the guard conditionals to be as readable as possible

This commit is contained in:
David Heinemeier Hansson
2025-10-07 13:04:44 +02:00
parent 1ffed127db
commit 011174699c

View File

@@ -5,25 +5,36 @@ abort() {
}
# Must be an Arch distro
[[ -f /etc/arch-release ]] || abort "Vanilla Arch"
if [[ ! -f /etc/arch-release ]]; then
abort "Vanilla Arch"
fi
# Must not be an Arch derivative distro
for marker in /etc/cachyos-release /etc/eos-release /etc/garuda-release /etc/manjaro-release; do
[[ -f "$marker" ]] && abort "Vanilla Arch"
if [[ -f "$marker" ]]; then
abort "Vanilla Arch"
fi
done
# Must not be running as root
[ "$EUID" -eq 0 ] && abort "Running as root (not user)"
if [ "$EUID" -eq 0 ]; then
abort "Running as root (not user)"
fi
# Must be x86 only to fully work
[ "$(uname -m)" != "x86_64" ] && abort "x86_64 CPU"
if [ "$(uname -m)" != "x86_64" ]; then
abort "x86_64 CPU"
fi
# Must have secure boot disabled
bootctl status 2>/dev/null | grep -q 'Secure Boot: enabled' && abort "Secure Boot disabled"
if bootctl status 2>/dev/null | grep -q 'Secure Boot: enabled'; then
abort "Secure Boot disabled"
fi
# Must not have Gnome or KDE already install
pacman -Qe gnome-shell &>/dev/null && abort "Fresh + Vanilla Arch"
pacman -Qe plasma-desktop &>/dev/null && abort "Fresh + Vanilla Arch"
if pacman -Qe gnome-shell &>/dev/null || pacman -Qe plasma-desktop &>/dev/null; then
abort "Fresh + Vanilla Arch"
fi
# Cleared all guards
echo "Guards: OK"