Blueforce-Linux/scripts/install/installer/modules/05-network.sh
emirhanmamak-blueforce da460519e8 feat(install): internet-free install flow, auto-discovered local packages
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.
2026-09-16 16:53:24 +03:00

47 lines
2.2 KiB
Bash
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# Network report for the field device. It separates three things that used to be
# one gate:
# 1. local network link — informational; the install does not use it,
# 2. Internet — NOT required: packages come from the local bundle,
# so external name resolution is not mandatory and a
# failing lookup must never stop the run,
# 3. central connection — not needed during install; enrollment checks it.
#
# The module therefore always exits 0: no network condition can fail an install.
set -euo pipefail
LOG_FILE="${LOG_FILE:-/var/log/blueforce-install.log}"; CHECK_MODE=0
[[ "${1:-}" == --check ]] && CHECK_MODE=1
OFFLINE="${BF_OFFLINE:-0}"; ENDPOINT="${BF_ENROLLMENT_ENDPOINT:-}"
log() { echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) [05-network] $1" | tee -a "$LOG_FILE"; }
local_link() { ip -o link show up 2>/dev/null | grep -qv ' lo:'; }
internet() { ping -c1 -W3 1.1.1.1 >/dev/null 2>&1 || getent hosts archive.ubuntu.com >/dev/null 2>&1; }
central() { [[ "$ENDPOINT" =~ ^https://[^[:space:]/]+ ]] && curl --connect-timeout 3 -fsSI "$ENDPOINT" >/dev/null 2>&1; }
if local_link; then
log 'BİLGİ: yerel ağ bağlantısı var (kurulum için gerekmiyor)'
else
log 'BİLGİ: yerel ağ bağlantısı görünmüyor (kurulum için gerekmiyor)'
fi
if [[ "$OFFLINE" == 1 ]]; then
log 'BİLGİ: internet: kurulum yerel paket deposundan yapılır; internet GEREKMEZ'
log 'BİLGİ: Apt kaynakları yerel depoyu gösterir; dış DNS çözümlenemese de kurulum sürer'
else
if internet; then
log 'BİLGİ: internet erişilebilir (geliştirme/test kipi; üretimde gerekmez)'
else
log 'BİLGİ: internet erişilemiyor (bu kurulum için gerekmez)'
fi
fi
if [[ -n "$ENDPOINT" ]]; then
if central; then
log 'BİLGİ: merkez kayıt uç noktası şu an erişilebilir (kurulumda yine de gerekmez)'
else
log 'BİLGİ: merkez kayıt uç noktasına şu an erişilemiyor; kurulum DURMAZ, enrollment aşamasında yeniden denenir'
fi
else
log 'BİLGİ: merkez kayıt uç noktası tanımlı değil; bağlantı enrollment aşamasında kurulur'
fi
log 'OK: ağ raporu tamam; kurulum internetsiz tamamlanabilir'
exit 0