menu formatting update
This commit is contained in:
+75
-111
@@ -22,6 +22,7 @@ source /opt/idssys/ta-proxmenu/inc/cpu-compat.inc
|
||||
source /opt/idssys/ta-proxmenu/inc/deploy-iso-nfs-lxc.sh
|
||||
source /opt/idssys/ta-proxmenu/inc/deploy-pulse-lxc.sh
|
||||
source /opt/idssys/ta-proxmenu/inc/virtio-helpers.inc
|
||||
source /opt/idssys/ta-proxmenu/inc/ui.inc
|
||||
|
||||
ACTION_REQUESTED=0
|
||||
[[ -n "${action:-}" ]] && ACTION_REQUESTED=1
|
||||
@@ -1761,69 +1762,47 @@ FORCE_UPDATE_CHECK() {
|
||||
|
||||
|
||||
MENU_HEADER() {
|
||||
local header_title='TA-ProxMenu - Proxmox Setup Scripts'
|
||||
local header_width=75
|
||||
local status_color=''
|
||||
local status_display=''
|
||||
local version_color="${idsCL[White]}"
|
||||
local right_width
|
||||
local spacer_width
|
||||
|
||||
local status_display='' status_style='' title='TA-ProxMenu'
|
||||
local version="${VERS}" spacing host
|
||||
host="$(hostname -s)"
|
||||
TAPM_UI_INIT
|
||||
TAPM_LOAD_HEADER_INFO
|
||||
|
||||
# Reuse a settled update result instead of running Git checks on every
|
||||
# arrow-key redraw. Continue refreshing only while the worker is pending.
|
||||
if [[ "$UPDATE_STATUS" == 'unknown' || "$UPDATE_STATUS" == 'checking' ]]; then
|
||||
if [[ "$UPDATE_STATUS" == unknown || "$UPDATE_STATUS" == checking ]]; then
|
||||
LOAD_UPDATE_STATUS
|
||||
fi
|
||||
case "$UPDATE_STATUS" in
|
||||
behind)
|
||||
status_display='** UPDATE AVAILABLE **'
|
||||
status_color="${idsCL[LightYellow]}"
|
||||
version_color="${idsCL[LightYellow]}"
|
||||
;;
|
||||
ahead)
|
||||
status_display='** LOCAL COMMITS **'
|
||||
status_color="${idsCL[LightYellow]}"
|
||||
version_color="${idsCL[LightYellow]}"
|
||||
;;
|
||||
diverged)
|
||||
status_display='** BRANCH DIVERGED **'
|
||||
status_color="${idsCL[LightRed]}"
|
||||
version_color="${idsCL[LightRed]}"
|
||||
;;
|
||||
dirty)
|
||||
status_display='** LOCAL CHANGES **'
|
||||
status_color="${idsCL[LightYellow]}"
|
||||
version_color="${idsCL[LightYellow]}"
|
||||
;;
|
||||
checking)
|
||||
status_display='(checking for updates)'
|
||||
status_color="${idsCL[LightCyan]}"
|
||||
version_color="${idsCL[LightCyan]}"
|
||||
;;
|
||||
behind) status_display='Update available'; status_style="$TAPM_UI_WARNING" ;;
|
||||
ahead) status_display='Local commits ahead of origin'; status_style="$TAPM_UI_WARNING" ;;
|
||||
diverged) status_display='Branch diverged'; status_style="$TAPM_UI_ERROR" ;;
|
||||
dirty) status_display='Local changes'; status_style="$TAPM_UI_WARNING" ;;
|
||||
checking) status_display='Checking for updates'; status_style="$TAPM_UI_MUTED" ;;
|
||||
current) status_display='Up to date'; status_style="$TAPM_UI_MUTED" ;;
|
||||
unknown) status_display='Update status unavailable'; status_style="$TAPM_UI_MUTED" ;;
|
||||
esac
|
||||
|
||||
right_width="${#VERS}"
|
||||
if [[ -n "$status_display" ]]; then
|
||||
right_width=$((right_width + ${#status_display} + 2))
|
||||
[[ -t 1 && "${TERM:-dumb}" != dumb ]] && clear
|
||||
printf '\n'
|
||||
spacing=$((TAPM_UI_WIDTH - 2 - ${#title} - ${#version}))
|
||||
if (( spacing >= 2 )); then
|
||||
printf ' %s%s%s%*s%s\n' "$TAPM_UI_BOLD" "$title" "$TAPM_UI_RESET" "$spacing" '' "$version"
|
||||
else
|
||||
TAPM_UI_TEXT "$TAPM_UI_BOLD" "$title"
|
||||
TAPM_UI_TEXT "$TAPM_UI_MUTED" "$version"
|
||||
fi
|
||||
spacer_width=$((header_width - 1 - ${#header_title} - right_width))
|
||||
((spacer_width < 2)) && spacer_width=2
|
||||
|
||||
clear
|
||||
echo
|
||||
printf ' %b%s%b%*s' \
|
||||
"${idsCL[Green]}" "$header_title" "${idsCL[Default]}" "$spacer_width" ''
|
||||
if [[ -n "$status_display" ]]; then
|
||||
printf '%b%s%b ' "$status_color" "$status_display" "${idsCL[Default]}"
|
||||
TAPM_UI_TEXT "$TAPM_UI_MUTED" 'Proxmox Setup Scripts'
|
||||
TAPM_UI_RULE
|
||||
# Stack context on narrow terminals rather than squeezing both columns.
|
||||
if (( TAPM_UI_WIDTH >= 74 && ${#host} <= 20 && ${#TAPM_HEADER_PVE_VERSION} <= 20 && ${#TAPM_HEADER_CLUSTER} <= 25 && ${#RNIP} <= 25 )); then
|
||||
printf ' %sHostname%s %-20s %sIP Address%s %s\n' "$TAPM_UI_MUTED" "$TAPM_UI_RESET" "$host" "$TAPM_UI_MUTED" "$TAPM_UI_RESET" "${RNIP:-Unavailable}"
|
||||
printf ' %sProxmox VE%s %-20s %sCluster%s %s\n' "$TAPM_UI_MUTED" "$TAPM_UI_RESET" "$TAPM_HEADER_PVE_VERSION" "$TAPM_UI_MUTED" "$TAPM_UI_RESET" "$TAPM_HEADER_CLUSTER"
|
||||
else
|
||||
TAPM_UI_TEXT '' "Hostname $host"
|
||||
TAPM_UI_TEXT '' "IP Address ${RNIP:-Unavailable}"
|
||||
TAPM_UI_TEXT '' "Proxmox VE $TAPM_HEADER_PVE_VERSION"
|
||||
TAPM_UI_TEXT '' "Cluster $TAPM_HEADER_CLUSTER"
|
||||
fi
|
||||
printf '%b%s%b\n' "$version_color" "$VERS" "${idsCL[Default]}"
|
||||
echo -e "${idsCL[Green]}---------------------------------------------------------------------------${idsCL[Default]}"
|
||||
echo -e " Hostname: ${idsCL[Cyan]}$(hostname -s)${idsCL[Default]}"
|
||||
echo -e " IP Address: ${idsCL[Cyan]}${RNIP:-Unavailable}${idsCL[Default]}"
|
||||
echo -e " Proxmox VE: ${idsCL[Cyan]}${TAPM_HEADER_PVE_VERSION}${idsCL[Default]} Cluster: ${idsCL[Cyan]}${TAPM_HEADER_CLUSTER}${idsCL[Default]}"
|
||||
echo -e "${idsCL[Green]}---------------------------------------------------------------------------${idsCL[Default]}"
|
||||
TAPM_UI_RULE
|
||||
[[ -z "$status_display" ]] || TAPM_UI_TEXT "$status_style" "$status_display"
|
||||
return 0
|
||||
}
|
||||
|
||||
SELECT_MENU() {
|
||||
@@ -1845,28 +1824,28 @@ SELECT_MENU() {
|
||||
while true; do
|
||||
MENU_HEADER
|
||||
echo
|
||||
echo -e " ${idsCL[LightCyan]}${title}${idsCL[Default]}"
|
||||
TAPM_UI_TEXT "$TAPM_UI_BOLD" "$title"
|
||||
echo
|
||||
|
||||
for index in "${!labels_ref[@]}"; do
|
||||
if (( index == selected )); then
|
||||
printf '\e[7m %d %-64s\e[0m\n' "$((index + 1))" "${labels_ref[$index]}"
|
||||
else
|
||||
printf ' %d %s\n' "$((index + 1))" "${labels_ref[$index]}"
|
||||
fi
|
||||
TAPM_UI_MENU_META "$title" "${values_ref[$index]}"
|
||||
TAPM_UI_MENU_ROW "$((index + 1))" "${labels_ref[$index]}" "$((index == selected))"
|
||||
done
|
||||
|
||||
echo
|
||||
if (( allow_back == 1 && allow_space == 1 )); then
|
||||
echo " ↑/↓ Navigate Space Toggle Enter Select Number Quick Select ←/Esc/B Back Q Quit"
|
||||
elif (( allow_back == 1 )); then
|
||||
echo " ↑/↓ Navigate Enter Select Number Quick Select ←/Esc/B Back Q Quit"
|
||||
elif (( allow_space == 1 )); then
|
||||
echo " ↑/↓ Navigate Space Toggle Enter Select Number Quick Select Q Quit"
|
||||
else
|
||||
echo " ↑/↓ Navigate Enter Select Number Quick Select Q Quit"
|
||||
TAPM_UI_MENU_META "$title" "${values_ref[$selected]}"
|
||||
if [[ -n "$TAPM_UI_HINT" ]]; then
|
||||
echo
|
||||
TAPM_UI_TEXT "$TAPM_UI_MUTED" "$TAPM_UI_HINT"
|
||||
fi
|
||||
echo
|
||||
echo
|
||||
local quick_max=${#values_ref[@]}
|
||||
(( quick_max > 9 )) && quick_max=9
|
||||
TAPM_UI_TEXT "$TAPM_UI_MUTED" "↑/↓ Move Enter Select 1-${quick_max} Quick select"
|
||||
(( allow_space == 0 )) || TAPM_UI_TEXT "$TAPM_UI_MUTED" 'Space Toggle'
|
||||
if (( allow_back )); then
|
||||
TAPM_UI_TEXT "$TAPM_UI_MUTED" '←/Esc/B Back Q Quit'
|
||||
else
|
||||
TAPM_UI_TEXT "$TAPM_UI_MUTED" 'Q Quit'
|
||||
fi
|
||||
echo
|
||||
|
||||
MENU_INPUT=""
|
||||
MENU_SELECTED_INDEX="$selected"
|
||||
@@ -1943,9 +1922,9 @@ SELECT_MENU() {
|
||||
# Leave only the header above the selected action's output.
|
||||
MENU_HEADER
|
||||
echo
|
||||
if [[ "$MENU_SELECTION" != "back" && "$MENU_SELECTION" != "quit" && "$MENU_INPUT" != "space" ]]; then
|
||||
printf '%b Starting: %b%b\n\n' \
|
||||
"${idsCL[LightCyan]}" "${labels_ref[$selected]}" "${idsCL[Default]}"
|
||||
TAPM_UI_MENU_META "$title" "$MENU_SELECTION"
|
||||
if [[ "$TAPM_UI_KIND" == task && "$MENU_INPUT" != space ]]; then
|
||||
TAPM_UI_TASK "${labels_ref[$selected]}"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@@ -2360,7 +2339,7 @@ HOST_SETUP_MENU() {
|
||||
values=("post_install")
|
||||
TAPM_POST_PROXMENUX_DETECTED &&
|
||||
labels[0]="TAPM Host Configuration — ProxMenux migration recommended"
|
||||
labels+=("Analyze VM CPU compatibility for HA and workload mobility")
|
||||
labels+=("Analyze VM CPU migration compatibility")
|
||||
values+=("cpu")
|
||||
|
||||
# Discover ISO storage only after the VirtIO submenu is selected.
|
||||
@@ -2415,7 +2394,7 @@ MONITORING_MENU() {
|
||||
fi
|
||||
|
||||
if systemctl is-active --quiet ITSPlatform; then
|
||||
labels+=("ConnectWise RMM agent (installed)")
|
||||
labels+=("ConnectWise RMM agent (running)")
|
||||
else
|
||||
labels+=($'Install \e[36mConnectWise RMM\e[39m agent')
|
||||
fi
|
||||
@@ -2435,7 +2414,7 @@ MONITORING_MENU() {
|
||||
fi
|
||||
|
||||
if systemctl is-active --quiet 'connectwise*'; then
|
||||
labels+=("ScreenConnect agent (installed)")
|
||||
labels+=("ScreenConnect agent (running)")
|
||||
else
|
||||
labels+=($'Install \e[36mScreenConnect\e[39m agent')
|
||||
fi
|
||||
@@ -2486,17 +2465,17 @@ CLUSTER_MENU() {
|
||||
maintenance_status=$?
|
||||
fi
|
||||
if (( maintenance_status == 0 )); then
|
||||
labels=("Take this host out of maintenance mode")
|
||||
labels=("Exit maintenance mode on this host")
|
||||
else
|
||||
labels=("Put this host into maintenance mode and evacuate guests")
|
||||
labels=("Enter maintenance mode and evacuate guests")
|
||||
fi
|
||||
|
||||
labels+=("Proxmox service recovery")
|
||||
dpkg-query -W -f='${Status}' keepalived 2>/dev/null | grep -q "install ok installed" &&
|
||||
labels+=("Deploy/reconfigure Keepalived (installed locally)") ||
|
||||
labels+=("Deploy or reconfigure Keepalived (installed locally)") ||
|
||||
labels+=("Deploy Keepalived on all cluster hosts")
|
||||
labels+=("Create shared ISO storage using an LXC NFS server")
|
||||
labels+=("Find orphaned / unused disks (read-only)")
|
||||
labels+=("Create shared ISO storage")
|
||||
labels+=("Find orphaned and unused disks [Read-only]")
|
||||
|
||||
SELECT_MENU "Cluster & Maintenance" labels values
|
||||
case "$MENU_SELECTION" in
|
||||
@@ -2689,6 +2668,7 @@ BRANCH_MANAGEMENT_MENU() {
|
||||
}
|
||||
|
||||
TAPM_INSTALL_MENU_UPDATE() {
|
||||
TAPM_UI_TASK "Update TA-ProxMenu"
|
||||
if ! /opt/idssys/ta-proxmenu/run.sh update; then
|
||||
printf '\nUpdate reported failures; review the node results above. TAPM will reload the locally installed version.\n'
|
||||
ENTER2CONTINUE
|
||||
@@ -2700,39 +2680,23 @@ TAPM_INSTALL_MENU_UPDATE() {
|
||||
|
||||
UTILITIES_MENU() {
|
||||
local -a labels
|
||||
local -a values=("install_update" "check_update" "branches" "about")
|
||||
local -a values=()
|
||||
local choice
|
||||
local last_checked
|
||||
|
||||
while true; do
|
||||
LOAD_UPDATE_STATUS
|
||||
case "$UPDATE_STATUS" in
|
||||
behind)
|
||||
labels=("Install available update")
|
||||
;;
|
||||
current)
|
||||
labels=("TA-ProxMenu is current")
|
||||
;;
|
||||
ahead)
|
||||
labels=("Local branch is ahead of origin")
|
||||
;;
|
||||
diverged)
|
||||
labels=("Local branch has diverged from origin")
|
||||
;;
|
||||
dirty)
|
||||
labels=("Local repository has uncommitted changes")
|
||||
;;
|
||||
checking)
|
||||
labels=("Update check in progress")
|
||||
;;
|
||||
*)
|
||||
labels=("Update status unavailable")
|
||||
;;
|
||||
esac
|
||||
if [[ "$UPDATE_STATUS" == behind ]]; then
|
||||
labels=("Install available update")
|
||||
values=("install_update" "check_update" "branches" "about")
|
||||
else
|
||||
labels=()
|
||||
values=("check_update" "branches" "about")
|
||||
fi
|
||||
last_checked="$(UPDATE_LAST_CHECKED_DISPLAY)"
|
||||
labels+=(
|
||||
"Check again now "$'\e[2m'"(last checked: ${last_checked})"$'\e[22m'
|
||||
"Git branch management"
|
||||
"Check for updates "$'\e[2m'"(last checked: ${last_checked})"$'\e[22m'
|
||||
"Switch Git branch"
|
||||
"Version and installation information"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user