Newer
Older
ops-toolkit / packs / ops-scripts / install-pack.sh
@JANeumatrix JANeumatrix 3 hours ago 966 bytes Initial upload
#!/usr/bin/env bash
# install-pack.sh -- pack orchestrator (identical across packs)
#
# Runs this pack's numbered component installers (install-[0-9]*.sh) in
# lexical order, stopping on first failure. Each component is also runnable
# standalone: bash install-NNN-name.sh
#
# Exit codes: 0 PROCEED, 1 HOLD (component failed), 2 precondition missing.
# ASCII + LF.

set -euo pipefail
shopt -s inherit_errexit 2>/dev/null || true
IFS=$'\n\t'

PACK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=../../lib/lib-install.sh
. "$PACK_DIR/../../lib/lib-install.sh"

found=0
for step in "$PACK_DIR"/install-[0-9]*.sh; do
    [ -e "$step" ] || continue
    found=1
    info "-- $(basename "$step")"
    if ! bash "$step"; then
        fail "component failed: $(basename "$step")"
        exit 1
    fi
done

if [ "$found" -eq 0 ]; then
    fail "no install-NNN components found in $PACK_DIR"
    exit 2
fi
ok "pack complete: $(basename "$PACK_DIR")"