bigboy-alma-deploy/scripts/utility-recon.sh

102 lines
3.4 KiB
Bash
Executable file

#!/usr/bin/env bash
# Built standing on the shoulders of billions of dwarves
# Created by John A. Hoeven with the ethical assistance of Claude AI
# Licence: The Unlicense — https://unlicense.org
# ---------------------------------------------------------------------------
# utility-recon.sh
# Version: v0.0.1 | Status: DEVELOPMENT
# Role: Recon
# ---------------------------------------------------------------------------
# Purpose: Check for commonly-expected baseline CLI utilities that a
# minimal AlmaLinux install may not include. Triggered by tar
# and which both turning up unexpectedly absent during Phase 5 —
# neither is part of coreutils, and this kickstart's minimal
# %packages list only explicitly requested a handful of
# utilities, letting real gaps through silently until something
# needed them.
# Target: BigBoy — AlmaLinux 10.2 (or any box installed from this kickstart)
# Entry: ./utility-recon.sh
# Depends: rpm (present by default)
# Note: Read-only — checks only, installs nothing.
# ---------------------------------------------------------------------------
# No 'set -e' — every operation checked and logged explicitly (CE OS standard §1.8).
LOG_DIR="${HOME}/.local/logs/utility-recon"
LOG_FILE="${LOG_DIR}/recon-$(date '+%Y-%m-%d_%H%M%S').log"
mkdir -p "${LOG_DIR}"
_log() {
printf '[%s] %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "${1}" | tee -a "${LOG_FILE}"
}
# ── Candidate list ────────────────────────────────────────────────────────
#
# Command name -> providing package (RHEL/AlmaLinux naming). Grouped
# loosely by why you'd reach for it. Not exhaustive — a reasonable
# baseline for admin/dev work, informed by what already turned up
# missing (tar, which) plus adjacent tools in the same category.
declare -A UTILITIES=(
# Archive/compression — tar already confirmed missing
["tar"]="tar"
["gzip"]="gzip"
["bzip2"]="bzip2"
["xz"]="xz"
["zip"]="zip"
["unzip"]="unzip"
# Shell/environment basics — which already confirmed missing
["which"]="which"
["tree"]="tree"
["less"]="less"
["man"]="man-db"
# File search / process inspection
["find"]="findutils"
["ps"]="procps-ng"
["lsof"]="lsof"
# Network diagnostics
["dig"]="bind-utils"
["nc"]="nmap-ncat"
["rsync"]="rsync"
["traceroute"]="traceroute"
# Debugging (useful given how much troubleshooting this deploy has needed)
["strace"]="strace"
# Data/text tools worth having
["jq"]="jq"
["bc"]="bc"
)
_log "Starting utility recon on $(hostname)"
_log ""
missing_packages=()
for cmd in "${!UTILITIES[@]}"; do
pkg="${UTILITIES[${cmd}]}"
if command -v "${cmd}" >/dev/null 2>&1; then
_log "OK — ${cmd} (${pkg})"
else
_log "MISSING — ${cmd} (${pkg})"
missing_packages+=("${pkg}")
fi
done
_log ""
if [[ "${#missing_packages[@]}" -eq 0 ]]; then
_log "Nothing missing from this checklist."
else
# de-duplicate in case two commands share a package
unique_missing=($(printf '%s\n' "${missing_packages[@]}" | sort -u))
_log "Missing packages (deduplicated): ${unique_missing[*]}"
_log ""
_log "To install everything missing right now:"
_log " sudo dnf install ${unique_missing[*]}"
fi
_log ""
_log "Full log: ${LOG_FILE}"