#!/bin/bash # KNEL-Football ISO Builder - Host Wrapper # This script orchestrates the Docker-based build process # Copyright © 2026 Known Element Enterprises LLC set -euo pipefail # Configuration variables readonly DOCKER_IMAGE="knel-football-builder:latest" readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" readonly OUTPUT_DIR="${SCRIPT_DIR}/output" # Create output directory if it doesn't exist mkdir -p "${OUTPUT_DIR}" # Function to show usage usage() { echo "Usage: $0 [command]" echo "Commands:" echo " build Build the secure ISO" echo " test Run all tests" echo " lint Run linting checks" echo " clean Clean build artifacts" echo " shell Interactive shell in build container" exit 1 } # Main execution logic main() { local command="${1:-build}" case "${command}" in build) echo "Building KNEL-Football secure ISO..." docker run --rm \ -v "${SCRIPT_DIR}:/workspace" \ -v "${OUTPUT_DIR}:/workspace/output" \ -u "$(id -u):$(id -g)" \ "${DOCKER_IMAGE}" \ /workspace/src/build-iso.sh ;; test) echo "Running KNEL-Football test suite..." docker run --rm \ -v "${SCRIPT_DIR}:/workspace" \ -u "$(id -u):$(id -g)" \ "${DOCKER_IMAGE}" \ bats -r /workspace/tests/ ;; lint) echo "Running linting checks..." docker run --rm \ -v "${SCRIPT_DIR}:/workspace" \ -u "$(id -u):$(id -g)" \ "${DOCKER_IMAGE}" \ shellcheck /workspace/src/*.sh /workspace/config/hooks/*/*.sh ;; clean) echo "Cleaning build artifacts..." rm -rf "${OUTPUT_DIR:?}"/* ;; shell) echo "Starting interactive shell..." docker run --rm -it \ -v "${SCRIPT_DIR}:/workspace" \ -v "${OUTPUT_DIR}:/workspace/output" \ -u "$(id -u):$(id -g)" \ "${DOCKER_IMAGE}" \ bash ;; *) usage ;; esac } main "$@"