#!/bin/bash # ============================================================================== # inject_payloads.sh -- regenerate the 150-payload HID macro matrix # ============================================================================== # Layout (v1.4 -- fixed): # overlay/data/payloads/linux/ 01..50 (.dd) Linux recovery payloads # overlay/data/payloads/macos/ 51..100 (.dd) macOS recovery payloads # overlay/data/payloads/windows/ 101..150 (.dd) Windows recovery payloads # # v1.3 bug fixed: macos/ and windows/ folders were never generated; the # install shipped 53 flat mac_*.macro and 45 flat win_*.macro files at the # payloads/ root. v1.4 generates the canonical 50+50+50 layout. Existing # .macro files from v1.3 are migrated (renamed + moved) on first run. # ============================================================================== set -euo pipefail PAYLOADS_ROOT="overlay/data/payloads" LINUX_DIR="$PAYLOADS_ROOT/linux" MACOS_DIR="$PAYLOADS_ROOT/macos" WINDOWS_DIR="$PAYLOADS_ROOT/windows" mkdir -p "$LINUX_DIR" "$MACOS_DIR" "$WINDOWS_DIR" # --- Migrate v1.3 flat .macro files if present ------------------------------- # v1.3 shipped: lnx_extract_profile_N.macro, lnx_rescue_profile_N.macro, # mac_extract_profile_N.macro, mac_rescue_profile_N.macro, # win_extract_profile_N.macro, win_rescue_profile_N.macro # These are extracted/rescue profiles, not the canonical 01..50 .dd payload # files. v1.4 keeps them as historical/operator-curated macros under a # legacy/ subdir for reference, but the canonical matrix is the .dd set. LEGACY_DIR="$PAYLOADS_ROOT/legacy" if ls "$PAYLOADS_ROOT"/*.macro >/dev/null 2>&1; then mkdir -p "$LEGACY_DIR" log "Migrating $(ls "$PAYLOADS_ROOT"/*.macro | wc -l) v1.3 .macro files to legacy/..." mv "$PAYLOADS_ROOT"/*.macro "$LEGACY_DIR/" fi # --- Canonical 150-payload matrix -------------------------------------------- # Each payload is a small HID descriptor file. v1.4 generates a deterministic # stub for every slot the build manifest advertises, then overlays real # operator-provided content where it exists (see $OPERATOR_PAYLOADS_DIR). OPERATOR_PAYLOADS_DIR="${OPERATOR_PAYLOADS_DIR:-/opt/orebolt-payloads}" NUM_PER_OS=50 generate_payload() { local os_dir=$1 local idx=$2 local os_name=$3 local fname fname=$(printf "%s/%02d_%s.dd" "$os_dir" "$idx" "$os_name") # If operator-provided content exists, prefer it. if [ -f "$OPERATOR_PAYLOADS_DIR/$os_name/$(printf "%02d" $idx).dd" ]; then cp "$OPERATOR_PAYLOADS_DIR/$os_name/$(printf "%02d" $idx).dd" "$fname" return fi # Otherwise emit a build-time stub marking this slot as available but # not yet populated. The deploy.mod UI will skip empty stubs. cat > "$fname" <