Repository navigation
Expand file tree
/
Copy pathinstall-languages.sh
More file actions
77 lines (69 loc) · 2.1 KB
/
Copy pathinstall-languages.sh
File metadata and controls
77 lines (69 loc) · 2.1 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
#!/bin/bash
# ============================================================
# install-languages.sh
# Install language runtimes into the Piston container.
# Run this ONCE after starting the container.
#
# Usage: bash install-languages.sh
# ============================================================
PISTON_URL="http://localhost:2000"
echo "🔧 Installing language packages into Piston..."
echo " This may take a few minutes on first run."
echo ""
# Array of languages to install (language:version)
LANGUAGES=(
"python:3.10.0"
"javascript:18.15.0"
"typescript:5.0.3"
"java:15.0.2"
"c:10.2.0"
"c++:10.2.0"
"csharp:6.12.0"
"go:1.16.2"
"rust:1.68.2"
"ruby:3.0.1"
"php:8.2.3"
"swift:5.3.3"
"kotlin:1.8.20"
"dart:2.19.6"
"scala:3.2.2"
"perl:5.36.0"
"lua:5.4.4"
"r:4.1.1"
"bash:5.2.0"
"sqlite3:3.36.0"
"haskell:9.0.1"
"elixir:1.11.3"
)
SUCCESS=0
FAIL=0
for LANG_VER in "${LANGUAGES[@]}"; do
IFS=':' read -r LANG VER <<< "$LANG_VER"
echo -n " 📦 Installing $LANG ($VER)... "
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" \
-X POST "$PISTON_URL/api/v2/packages" \
-H "Content-Type: application/json" \
-d "{\"language\": \"$LANG\", \"version\": \"$VER\"}")
if [ "$RESPONSE" = "200" ]; then
echo "✅"
((SUCCESS++))
else
echo "❌ (HTTP $RESPONSE — version might not be available, trying latest...)"
# Try without specific version — install whatever is available
RESPONSE2=$(curl -s "$PISTON_URL/api/v2/packages" | grep -o "\"$LANG\"" | head -1)
if [ -n "$RESPONSE2" ]; then
echo " ↳ $LANG is available in the package list, will use at runtime"
((SUCCESS++))
else
((FAIL++))
fi
fi
done
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " ✅ Installed: $SUCCESS languages"
echo " ❌ Failed: $FAIL languages"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "🎉 You can now run: npm start"
echo " Check available runtimes: curl $PISTON_URL/api/v2/runtimes | jq"