-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-dojo.sh
More file actions
executable file
·65 lines (56 loc) · 1.58 KB
/
Copy pathstart-dojo.sh
File metadata and controls
executable file
·65 lines (56 loc) · 1.58 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
#!/usr/bin/env bash
set -e
URL="http://localhost:7681"
open_browser() {
if [[ "$(uname -s)" == "Darwin" ]] && command -v open >/dev/null 2>&1; then
open "$URL" >/dev/null 2>&1 || true
elif grep -qi microsoft /proc/version 2>/dev/null && command -v cmd.exe >/dev/null 2>&1; then
cmd.exe /c start "$URL" >/dev/null 2>&1 || true
elif command -v xdg-open >/dev/null 2>&1; then
xdg-open "$URL" >/dev/null 2>&1 || true
else
return 0
fi
}
print_panel() {
cat <<EOF
GDB Dojo local browser terminal
Repo: $(pwd)
Mounted at: /dojo
Terminal: $URL
Container: gdb-dojo
Tools: gdb, gcc, g++, make, vim, nano
Opening $URL
Press Ctrl+C to stop.
EOF
}
if ! command -v docker >/dev/null 2>&1; then
echo "Docker was not found. Install Docker, then try again."
exit 1
fi
if ! docker info >/dev/null 2>&1; then
echo "Docker is installed but not running. Start Docker, then try again."
exit 1
fi
if docker compose version >/dev/null 2>&1; then
print_panel
echo "Building image quietly..."
docker compose build --quiet
echo "Starting terminal..."
echo "Opening browser after the terminal starts..."
(sleep 4; open_browser) &
echo
docker compose up
elif command -v docker-compose >/dev/null 2>&1; then
print_panel
echo "Building image..."
docker-compose build
echo "Starting terminal..."
echo "Opening browser after the terminal starts..."
(sleep 4; open_browser) &
echo
docker-compose up
else
echo "Docker Compose was not found. Install or update Docker."
exit 1
fi