-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·111 lines (96 loc) · 3.53 KB
/
install.sh
File metadata and controls
executable file
·111 lines (96 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
# Crane Simulation - Installation Script
# This script checks for Docker and installs it if needed, then runs the application
set -e
echo "🏗️ Crane Simulation - Installation Script"
echo "=========================================="
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to detect OS
detect_os() {
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "macos"
elif [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
echo "windows"
else
echo "unknown"
fi
}
# Check for Docker
echo "🔍 Checking for Docker..."
if ! command_exists docker; then
echo "❌ Docker not found. Installing Docker..."
OS=$(detect_os)
case $OS in
"linux")
echo "📦 Installing Docker on Linux..."
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
sudo usermod -aG docker $USER
echo "⚠️ You may need to log out and back in for Docker permissions to take effect"
;;
"macos")
echo "📦 Please install Docker Desktop from: https://docs.docker.com/desktop/install/mac/"
echo " Then run this script again."
exit 1
;;
"windows")
echo "📦 Please install Docker Desktop from: https://docs.docker.com/desktop/install/windows/"
echo " Then run this script again."
exit 1
;;
*)
echo "❌ Unsupported OS. Please install Docker manually from: https://docs.docker.com/get-docker/"
exit 1
;;
esac
else
echo "✅ Docker found"
fi
# Check for Docker Compose
echo "🔍 Checking for Docker Compose..."
if ! command_exists docker-compose && ! docker compose version >/dev/null 2>&1; then
echo "❌ Docker Compose not found"
echo "📦 Installing Docker Compose..."
# Try to install docker-compose
if command_exists curl; then
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
else
echo "❌ curl not found. Please install Docker Compose manually from: https://docs.docker.com/compose/install/"
exit 1
fi
else
echo "✅ Docker Compose found"
fi
# Verify Docker is running
echo "🔍 Checking if Docker is running..."
if ! docker info >/dev/null 2>&1; then
echo "❌ Docker is not running. Please start Docker and run this script again."
exit 1
fi
echo "✅ Docker is running"
# Check if port 8080 is available
echo "🔍 Checking if port 8080 is available..."
if command_exists lsof && lsof -i :8080 >/dev/null 2>&1; then
echo "⚠️ Port 8080 is in use. Stopping any existing containers..."
docker compose down 2>/dev/null || true
fi
# Build and run the application in development mode
echo "🚀 Building and starting the Crane Simulation (Development Mode)..."
echo " This may take a few minutes on first run..."
# Try docker compose first, fall back to docker-compose
if docker compose version >/dev/null 2>&1; then
docker compose -f docker-compose.dev.yml up --build
else
docker-compose -f docker-compose.dev.yml up --build
fi
echo ""
echo "🎉 Installation complete!"
echo " Frontend: http://localhost:5173"
echo " Backend: http://localhost:8080"
echo " Press Ctrl+C to stop the application"