From f39f98b319f5432c2a6b9259e6fc377b7331b682 Mon Sep 17 00:00:00 2001 From: jon brookes Date: Wed, 6 Aug 2025 08:39:26 +0100 Subject: [PATCH] fix: windows check added to vagrant config --- scripts/configure_vagrant_k3s.sh | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/scripts/configure_vagrant_k3s.sh b/scripts/configure_vagrant_k3s.sh index 92ce1ca..0ca352d 100755 --- a/scripts/configure_vagrant_k3s.sh +++ b/scripts/configure_vagrant_k3s.sh @@ -10,10 +10,15 @@ if ! command -v vagrant &> /dev/null; then exit 1 fi -# Check if VirtualBox is installed -if ! command -v VBoxManage &> /dev/null; then - echo "VirtualBox is not installed. Please install VirtualBox to proceed." - exit 1 +# Check if running on Windows +if [[ "$(uname -s)" == *"MINGW"* || "$(uname -s)" == *"CYGWIN"* || "$OSTYPE" == "msys" ]]; then + echo "Detected Windows environment. Skipping VBoxManage check as Vagrant will handle VirtualBox interactions." +else + # Check if VirtualBox is installed (for non-Windows systems) + if ! command -v VBoxManage &> /dev/null; then + echo "VirtualBox is not installed. Please install VirtualBox to proceed." + exit 1 + fi fi SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" @@ -72,6 +77,17 @@ echo "Network information gathered successfully." echo "Gathering Vagrant port information..." +# Ensure unique ports are added to the vagrant_ports array +add_unique_port() { + local port=$1 + for existing_port in "${vagrant_ports[@]}"; do + if [ "$existing_port" == "$port" ]; then + return + fi + done + vagrant_ports+=("$port") +} + while read -r line; do echo "Processing line: $line" @@ -81,15 +97,13 @@ while read -r line; do vagrant_ports+=("$port") done < <(vagrant ssh-config | grep Port) - - while read -r line; do echo "Processing line: $line" # Extract the port number port=$(echo "$line" | awk '{print $2}') echo "Extracted port: $port" - vagrant_ports+=("$port") + add_unique_port "$port" done < <(vagrant ssh-config | grep Port)