43 lines
1.1 KiB
Bash
Executable File
43 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -o errexit
|
|
set -o nounset
|
|
set -o pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
# shellcheck source=00_env.sh
|
|
source "$SCRIPT_DIR/00_env.sh"
|
|
|
|
parse_common_args "$@"
|
|
|
|
missing=0
|
|
for cmd in lsblk vxdisk vxdctl; do
|
|
require_cmd "$cmd" || missing=1
|
|
done
|
|
|
|
if (( missing != 0 )); then
|
|
exit 2
|
|
fi
|
|
|
|
ok "Veritas LUN discovery started"
|
|
log "INFO" "log file: $LOG_FILE"
|
|
capture_cmd "Current Linux block devices" lsblk
|
|
capture_cmd "Current VxVM disks" vxdisk list
|
|
|
|
run_cmd "Refresh VxVM device discovery" vxdctl enable
|
|
run_cmd "Scan disks known to VxVM" vxdisk scandisks
|
|
|
|
ok "Candidate VxVM disks with status 'online invalid'"
|
|
candidate_count=0
|
|
while read -r disk status rest; do
|
|
if [[ "$status $rest" == *"online invalid"* ]]; then
|
|
printf ' %s %s %s\n' "$disk" "$status" "$rest" | tee -a "$LOG_FILE"
|
|
candidate_count=$(( candidate_count + 1 ))
|
|
fi
|
|
done < <(vxdisk list 2>/dev/null | awk 'NR > 1 {print $1, $4, $5, $6, $7, $8}')
|
|
|
|
if (( candidate_count == 0 )); then
|
|
warning "no candidate disks detected with VxVM status 'online invalid'"
|
|
else
|
|
ok "detected $candidate_count candidate disk(s); review before initialization"
|
|
fi
|