#!/usr/bin/env bash # 00-preflight — verify we can proceed at all. step_name="preflight" step_desc="verify distro, network, privileges" step_run="run_preflight" run_preflight() { log "preflight checks" if [[ "$DISTRO" == "unknown" ]]; then err "unsupported distro (could not read ID/ID_LIKE from /etc/os-release)" err "bootstrap supports debian/ubuntu and arch only." exit 1 fi if (( EUID == 0 )); then SUDO="" export SUDO else SUDO="sudo" export SUDO if ! sudo -n true 2>/dev/null; then warn "not root and passwordless sudo unavailable — sudo will prompt per-use" fi fi if command -v ping >/dev/null 2>&1 && ping -c1 -W2 8.8.8.8 >/dev/null 2>&1; then : elif curl -fsS --max-time 3 https://g.mk.fo >/dev/null 2>&1; then : else err "no outbound network — cannot install anything" exit 1 fi ok "distro=$DISTRO arch=$ARCH user=$USER sudo=${SUDO:-root}" }