fix: windows check added to vagrant config

This commit is contained in:
jon brookes 2025-08-06 08:39:26 +01:00
parent 698e67d8c0
commit f39f98b319

View file

@ -10,11 +10,16 @@ if ! command -v vagrant &> /dev/null; then
exit 1 exit 1
fi fi
# Check if VirtualBox is installed # 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 if ! command -v VBoxManage &> /dev/null; then
echo "VirtualBox is not installed. Please install VirtualBox to proceed." echo "VirtualBox is not installed. Please install VirtualBox to proceed."
exit 1 exit 1
fi fi
fi
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "Script directory: $SCRIPT_DIR" echo "Script directory: $SCRIPT_DIR"
@ -72,6 +77,17 @@ echo "Network information gathered successfully."
echo "Gathering Vagrant port information..." 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 while read -r line; do
echo "Processing line: $line" echo "Processing line: $line"
@ -81,15 +97,13 @@ while read -r line; do
vagrant_ports+=("$port") vagrant_ports+=("$port")
done < <(vagrant ssh-config | grep Port) done < <(vagrant ssh-config | grep Port)
while read -r line; do while read -r line; do
echo "Processing line: $line" echo "Processing line: $line"
# Extract the port number # Extract the port number
port=$(echo "$line" | awk '{print $2}') port=$(echo "$line" | awk '{print $2}')
echo "Extracted port: $port" echo "Extracted port: $port"
vagrant_ports+=("$port") add_unique_port "$port"
done < <(vagrant ssh-config | grep Port) done < <(vagrant ssh-config | grep Port)