Switch debug TUI menus to dialog and include dialog package

This commit is contained in:
Mikhail Chusavitin
2026-03-06 17:57:40 +03:00
parent f84ec9320c
commit 94b305f166
3 changed files with 81 additions and 118 deletions

View File

@@ -45,6 +45,7 @@ lsof
file file
less less
vim vim
dialog
EOF EOF
rc_add devfs sysinit rc_add devfs sysinit

View File

@@ -51,5 +51,6 @@ profile_bee_debug() {
file file
less less
vim vim
dialog
" "
} }

View File

@@ -3,6 +3,11 @@
set -u set -u
if ! command -v dialog >/dev/null 2>&1; then
echo "ERROR: dialog is required but not installed"
exit 1
fi
pause() { pause() {
echo echo
printf 'Press Enter to continue... ' printf 'Press Enter to continue... '
@@ -17,6 +22,13 @@ header() {
echo echo
} }
menu_choice() {
title="$1"
prompt="$2"
shift 2
dialog --clear --stdout --title "$title" --menu "$prompt" 20 90 12 "$@"
}
list_ifaces() { list_ifaces() {
ip -o link show \ ip -o link show \
| awk -F': ' '{print $2}' \ | awk -F': ' '{print $2}' \
@@ -47,15 +59,12 @@ choose_interface() {
return 1 return 1
fi fi
echo "$ifaces" | nl -w2 -s'. ' set --
echo for iface in $ifaces; do
printf 'Select interface number: ' set -- "$@" "$iface" "$iface"
read -r idx done
iface=$(echo "$ifaces" | sed -n "${idx}p") iface=$(menu_choice "Network" "Select interface" "$@") || return 1
if [ -z "$iface" ]; then
echo "Invalid interface selection"
return 1
fi
CHOSEN_IFACE="$iface" CHOSEN_IFACE="$iface"
return 0 return 0
} }
@@ -185,16 +194,12 @@ mask_to_prefix() {
network_menu() { network_menu() {
while true; do while true; do
header choice=$(menu_choice "Network" "Select action" \
echo "Network" "1" "Show network status" \
echo "1. Show network status" "2" "DHCP on all interfaces" \
echo "2. DHCP on all interfaces" "3" "DHCP on one interface" \
echo "3. DHCP on one interface" "4" "Set static IPv4 on one interface" \
echo "4. Set static IPv4 on one interface" "5" "Back") || return
echo "5. Back"
echo
printf 'Choice: '
read -r choice
case "$choice" in case "$choice" in
1) show_network_status ;; 1) show_network_status ;;
@@ -235,15 +240,12 @@ choose_service() {
return 1 return 1
fi fi
echo "$svcs" | nl -w2 -s'. ' set --
echo for svc in $svcs; do
printf 'Select service number: ' set -- "$@" "$svc" "$svc"
read -r idx done
svc=$(echo "$svcs" | sed -n "${idx}p") svc=$(menu_choice "bee Services" "Select service" "$@") || return 1
if [ -z "$svc" ]; then
echo "Invalid service selection"
return 1
fi
CHOSEN_SERVICE="$svc" CHOSEN_SERVICE="$svc"
return 0 return 0
} }
@@ -255,30 +257,19 @@ service_action_menu() {
choose_service || { pause; return; } choose_service || { pause; return; }
svc="$CHOSEN_SERVICE" svc="$CHOSEN_SERVICE"
echo act=$(menu_choice "Service: $svc" "Select action" \
echo "Selected: $svc" "1" "status" \
echo "1. status" "2" "restart" \
echo "2. restart" "3" "start" \
echo "3. start" "4" "stop" \
echo "4. stop" "5" "toggle start/stop" \
echo "5. toggle start/stop" "6" "Back") || return
echo
printf 'Choice: '
read -r act
case "$act" in case "$act" in
1) 1) rc-service "$svc" status || true ;;
rc-service "$svc" status || true 2) rc-service "$svc" restart || true ;;
;; 3) rc-service "$svc" start || true ;;
2) 4) rc-service "$svc" stop || true ;;
rc-service "$svc" restart || true
;;
3)
rc-service "$svc" start || true
;;
4)
rc-service "$svc" stop || true
;;
5) 5)
if rc-service "$svc" status >/dev/null 2>&1; then if rc-service "$svc" status >/dev/null 2>&1; then
rc-service "$svc" stop || true rc-service "$svc" stop || true
@@ -286,23 +277,18 @@ service_action_menu() {
rc-service "$svc" start || true rc-service "$svc" start || true
fi fi
;; ;;
*) 6) return ;;
echo "Invalid action" *) echo "Invalid action" ;;
;;
esac esac
pause pause
} }
services_menu() { services_menu() {
while true; do while true; do
header choice=$(menu_choice "bee Services" "Select action" \
echo "bee Services" "1" "Status of all bee-* services" \
echo "1. Status of all bee-* services" "2" "Manage one service (status/restart/start/stop/toggle)" \
echo "2. Manage one service (status/restart/start/stop/toggle)" "3" "Back") || return
echo "3. Back"
echo
printf 'Choice: '
read -r choice
case "$choice" in case "$choice" in
1) services_status_all ;; 1) services_status_all ;;
@@ -324,19 +310,15 @@ confirm_phrase() {
shutdown_menu() { shutdown_menu() {
while true; do while true; do
header choice=$(menu_choice "Shutdown/Reboot Tests" "Select action" \
echo "Shutdown/Reboot Tests" "1" "Reboot now" \
echo "1. Reboot now" "2" "Power off now" \
echo "2. Power off now" "3" "Schedule poweroff in 60s" \
echo "3. Schedule poweroff in 60s" "4" "Cancel scheduled shutdown" \
echo "4. Cancel scheduled shutdown" "5" "IPMI chassis power status" \
echo "5. IPMI chassis power status" "6" "IPMI chassis power soft" \
echo "6. IPMI chassis power soft" "7" "IPMI chassis power cycle" \
echo "7. IPMI chassis power cycle" "8" "Back") || return
echo "8. Back"
echo
printf 'Choice: '
read -r choice
case "$choice" in case "$choice" in
1) 1)
@@ -410,13 +392,9 @@ gpu_burn_10m() {
gpu_benchmarks_menu() { gpu_benchmarks_menu() {
while true; do while true; do
header choice=$(menu_choice "Benchmarks -> GPU" "Select action" \
echo "Benchmarks -> GPU" "1" "GPU Burn (10 minutes)" \
echo "1. GPU Burn (10 minutes)" "2" "Back") || return
echo "2. Back"
echo
printf 'Choice: '
read -r choice
case "$choice" in case "$choice" in
1) gpu_burn_10m ;; 1) gpu_burn_10m ;;
@@ -428,13 +406,9 @@ gpu_benchmarks_menu() {
benchmarks_menu() { benchmarks_menu() {
while true; do while true; do
header choice=$(menu_choice "Benchmarks" "Select category" \
echo "Benchmarks" "1" "GPU" \
echo "1. GPU" "2" "Back") || return
echo "2. Back"
echo
printf 'Choice: '
read -r choice
case "$choice" in case "$choice" in
1) gpu_benchmarks_menu ;; 1) gpu_benchmarks_menu ;;
@@ -489,7 +463,6 @@ run_gpu_nvidia_acceptance_test() {
run_cmd_log "dmidecode_system" "$c3" "$run_dir/03-dmidecode-system.log"; rc3=$? run_cmd_log "dmidecode_system" "$c3" "$run_dir/03-dmidecode-system.log"; rc3=$?
run_cmd_log "nvidia_bug_report" "$c4" "$run_dir/04-nvidia-bug-report.log"; rc4=$? run_cmd_log "nvidia_bug_report" "$c4" "$run_dir/04-nvidia-bug-report.log"; rc4=$?
# Collect any bug report artifact generated in cwd.
bug_report="$(ls -1 nvidia-bug-report.log.gz 2>/dev/null | head -n1 || true)" bug_report="$(ls -1 nvidia-bug-report.log.gz 2>/dev/null | head -n1 || true)"
if [ -n "$bug_report" ] && [ -f "$bug_report" ]; then if [ -n "$bug_report" ] && [ -f "$bug_report" ]; then
cp -f "$bug_report" "$run_dir/" cp -f "$bug_report" "$run_dir/"
@@ -516,13 +489,9 @@ run_gpu_nvidia_acceptance_test() {
gpu_nvidia_sat_menu() { gpu_nvidia_sat_menu() {
while true; do while true; do
header choice=$(menu_choice "System acceptance tests -> GPU NVIDIA" "Select action" \
echo "System acceptance tests -> GPU NVIDIA" "1" "Run command pack" \
echo "1. Run command pack" "2" "Back") || return
echo "2. Back"
echo
printf 'Choice: '
read -r choice
case "$choice" in case "$choice" in
1) run_gpu_nvidia_acceptance_test ;; 1) run_gpu_nvidia_acceptance_test ;;
@@ -534,13 +503,9 @@ gpu_nvidia_sat_menu() {
system_acceptance_tests_menu() { system_acceptance_tests_menu() {
while true; do while true; do
header choice=$(menu_choice "System acceptance tests" "Select category" \
echo "System acceptance tests" "1" "GPU NVIDIA" \
echo "1. GPU NVIDIA" "2" "Back") || return
echo "2. Back"
echo
printf 'Choice: '
read -r choice
case "$choice" in case "$choice" in
1) gpu_nvidia_sat_menu ;; 1) gpu_nvidia_sat_menu ;;
@@ -569,7 +534,7 @@ check_required_tools() {
header header
echo "Required tools check" echo "Required tools check"
echo echo
for tool in dmidecode smartctl nvme ipmitool lspci audit nvidia-smi gpu_burn; do for tool in dmidecode smartctl nvme ipmitool lspci audit nvidia-smi gpu_burn dialog; do
if command -v "$tool" >/dev/null 2>&1; then if command -v "$tool" >/dev/null 2>&1; then
echo "- $tool: OK ($(command -v "$tool"))" echo "- $tool: OK ($(command -v "$tool"))"
else else
@@ -581,20 +546,16 @@ check_required_tools() {
main_menu() { main_menu() {
while true; do while true; do
header choice=$(menu_choice "Bee TUI (debug)" "Select action" \
echo "Main Menu" "1" "Network setup" \
echo "1. Network setup" "2" "bee service management" \
echo "2. bee service management" "3" "Shutdown/reboot tests" \
echo "3. Shutdown/reboot tests" "4" "Benchmarks" \
echo "4. Benchmarks" "5" "System acceptance tests" \
echo "5. System acceptance tests" "6" "Run audit now" \
echo "6. Run audit now" "7" "Check required tools" \
echo "7. Check required tools" "8" "Show last audit log tail" \
echo "8. Show last audit log tail" "9" "Exit to console") || exit 0
echo "9. Exit to console"
echo
printf 'Choice: '
read -r choice
case "$choice" in case "$choice" in
1) network_menu ;; 1) network_menu ;;