Files
David Schroeder dd7a66e1e4 update
2026-07-28 22:26:29 -05:00

38 lines
1.0 KiB
Bash

#!/usr/bin/env bash
# Cached local host details displayed by the interactive menu header.
TAPM_HEADER_INFO_LOADED=0
TAPM_HEADER_PVE_VERSION='Unavailable'
TAPM_HEADER_CLUSTER='Standalone'
TAPM_LOAD_HEADER_INFO() {
local pve_output=''
local first_line=''
local cluster_config="${1:-/etc/pve/corosync.conf}"
local cluster_name=''
local line=''
(( TAPM_HEADER_INFO_LOADED == 0 )) || return 0
TAPM_HEADER_INFO_LOADED=1
if command -v pveversion >/dev/null 2>&1; then
pve_output="$(pveversion 2>/dev/null || true)"
first_line="${pve_output%%$'\n'*}"
if [[ "$first_line" =~ ^pve-manager/([^/[:space:]]+) ]]; then
TAPM_HEADER_PVE_VERSION="${BASH_REMATCH[1]}"
elif [[ -n "$first_line" ]]; then
TAPM_HEADER_PVE_VERSION="${first_line%%[[:space:]]*}"
fi
fi
if [[ -r "$cluster_config" ]]; then
while IFS= read -r line; do
if [[ "$line" =~ ^[[:space:]]*cluster_name:[[:space:]]*([^[:space:]#]+) ]]; then
cluster_name="${BASH_REMATCH[1]}"
break
fi
done <"$cluster_config"
TAPM_HEADER_CLUSTER="${cluster_name:-Clustered}"
fi
}