Files
Mateusz Suski ca5a876d03
lint / shell-yaml-ansible (push) Failing after 21s
Improve infra-run portfolio credibility
2026-05-08 21:18:22 +00:00

113 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
TIMESTAMP="${TIMESTAMP:-$(date +%Y%m%d_%H%M%S)}"
DRY_RUN="${DRY_RUN:-true}"
LOG_FILE="${LOG_FILE:-/tmp/gpfs_extend_${TIMESTAMP}.log}"
FILESYSTEM="${FILESYSTEM:-}"
NSD_STANZA="${NSD_STANZA:-}"
FAILURE_GROUP="${FAILURE_GROUP:-}"
STORAGE_POOL="${STORAGE_POOL:-system}"
USAGE="${USAGE:-dataAndMetadata}"
log() {
local level="$1"
shift
local message="$*"
printf '%s: %s\n' "$level" "$message" | tee -a "$LOG_FILE"
}
ok() {
log "OK" "$@"
}
warning() {
log "WARNING" "$@"
}
critical() {
log "CRITICAL" "$@"
}
require_cmd() {
local cmd="$1"
if command -v "$cmd" >/dev/null 2>&1; then
ok "Command available: $cmd"
return 0
fi
critical "Required command not found: $cmd"
return 1
}
validate_gpfs_command() {
local cmd="$1"
if command -v "$cmd" >/dev/null 2>&1; then
return 0
fi
warning "GPFS command not available, skipping: $cmd"
return 1
}
run_cmd() {
if [[ "$#" -eq 0 ]]; then
critical "run_cmd called without a command"
return 2
fi
if [[ "$DRY_RUN" == "true" ]]; then
log "OK" "DRY-RUN: $*"
return 0
fi
log "OK" "RUN: $*"
"$@" 2>&1 | tee -a "$LOG_FILE"
}
run_readonly() {
if [[ "$#" -eq 0 ]]; then
critical "run_readonly called without a command"
return 2
fi
log "OK" "READ-ONLY: $*"
"$@" 2>&1 | tee -a "$LOG_FILE"
}
confirm_execute() {
local target="${1:-GPFS change}"
if [[ "$DRY_RUN" == "true" ]]; then
ok "Dry-run mode enabled. No changes will be made."
return 0
fi
warning "Execution mode requested for: $target"
warning "Coordinate this change with storage, GPFS, application, and change-management teams."
printf 'Type EXECUTE to continue: '
read -r confirmation
if [[ "$confirmation" != "EXECUTE" ]]; then
critical "Confirmation failed. Aborting."
exit 1
fi
ok "Execution confirmed by operator."
}
usage_value_valid() {
case "$1" in
dataOnly|metadataOnly|dataAndMetadata) return 0 ;;
*) return 1 ;;
esac
}
section() {
printf '\n== %s ==\n' "$1" | tee -a "$LOG_FILE"
}