36 lines
1.5 KiB
Bash
Executable file
36 lines
1.5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Created by John A. Hoeven with the ethical assistance of Claude AI
|
|
# ---------------------------------------------------------------------------
|
|
# 00_preflight.sh
|
|
# /home/john/projects/suse-professional-package-installer/lib/00_preflight.sh
|
|
# Version: v0.1.0 | Status: DEVELOPMENT
|
|
# ---------------------------------------------------------------------------
|
|
# Purpose: Environment checks only — no system changes. Runs unconditionally
|
|
# before any privileged subscript, unprivileged itself.
|
|
# Target: SUSE family (zypper).
|
|
# Entry: ./00_preflight.sh
|
|
# Depends: ce-common.sh (same directory)
|
|
# ---------------------------------------------------------------------------
|
|
|
|
# shellcheck disable=SC2016
|
|
# ^ run_test()'s cmd args are intentionally single-quoted — deferred-eval
|
|
# expressions, not meant to expand at the call site.
|
|
|
|
_SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
|
|
# shellcheck source=./ce-common.sh
|
|
source "${_SCRIPT_DIR}/ce-common.sh"
|
|
|
|
log_info "=== PRE-FLIGHT ==="
|
|
|
|
run_test "not running as root" '[[ "${EUID}" -ne 0 ]]' fail
|
|
run_test "zypper available" 'command -v zypper >/dev/null 2>&1' fail
|
|
run_test "sudo or doas available" \
|
|
'command -v sudo >/dev/null 2>&1 || command -v doas >/dev/null 2>&1' fail
|
|
run_test "internet reachable" \
|
|
'curl --silent --max-time 5 --output /dev/null https://download.opensuse.org' \
|
|
warn
|
|
run_test "disk space >= 500MB" \
|
|
'[[ $(df / --output=avail | tail -1) -ge 512000 ]]' \
|
|
warn
|
|
|
|
log_info "Pre-flight complete"
|