#!/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