diff --git a/first_time_install.sh b/first_time_install.sh index dbc6fc79..d533c2ff 100644 --- a/first_time_install.sh +++ b/first_time_install.sh @@ -982,7 +982,8 @@ if [ -f "$PROJECT_ROOT_DIR/scripts/install/install_wifi_monitor.sh" ]; then if [ ! -f "/etc/systemd/system/ledmatrix-wifi-monitor.service" ] || [ "$NEEDS_UPDATE" = true ]; then echo "Installing/updating WiFi monitor service..." - bash "$PROJECT_ROOT_DIR/scripts/install/install_wifi_monitor.sh" + # Pass ASSUME_YES to ensure non-interactive mode + ASSUME_YES="$ASSUME_YES" LEDMATRIX_ASSUME_YES="$ASSUME_YES" bash "$PROJECT_ROOT_DIR/scripts/install/install_wifi_monitor.sh" # Harden service file permissions (if service was created) if [ -f "/etc/systemd/system/ledmatrix-wifi-monitor.service" ]; then diff --git a/scripts/install/install_wifi_monitor.sh b/scripts/install/install_wifi_monitor.sh index e964df87..a5b43771 100755 --- a/scripts/install/install_wifi_monitor.sh +++ b/scripts/install/install_wifi_monitor.sh @@ -47,18 +47,19 @@ if [ ${#MISSING_PACKAGES[@]} -gt 0 ]; then echo "" # Check for non-interactive mode (ASSUME_YES or LEDMATRIX_ASSUME_YES) + # If called from installation script, always install packages automatically ASSUME_YES=${ASSUME_YES:-${LEDMATRIX_ASSUME_YES:-0}} - if [ "$ASSUME_YES" = "1" ]; then - echo "Non-interactive mode: installing required packages..." - sudo apt update - sudo apt install -y "${MISSING_PACKAGES[@]}" - echo "✓ Packages installed" - elif [ ! -t 0 ]; then - # Non-interactive mode detected (no TTY) but ASSUME_YES not set - echo "⚠ Non-interactive mode detected but ASSUME_YES not set." - echo " Installing packages automatically (required for WiFi setup)..." - sudo apt update - sudo apt install -y "${MISSING_PACKAGES[@]}" + if [ "$ASSUME_YES" = "1" ] || [ ! -t 0 ]; then + # Non-interactive mode - install packages automatically + # Use apt directly if running as root, otherwise use sudo + echo "Installing required packages automatically..." + if [ "$EUID" -eq 0 ]; then + apt update + apt install -y "${MISSING_PACKAGES[@]}" + else + sudo apt update + sudo apt install -y "${MISSING_PACKAGES[@]}" + fi echo "✓ Packages installed" else # Interactive mode - ask user