From 19f1ca62cb881ee436ae232a67c3e2240c276713 Mon Sep 17 00:00:00 2001 From: master3395 Date: Mon, 26 Jan 2026 21:11:18 +0100 Subject: [PATCH] Always re-capture OS variables in install_dependencies to ensure they persist - Always call detect_os() and get_os_info() in install_dependencies() - This ensures variables are fresh and properly captured - Add confirmation message showing captured values - Fixes issue where variables were detected but empty when passed to manage_dependencies --- install.sh | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/install.sh b/install.sh index 9ba721b80..733e8d6bf 100644 --- a/install.sh +++ b/install.sh @@ -248,25 +248,21 @@ detect_operating_system() { install_dependencies() { print_status "$BLUE" "📦 Installing dependencies..." - # Ensure variables are set (they should be from detect_operating_system) - # Re-detect if they're not set, using get_os_info() to capture values - if [ -z "$SERVER_OS" ] || [ -z "$OS_FAMILY" ] || [ -z "$PACKAGE_MANAGER" ]; then - print_status "$YELLOW" "⚠️ OS variables not set, re-detecting..." - # Try to get them again - if detect_os; then - # Use get_os_info() to properly capture the values - eval $(get_os_info) - export SERVER_OS OS_FAMILY PACKAGE_MANAGER ARCHITECTURE - print_status "$GREEN" "✅ Re-detected: SERVER_OS=$SERVER_OS, OS_FAMILY=$OS_FAMILY, PACKAGE_MANAGER=$PACKAGE_MANAGER" - else - print_status "$RED" "❌ Failed to detect OS for dependency installation" - return 1 - fi + # Always re-capture OS variables using get_os_info() to ensure we have the latest values + # This is necessary because variables might not persist between function calls + if detect_os; then + # Use get_os_info() to properly capture the values from the module + eval $(get_os_info) + export SERVER_OS OS_FAMILY PACKAGE_MANAGER ARCHITECTURE + print_status "$GREEN" "✅ Captured OS info: SERVER_OS=$SERVER_OS, OS_FAMILY=$OS_FAMILY, PACKAGE_MANAGER=$PACKAGE_MANAGER" + else + print_status "$RED" "❌ Failed to detect OS for dependency installation" + return 1 fi - # Verify variables one more time before calling + # Verify variables are set before calling manage_dependencies if [ -z "$SERVER_OS" ] || [ -z "$OS_FAMILY" ] || [ -z "$PACKAGE_MANAGER" ]; then - print_status "$RED" "❌ OS variables still not set after re-detection" + print_status "$RED" "❌ OS variables not set after detection" print_status "$RED" " SERVER_OS='$SERVER_OS', OS_FAMILY='$OS_FAMILY', PACKAGE_MANAGER='$PACKAGE_MANAGER'" return 1 fi