Switch debug TUI menus to dialog and include dialog package
This commit is contained in:
@@ -45,6 +45,7 @@ lsof
|
||||
file
|
||||
less
|
||||
vim
|
||||
dialog
|
||||
EOF
|
||||
|
||||
rc_add devfs sysinit
|
||||
|
||||
@@ -51,5 +51,6 @@ profile_bee_debug() {
|
||||
file
|
||||
less
|
||||
vim
|
||||
dialog
|
||||
"
|
||||
}
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
|
||||
set -u
|
||||
|
||||
if ! command -v dialog >/dev/null 2>&1; then
|
||||
echo "ERROR: dialog is required but not installed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pause() {
|
||||
echo
|
||||
printf 'Press Enter to continue... '
|
||||
@@ -17,6 +22,13 @@ header() {
|
||||
echo
|
||||
}
|
||||
|
||||
menu_choice() {
|
||||
title="$1"
|
||||
prompt="$2"
|
||||
shift 2
|
||||
dialog --clear --stdout --title "$title" --menu "$prompt" 20 90 12 "$@"
|
||||
}
|
||||
|
||||
list_ifaces() {
|
||||
ip -o link show \
|
||||
| awk -F': ' '{print $2}' \
|
||||
@@ -47,15 +59,12 @@ choose_interface() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "$ifaces" | nl -w2 -s'. '
|
||||
echo
|
||||
printf 'Select interface number: '
|
||||
read -r idx
|
||||
iface=$(echo "$ifaces" | sed -n "${idx}p")
|
||||
if [ -z "$iface" ]; then
|
||||
echo "Invalid interface selection"
|
||||
return 1
|
||||
fi
|
||||
set --
|
||||
for iface in $ifaces; do
|
||||
set -- "$@" "$iface" "$iface"
|
||||
done
|
||||
iface=$(menu_choice "Network" "Select interface" "$@") || return 1
|
||||
|
||||
CHOSEN_IFACE="$iface"
|
||||
return 0
|
||||
}
|
||||
@@ -185,16 +194,12 @@ mask_to_prefix() {
|
||||
|
||||
network_menu() {
|
||||
while true; do
|
||||
header
|
||||
echo "Network"
|
||||
echo "1. Show network status"
|
||||
echo "2. DHCP on all interfaces"
|
||||
echo "3. DHCP on one interface"
|
||||
echo "4. Set static IPv4 on one interface"
|
||||
echo "5. Back"
|
||||
echo
|
||||
printf 'Choice: '
|
||||
read -r choice
|
||||
choice=$(menu_choice "Network" "Select action" \
|
||||
"1" "Show network status" \
|
||||
"2" "DHCP on all interfaces" \
|
||||
"3" "DHCP on one interface" \
|
||||
"4" "Set static IPv4 on one interface" \
|
||||
"5" "Back") || return
|
||||
|
||||
case "$choice" in
|
||||
1) show_network_status ;;
|
||||
@@ -235,15 +240,12 @@ choose_service() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "$svcs" | nl -w2 -s'. '
|
||||
echo
|
||||
printf 'Select service number: '
|
||||
read -r idx
|
||||
svc=$(echo "$svcs" | sed -n "${idx}p")
|
||||
if [ -z "$svc" ]; then
|
||||
echo "Invalid service selection"
|
||||
return 1
|
||||
fi
|
||||
set --
|
||||
for svc in $svcs; do
|
||||
set -- "$@" "$svc" "$svc"
|
||||
done
|
||||
svc=$(menu_choice "bee Services" "Select service" "$@") || return 1
|
||||
|
||||
CHOSEN_SERVICE="$svc"
|
||||
return 0
|
||||
}
|
||||
@@ -255,30 +257,19 @@ service_action_menu() {
|
||||
choose_service || { pause; return; }
|
||||
svc="$CHOSEN_SERVICE"
|
||||
|
||||
echo
|
||||
echo "Selected: $svc"
|
||||
echo "1. status"
|
||||
echo "2. restart"
|
||||
echo "3. start"
|
||||
echo "4. stop"
|
||||
echo "5. toggle start/stop"
|
||||
echo
|
||||
printf 'Choice: '
|
||||
read -r act
|
||||
act=$(menu_choice "Service: $svc" "Select action" \
|
||||
"1" "status" \
|
||||
"2" "restart" \
|
||||
"3" "start" \
|
||||
"4" "stop" \
|
||||
"5" "toggle start/stop" \
|
||||
"6" "Back") || return
|
||||
|
||||
case "$act" in
|
||||
1)
|
||||
rc-service "$svc" status || true
|
||||
;;
|
||||
2)
|
||||
rc-service "$svc" restart || true
|
||||
;;
|
||||
3)
|
||||
rc-service "$svc" start || true
|
||||
;;
|
||||
4)
|
||||
rc-service "$svc" stop || true
|
||||
;;
|
||||
1) rc-service "$svc" status || true ;;
|
||||
2) rc-service "$svc" restart || true ;;
|
||||
3) rc-service "$svc" start || true ;;
|
||||
4) rc-service "$svc" stop || true ;;
|
||||
5)
|
||||
if rc-service "$svc" status >/dev/null 2>&1; then
|
||||
rc-service "$svc" stop || true
|
||||
@@ -286,23 +277,18 @@ service_action_menu() {
|
||||
rc-service "$svc" start || true
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Invalid action"
|
||||
;;
|
||||
6) return ;;
|
||||
*) echo "Invalid action" ;;
|
||||
esac
|
||||
pause
|
||||
}
|
||||
|
||||
services_menu() {
|
||||
while true; do
|
||||
header
|
||||
echo "bee Services"
|
||||
echo "1. Status of all bee-* services"
|
||||
echo "2. Manage one service (status/restart/start/stop/toggle)"
|
||||
echo "3. Back"
|
||||
echo
|
||||
printf 'Choice: '
|
||||
read -r choice
|
||||
choice=$(menu_choice "bee Services" "Select action" \
|
||||
"1" "Status of all bee-* services" \
|
||||
"2" "Manage one service (status/restart/start/stop/toggle)" \
|
||||
"3" "Back") || return
|
||||
|
||||
case "$choice" in
|
||||
1) services_status_all ;;
|
||||
@@ -324,19 +310,15 @@ confirm_phrase() {
|
||||
|
||||
shutdown_menu() {
|
||||
while true; do
|
||||
header
|
||||
echo "Shutdown/Reboot Tests"
|
||||
echo "1. Reboot now"
|
||||
echo "2. Power off now"
|
||||
echo "3. Schedule poweroff in 60s"
|
||||
echo "4. Cancel scheduled shutdown"
|
||||
echo "5. IPMI chassis power status"
|
||||
echo "6. IPMI chassis power soft"
|
||||
echo "7. IPMI chassis power cycle"
|
||||
echo "8. Back"
|
||||
echo
|
||||
printf 'Choice: '
|
||||
read -r choice
|
||||
choice=$(menu_choice "Shutdown/Reboot Tests" "Select action" \
|
||||
"1" "Reboot now" \
|
||||
"2" "Power off now" \
|
||||
"3" "Schedule poweroff in 60s" \
|
||||
"4" "Cancel scheduled shutdown" \
|
||||
"5" "IPMI chassis power status" \
|
||||
"6" "IPMI chassis power soft" \
|
||||
"7" "IPMI chassis power cycle" \
|
||||
"8" "Back") || return
|
||||
|
||||
case "$choice" in
|
||||
1)
|
||||
@@ -410,13 +392,9 @@ gpu_burn_10m() {
|
||||
|
||||
gpu_benchmarks_menu() {
|
||||
while true; do
|
||||
header
|
||||
echo "Benchmarks -> GPU"
|
||||
echo "1. GPU Burn (10 minutes)"
|
||||
echo "2. Back"
|
||||
echo
|
||||
printf 'Choice: '
|
||||
read -r choice
|
||||
choice=$(menu_choice "Benchmarks -> GPU" "Select action" \
|
||||
"1" "GPU Burn (10 minutes)" \
|
||||
"2" "Back") || return
|
||||
|
||||
case "$choice" in
|
||||
1) gpu_burn_10m ;;
|
||||
@@ -428,13 +406,9 @@ gpu_benchmarks_menu() {
|
||||
|
||||
benchmarks_menu() {
|
||||
while true; do
|
||||
header
|
||||
echo "Benchmarks"
|
||||
echo "1. GPU"
|
||||
echo "2. Back"
|
||||
echo
|
||||
printf 'Choice: '
|
||||
read -r choice
|
||||
choice=$(menu_choice "Benchmarks" "Select category" \
|
||||
"1" "GPU" \
|
||||
"2" "Back") || return
|
||||
|
||||
case "$choice" in
|
||||
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 "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)"
|
||||
if [ -n "$bug_report" ] && [ -f "$bug_report" ]; then
|
||||
cp -f "$bug_report" "$run_dir/"
|
||||
@@ -516,13 +489,9 @@ run_gpu_nvidia_acceptance_test() {
|
||||
|
||||
gpu_nvidia_sat_menu() {
|
||||
while true; do
|
||||
header
|
||||
echo "System acceptance tests -> GPU NVIDIA"
|
||||
echo "1. Run command pack"
|
||||
echo "2. Back"
|
||||
echo
|
||||
printf 'Choice: '
|
||||
read -r choice
|
||||
choice=$(menu_choice "System acceptance tests -> GPU NVIDIA" "Select action" \
|
||||
"1" "Run command pack" \
|
||||
"2" "Back") || return
|
||||
|
||||
case "$choice" in
|
||||
1) run_gpu_nvidia_acceptance_test ;;
|
||||
@@ -534,13 +503,9 @@ gpu_nvidia_sat_menu() {
|
||||
|
||||
system_acceptance_tests_menu() {
|
||||
while true; do
|
||||
header
|
||||
echo "System acceptance tests"
|
||||
echo "1. GPU NVIDIA"
|
||||
echo "2. Back"
|
||||
echo
|
||||
printf 'Choice: '
|
||||
read -r choice
|
||||
choice=$(menu_choice "System acceptance tests" "Select category" \
|
||||
"1" "GPU NVIDIA" \
|
||||
"2" "Back") || return
|
||||
|
||||
case "$choice" in
|
||||
1) gpu_nvidia_sat_menu ;;
|
||||
@@ -569,7 +534,7 @@ check_required_tools() {
|
||||
header
|
||||
echo "Required tools check"
|
||||
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
|
||||
echo "- $tool: OK ($(command -v "$tool"))"
|
||||
else
|
||||
@@ -581,20 +546,16 @@ check_required_tools() {
|
||||
|
||||
main_menu() {
|
||||
while true; do
|
||||
header
|
||||
echo "Main Menu"
|
||||
echo "1. Network setup"
|
||||
echo "2. bee service management"
|
||||
echo "3. Shutdown/reboot tests"
|
||||
echo "4. Benchmarks"
|
||||
echo "5. System acceptance tests"
|
||||
echo "6. Run audit now"
|
||||
echo "7. Check required tools"
|
||||
echo "8. Show last audit log tail"
|
||||
echo "9. Exit to console"
|
||||
echo
|
||||
printf 'Choice: '
|
||||
read -r choice
|
||||
choice=$(menu_choice "Bee TUI (debug)" "Select action" \
|
||||
"1" "Network setup" \
|
||||
"2" "bee service management" \
|
||||
"3" "Shutdown/reboot tests" \
|
||||
"4" "Benchmarks" \
|
||||
"5" "System acceptance tests" \
|
||||
"6" "Run audit now" \
|
||||
"7" "Check required tools" \
|
||||
"8" "Show last audit log tail" \
|
||||
"9" "Exit to console") || exit 0
|
||||
|
||||
case "$choice" in
|
||||
1) network_menu ;;
|
||||
|
||||
Reference in New Issue
Block a user