-
-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathentrypoint.sh
More file actions
38 lines (33 loc) · 1.14 KB
/
entrypoint.sh
File metadata and controls
38 lines (33 loc) · 1.14 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
#!/bin/sh
# Default transport to stdio
TRANSPORT_MODE="stdio"
# Check if DROIDMIND_TRANSPORT is set and not empty
if [ -n "$DROIDMIND_TRANSPORT" ]; then
TRANSPORT_MODE="$DROIDMIND_TRANSPORT"
fi
# If CMD is just 'droidmind' or empty, use default args for the chosen transport
if [ "$#" -eq 0 ] || { [ "$#" -eq 1 ] && [ "$1" = "droidmind" ]; }; then
if [ "$TRANSPORT_MODE" = "sse" ]; then
exec droidmind --transport sse --host 0.0.0.0 --port 4256
else
exec droidmind --transport stdio
fi
else
# If CMD has other arguments, pass them through, but ensure --transport is set correctly
# This is a bit more complex to do perfectly without overriding user's explicit --transport
# For now, we'll prioritize DROIDMIND_TRANSPORT if no --transport is in CMD args
HAS_TRANSPORT_ARG=false
# Loop through arguments to check for --transport flag
for arg in "$@"; do
if [ "$arg" = "--transport" ]; then
HAS_TRANSPORT_ARG=true
break
fi
done
if [ "$HAS_TRANSPORT_ARG" = "false" ]; then
exec droidmind --transport "$TRANSPORT_MODE" "$@"
else
# User has provided --transport, let it be
exec droidmind "$@"
fi
fi