The operator no longer answers an "offline?" question and no longer needs network access: the installer finds the package set that ships with the checkout, so the only input left is the dealer number. Installer - Auto-discover the local APT repository (BF_OFFLINE_REPO, then provisioning/offline-repo/built, then /opt/blueforce/offline-repo) and enter offline mode on its own; --offline stays for compatibility. - Fail closed with an explicit Turkish message when nothing is found: the searched locations, what to do, and a named exit reason -- no state touched. - Distinguish "repository absent" (operator error, actionable) from "repository present but invalid" (OFFLINE BLOCKED, verification gate). - Network is informational only in precheck/network modules; no probe runs in offline mode and archive.ubuntu.com is no longer mandatory. ISO builder - Look for built/ first, which is what build-index.sh produces, and accept build/ as a warned legacy path. The two disagreed, so a medium could be built without the package set and fail only at install time. Docs - docs/27, scripts/install/README, provisioning/offline-repo/README and provisioning/firstboot/README describe the discovered flow, the two failure modes, and that the installer downloads nothing. Tests - check-admin-static exercised the "console missing from the clone" branch by deleting a tracked file; git clone restored it from history, so the branch never ran and the warning was effectively untested. Build the stripped source as a real commit instead; verified by mutation.
74 lines
3.1 KiB
Bash
Executable file
74 lines
3.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
||
# Pre-flight checks: root, Ubuntu release, RAM and disk.
|
||
#
|
||
# Network is informational here and never a gate: an offline install takes its
|
||
# packages from the local bundle, so it needs neither the Internet nor the
|
||
# central endpoint. Three things are reported separately for the operator:
|
||
# 1. local network link — no intent, not used by the install,
|
||
# 2. Internet — NOT required for an offline install (no warning),
|
||
# 3. central connection — not needed during install; that is the enrollment
|
||
# stage's job.
|
||
# This module therefore never fails because a network probe failed.
|
||
#
|
||
# Idempotent: safe to re-run. Supports --check for read-only verification.
|
||
# Exit codes: 0 = OK, 3 = SKIP (optional step, nothing to do), 1 = real failure.
|
||
set -euo pipefail
|
||
|
||
MODULE="01-precheck"
|
||
LOG_FILE="${LOG_FILE:-/var/log/blueforce-install.log}"
|
||
DEALER_ID="${DEALER_ID:-}"
|
||
BF_HOSTNAME="${BF_HOSTNAME:-}"
|
||
BF_DEVICE="${BF_DEVICE:-}"
|
||
STATE_DIR="${STATE_DIR:-/var/lib/blueforce}"
|
||
|
||
log() {
|
||
local msg="$1"
|
||
mkdir -p "$(dirname "$LOG_FILE")" 2>/dev/null || true
|
||
echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) [01-precheck] $msg" | tee -a "$LOG_FILE"
|
||
}
|
||
|
||
CHECK_MODE=0
|
||
if [[ "${1:-}" == "--check" ]]; then CHECK_MODE=1; fi
|
||
MIN_RAM_MB=2048
|
||
MIN_DISK_MB=20480
|
||
|
||
fail() { log "FAIL: $1"; echo "FAIL: $1" >&2; exit 1; }
|
||
info() { log "BİLGİ: $1"; }
|
||
|
||
# Read-only network report. Nothing here can fail the install.
|
||
report_network() {
|
||
if ip -o link show up 2>/dev/null | grep -qv ' lo:'; then
|
||
info "yerel ağ: bağlantı var (kurulum için gerekmiyor, kullanılmıyor)"
|
||
else
|
||
info "yerel ağ: bağlantı görünmüyor (kurulum için gerekmiyor, kullanılmıyor)"
|
||
fi
|
||
if [[ "${BF_OFFLINE:-0}" == 1 ]]; then
|
||
# Offline install: no probe at all, and no warning either.
|
||
info "internet: kurulum yerel paket deposundan yapılır; internet GEREKMEZ"
|
||
elif getent hosts archive.ubuntu.com >/dev/null 2>&1; then
|
||
info "internet: erişilebilir (geliştirme/test kipi)"
|
||
else
|
||
info "internet: erişilemiyor (bu kurulum için gerekmez)"
|
||
fi
|
||
info "merkez bağlantısı: kurulum sırasında gerekmez; enrollment aşamasında doğrulanır"
|
||
}
|
||
|
||
run_checks() {
|
||
[[ "$(id -u)" -eq 0 ]] || fail "must run as root"
|
||
if [[ -f /etc/os-release ]]; then
|
||
# shellcheck disable=SC1091
|
||
. /etc/os-release
|
||
[[ "${VERSION_ID:-}" == 26.04* ]] || fail "unsupported OS: ${NAME:-unknown} ${VERSION_ID:-unknown} (need Ubuntu 26.04)"
|
||
else
|
||
fail "/etc/os-release not found"
|
||
fi
|
||
local ram_mb disk_mb
|
||
ram_mb=$(awk '/MemTotal/ {printf "%d", $2/1024}' /proc/meminfo)
|
||
[[ "$ram_mb" -ge "$MIN_RAM_MB" ]] || fail "RAM too low: ${ram_mb}MB (need >= ${MIN_RAM_MB}MB)"
|
||
disk_mb=$(df -m / --output=avail | tail -1 | tr -d ' ')
|
||
[[ "$disk_mb" -ge "$MIN_DISK_MB" ]] || fail "disk too low: ${disk_mb}MB free on / (need >= ${MIN_DISK_MB}MB)"
|
||
report_network
|
||
log "OK: ön denetim geçti (Ubuntu ${VERSION_ID}, RAM ${ram_mb}MB, disk ${disk_mb}MB boş; yerel kurulum=$([[ "${BF_OFFLINE:-0}" == 1 ]] && echo evet || echo hayır))"
|
||
}
|
||
|
||
run_checks
|