-
-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·116 lines (94 loc) · 3.87 KB
/
install.sh
File metadata and controls
executable file
·116 lines (94 loc) · 3.87 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
112
113
114
115
116
#!/bin/bash
# Function to get current macOS version
get_macos_version() {
sw_vers -productVersion | awk -F. '{print $1 "." $2}'
}
# Check the system type
if [[ "$OSTYPE" != "darwin"* ]]; then
echo "❌ This script is intended for macOS systems only. Exiting."
exit 1
fi
# Check macOS version
macos_version=$(get_macos_version)
if (( $(echo "$macos_version < 26.0" | bc -l) )); then
echo "Warning: Your macOS version is $macos_version. Version 26.0 or later is recommended. Some features of 'container' might not work properly."
else
echo "✅ macOS system detected."
fi
download_url="https://github.com/apple/container/releases/download/0.8.0/container-installer-signed.pkg"
# Check if container is installed and display its version
if command -v container &> /dev/null
then
echo "Apple 'container' tool detected. Current version:"
container --version
current_version=$(container --version | awk '{print $4}')
echo $current_version
target_version=$(echo $download_url | awk -F'/' '{print $8}')
if [ "$current_version" != "$target_version" ]; then
echo "Consider updating to version $target_version. Download it here: $download_url"
fi
echo "Stopping any running Apple 'container' processes..."
container system stop 2>/dev/null || true
else
echo "Apple 'container' tool not detected. Proceeding with installation..."
# Download and install the Apple 'container' tool
echo "Downloading Apple 'container' tool..."
curl -Lo container-installer.pkg "$download_url"
echo "Installing Apple 'container' tool..."
sudo installer -pkg container-installer.pkg -target /
fi
# Stop any existing container system to clean up stale connections
echo "Stopping any existing container system..."
container system stop 2>/dev/null || true
# Wait a moment for cleanup
sleep 2
# Start the container system (this is blocking and will wait for kernel download if needed)
echo "Starting the Sandbox Container system (this may take a few minutes if downloading kernel)..."
if ! container system start; then
echo "❌ Failed to start container system."
exit 1
fi
# Quick verification that system is ready
echo "Verifying container system is ready..."
if container system status &>/dev/null; then
echo "✅ Container system is ready."
else
echo "❌ Container system started but status check failed."
echo "Try running: container system stop && container system start"
exit 1
fi
echo "Setting up local network domain..."
# Run the commands for setting up the local network
echo "Running: sudo container system dns create local"
sudo container system dns create local 2>/dev/null || echo "DNS domain 'local' already exists (this is fine)"
echo "Running: container system property set dns.domain local"
container system property set dns.domain local
echo "Pulling the latest image: instavm/coderunner"
if ! container image pull instavm/coderunner; then
echo "❌ Failed to pull image. Please check your internet connection and try again."
exit 1
fi
echo "→ Ensuring coderunner assets directories…"
ASSETS_SRC="$HOME/.coderunner/assets"
mkdir -p "$ASSETS_SRC/skills/user"
mkdir -p "$ASSETS_SRC/outputs"
# Stop any existing coderunner container
echo "Stopping any existing coderunner container..."
container stop coderunner 2>/dev/null || true
sleep 2
# Run the command to start the sandbox container
echo "Running: container run --name coderunner --detach --rm --cpus 8 --memory 4g instavm/coderunner"
if container run \
--volume "$ASSETS_SRC/skills/user:/app/uploads/skills/user" \
--volume "$ASSETS_SRC/outputs:/app/uploads/outputs" \
--name coderunner \
--detach \
--rm \
--cpus 8 \
--memory 4g \
instavm/coderunner; then
echo "✅ Setup complete. MCP server is available at http://coderunner.local:8222/mcp"
else
echo "❌ Failed to start coderunner container. Please check the logs with: container logs coderunner"
exit 1
fi