Fix menu system error handling and OS detection
- Add comprehensive error handling to menu.sh to prevent crashes when scripts fail - Fix OS detection in common.sh for lsb_release output parsing - Modify preflight.sh to run all checks without early exit on failures - Ensure menu navigation remains stable during testing phase
This commit is contained in:
@@ -25,8 +25,8 @@ IS_ARM64=false
|
|||||||
[[ "$ARCH" == "aarch64" ]] && IS_ARM64=true
|
[[ "$ARCH" == "aarch64" ]] && IS_ARM64=true
|
||||||
|
|
||||||
# System information
|
# System information
|
||||||
OS_NAME="$(lsb_release -si 2>/dev/null || echo "Unknown")"
|
OS_NAME="$(lsb_release -si 2>/dev/null | tail -1 || echo "Unknown")"
|
||||||
OS_VERSION="$(lsb_release -sr 2>/dev/null || echo "Unknown")"
|
OS_VERSION="$(lsb_release -sr 2>/dev/null | tail -1 || echo "Unknown")"
|
||||||
KERNEL_VERSION="$(uname -r)"
|
KERNEL_VERSION="$(uname -r)"
|
||||||
|
|
||||||
# Colors for output
|
# Colors for output
|
||||||
|
|||||||
@@ -209,11 +209,13 @@ handle_system_menu() {
|
|||||||
case "$choice" in
|
case "$choice" in
|
||||||
1)
|
1)
|
||||||
print_info "Running system preflight check..."
|
print_info "Running system preflight check..."
|
||||||
|
set +e
|
||||||
./preflight.sh
|
./preflight.sh
|
||||||
|
set -e
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
print_info "Installing and configuring Docker..."
|
print_info "Installing and configuring Docker..."
|
||||||
./setup.sh
|
./setup.sh --no-ui --skip-nvidia
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
print_info "Validating Docker installation..."
|
print_info "Validating Docker installation..."
|
||||||
@@ -252,19 +254,22 @@ handle_config_menu() {
|
|||||||
case "$choice" in
|
case "$choice" in
|
||||||
1)
|
1)
|
||||||
print_info "Starting interactive pre-deployment wizard..."
|
print_info "Starting interactive pre-deployment wizard..."
|
||||||
./pre-deployment-wizard.sh
|
print_info "The menu will exit to allow the wizard to run. The menu will restart after completion."
|
||||||
|
echo
|
||||||
|
read -rp "Press Enter to continue..."
|
||||||
|
exec ./pre-deployment-wizard.sh
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
print_info "Localizing configuration templates..."
|
print_info "Localizing configuration templates..."
|
||||||
./localize.sh
|
./localize.sh || true
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
print_info "Generalizing configuration files..."
|
print_info "Generalizing configuration files..."
|
||||||
./generalize.sh
|
./generalize.sh --method restore --no-ui || true
|
||||||
;;
|
;;
|
||||||
4)
|
4)
|
||||||
print_info "Validating all configurations..."
|
print_info "Validating all configurations..."
|
||||||
./validate.sh
|
./validate.sh || true
|
||||||
;;
|
;;
|
||||||
5)
|
5)
|
||||||
print_info "Current configuration status:"
|
print_info "Current configuration status:"
|
||||||
@@ -347,30 +352,30 @@ handle_monitor_menu() {
|
|||||||
case "$choice" in
|
case "$choice" in
|
||||||
1)
|
1)
|
||||||
print_info "Showing monitoring dashboard..."
|
print_info "Showing monitoring dashboard..."
|
||||||
./monitor.sh dashboard
|
./monitor.sh dashboard || true
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
print_info "Monitoring service health..."
|
print_info "Monitoring service health..."
|
||||||
./monitor.sh check
|
./monitor.sh check || true
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
print_info "Monitoring system resources..."
|
print_info "Monitoring system resources..."
|
||||||
echo "System Resources:"
|
echo "System Resources:"
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
./monitor.sh check | grep -E "(CPU|Memory|Disk)"
|
./monitor.sh check | grep -E "(CPU|Memory|Disk)" || true
|
||||||
;;
|
;;
|
||||||
4)
|
4)
|
||||||
echo "Available services:"
|
echo "Available services:"
|
||||||
./service.sh list | grep "✅ Running" | head -10
|
./service.sh list | grep "✅ Running" | head -10 || true
|
||||||
echo
|
echo
|
||||||
read -rp "Enter service name to view logs (or press Enter to skip): " service_name
|
read -rp "Enter service name to view logs (or press Enter to skip): " service_name
|
||||||
if [[ -n "$service_name" ]]; then
|
if [[ -n "$service_name" ]]; then
|
||||||
./service.sh logs "$service_name" -n 20
|
./service.sh logs "$service_name" -n 20 || true
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
5)
|
5)
|
||||||
print_info "Starting continuous monitoring (Ctrl+C to stop)..."
|
print_info "Starting continuous monitoring (Ctrl+C to stop)..."
|
||||||
./monitor.sh watch -i 30
|
./monitor.sh watch -i 30 || true
|
||||||
;;
|
;;
|
||||||
6) return 0 ;; # Back to main menu
|
6) return 0 ;; # Back to main menu
|
||||||
*)
|
*)
|
||||||
@@ -390,39 +395,39 @@ handle_backup_menu() {
|
|||||||
case "$choice" in
|
case "$choice" in
|
||||||
1)
|
1)
|
||||||
print_info "Backing up configuration files..."
|
print_info "Backing up configuration files..."
|
||||||
./backup.sh config
|
./backup.sh config || true
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
print_info "Backing up Docker volumes..."
|
print_info "Backing up Docker volumes..."
|
||||||
./backup.sh volumes
|
./backup.sh volumes || true
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
print_info "Backing up system logs..."
|
print_info "Backing up system logs..."
|
||||||
./backup.sh logs
|
./backup.sh logs || true
|
||||||
;;
|
;;
|
||||||
4)
|
4)
|
||||||
print_info "Backing up everything..."
|
print_info "Backing up everything..."
|
||||||
./backup.sh all
|
./backup.sh all || true
|
||||||
;;
|
;;
|
||||||
5)
|
5)
|
||||||
echo "Available backups:"
|
echo "Available backups:"
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
./backup.sh list config
|
./backup.sh list config || true
|
||||||
./backup.sh list volumes
|
./backup.sh list volumes || true
|
||||||
./backup.sh list logs
|
./backup.sh list logs || true
|
||||||
;;
|
;;
|
||||||
6)
|
6)
|
||||||
echo "Available backups:"
|
echo "Available backups:"
|
||||||
./backup.sh list config | grep -E "\.tar\.gzip$" | tail -5
|
./backup.sh list config | grep -E "\.tar\.gzip$" | tail -5 || true
|
||||||
echo
|
echo
|
||||||
read -rp "Enter backup filename to restore (or press Enter to skip): " backup_file
|
read -rp "Enter backup filename to restore (or press Enter to skip): " backup_file
|
||||||
if [[ -n "$backup_file" ]]; then
|
if [[ -n "$backup_file" ]]; then
|
||||||
./backup.sh config --restore "$backup_file"
|
./backup.sh config --restore "$backup_file" || true
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
7)
|
7)
|
||||||
print_info "Setting up automated backups..."
|
print_info "Setting up automated backups..."
|
||||||
./backup.sh schedule
|
./backup.sh schedule || true
|
||||||
;;
|
;;
|
||||||
8) return 0 ;; # Back to main menu
|
8) return 0 ;; # Back to main menu
|
||||||
*)
|
*)
|
||||||
@@ -442,35 +447,35 @@ handle_update_menu() {
|
|||||||
case "$choice" in
|
case "$choice" in
|
||||||
1)
|
1)
|
||||||
print_info "Checking for service updates..."
|
print_info "Checking for service updates..."
|
||||||
./update.sh check
|
./update.sh check || true
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
echo "Available services:"
|
echo "Available services:"
|
||||||
./service.sh list | grep "✅ Running" | head -10
|
./service.sh list | grep "✅ Running" | head -10 || true
|
||||||
echo
|
echo
|
||||||
read -rp "Enter service name to update (or press Enter to skip): " service_name
|
read -rp "Enter service name to update (or press Enter to skip): " service_name
|
||||||
if [[ -n "$service_name" ]]; then
|
if [[ -n "$service_name" ]]; then
|
||||||
./update.sh update "$service_name"
|
./update.sh update "$service_name" || true
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
print_warning "This will update all services. Continue? (y/N): "
|
print_warning "This will update all services. Continue? (y/N): "
|
||||||
read -r response
|
read -r response
|
||||||
if [[ "$response" =~ ^[Yy]$ ]]; then
|
if [[ "$response" =~ ^[Yy]$ ]]; then
|
||||||
./update.sh update all
|
./update.sh update all || true
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
4)
|
4)
|
||||||
print_info "Showing update history..."
|
print_info "Showing update history..."
|
||||||
./update.sh status
|
./update.sh status || true
|
||||||
;;
|
;;
|
||||||
5)
|
5)
|
||||||
print_info "Monitoring update progress..."
|
print_info "Monitoring update progress..."
|
||||||
./update.sh monitor
|
./update.sh monitor || true
|
||||||
;;
|
;;
|
||||||
6)
|
6)
|
||||||
print_info "Setting up automated updates..."
|
print_info "Setting up automated updates..."
|
||||||
./update.sh schedule
|
./update.sh schedule || true
|
||||||
;;
|
;;
|
||||||
7) return 0 ;; # Back to main menu
|
7) return 0 ;; # Back to main menu
|
||||||
*)
|
*)
|
||||||
@@ -499,7 +504,7 @@ handle_advanced_menu() {
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
if [[ -n "$cmd" ]]; then
|
if [[ -n "$cmd" ]]; then
|
||||||
./service.sh $cmd
|
./service.sh $cmd || true
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
@@ -541,7 +546,7 @@ handle_advanced_menu() {
|
|||||||
echo
|
echo
|
||||||
read -rp "Run cleanup? (y/N): " response
|
read -rp "Run cleanup? (y/N): " response
|
||||||
if [[ "$response" =~ ^[Yy]$ ]]; then
|
if [[ "$response" =~ ^[Yy]$ ]]; then
|
||||||
./service.sh cleanup
|
./service.sh cleanup || true
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
6)
|
6)
|
||||||
@@ -554,7 +559,7 @@ handle_advanced_menu() {
|
|||||||
case "$tool_choice" in
|
case "$tool_choice" in
|
||||||
1) ping -c 3 8.8.8.8 ;;
|
1) ping -c 3 8.8.8.8 ;;
|
||||||
2) docker logs $(docker ps -q | head -1) 2>/dev/null || echo "No containers running" ;;
|
2) docker logs $(docker ps -q | head -1) 2>/dev/null || echo "No containers running" ;;
|
||||||
3) ./validate.sh ;;
|
3) ./validate.sh || true ;;
|
||||||
4) uname -a && docker --version ;;
|
4) uname -a && docker --version ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
@@ -593,7 +598,7 @@ show_system_menu() {
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
handle_system_menu "$choice"
|
handle_system_menu "$choice" || true
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -607,7 +612,7 @@ show_config_menu() {
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
handle_config_menu "$choice"
|
handle_config_menu "$choice" || true
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,7 +626,7 @@ show_deploy_menu() {
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
handle_deploy_menu "$choice"
|
handle_deploy_menu "$choice" || true
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,7 +640,7 @@ show_monitor_menu() {
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
handle_monitor_menu "$choice"
|
handle_monitor_menu "$choice" || true
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -649,7 +654,7 @@ show_backup_menu() {
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
handle_backup_menu "$choice"
|
handle_backup_menu "$choice" || true
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -663,7 +668,7 @@ show_update_menu() {
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
handle_update_menu "$choice"
|
handle_update_menu "$choice" || true
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -677,7 +682,7 @@ show_advanced_menu() {
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
handle_advanced_menu "$choice"
|
handle_advanced_menu "$choice" || true
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ check_user_permissions() {
|
|||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! sudo -n true 2>/dev/null; then
|
if ! sudo -n true 2>/dev/null && ! sudo -l >/dev/null 2>&1; then
|
||||||
print_error "User does not have sudo access"
|
print_error "User does not have sudo access"
|
||||||
print_error "Please ensure your user can run sudo commands"
|
print_error "Please ensure your user can run sudo commands"
|
||||||
return 1
|
return 1
|
||||||
@@ -319,7 +319,8 @@ main() {
|
|||||||
local warnings=0
|
local warnings=0
|
||||||
local failed=0
|
local failed=0
|
||||||
|
|
||||||
# Run all checks
|
# Run all checks (disable strict error checking for this loop)
|
||||||
|
set +e
|
||||||
local checks=(
|
local checks=(
|
||||||
"check_os_compatibility"
|
"check_os_compatibility"
|
||||||
"check_system_resources"
|
"check_system_resources"
|
||||||
@@ -346,6 +347,7 @@ main() {
|
|||||||
((failed++))
|
((failed++))
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
set -e # Re-enable strict error checking
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
print_info "Pre-flight validation complete!"
|
print_info "Pre-flight validation complete!"
|
||||||
|
|||||||
Reference in New Issue
Block a user