-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·68 lines (63 loc) · 2.34 KB
/
Copy pathdocker-entrypoint.sh
File metadata and controls
executable file
·68 lines (63 loc) · 2.34 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
#!/bin/sh
set -eu
# Keep runtime-created SQLite files writable when OpenShift rotates the
# arbitrary UID while retaining the image's root-group permission model.
umask 0002
# Mirror the server's default only for permission preparation. Keep DATABASE_URL
# unset so the Rust CLI remains authoritative for the actual connection URL.
agentic_api_home=${AGENTIC_API_HOME:-/var/lib/agentic-api}
database_url=${DATABASE_URL:-sqlite://${agentic_api_home}/agentic_api.db}
case "$database_url" in
sqlite::memory:*)
;;
sqlite://*)
case "$database_url" in
*%*)
echo "DATABASE_URL percent-encoded SQLite paths are not supported by this container entrypoint" >&2
exit 64
;;
esac
sqlite_query=
case "$database_url" in
*\?*)
sqlite_query=${database_url#*\?}
sqlite_query=${sqlite_query%%\#*}
;;
esac
prepare_sqlite=true
case "&$sqlite_query&" in
*"&mode=ro&"* | *"&mode=rw&"* | *"&mode=memory&"*)
prepare_sqlite=false
;;
esac
if [ "$prepare_sqlite" = true ]; then
# `?` and `#` are URI query/fragment delimiters, so they are not part
# of the filesystem path extracted here. Keep the parent directory
# group-writable so a rotated arbitrary UID can create SQLite sidecar files.
database_path=${database_url#sqlite://}
database_path=${database_path%%\?*}
database_path=${database_path%%\#*}
if [ -n "$database_path" ]; then
if [ ! -e "$database_path" ]; then
: >"$database_path"
chmod g+rw "$database_path"
fi
database_directory=$(dirname -- "$database_path")
chmod g+rwx "$database_directory" 2>/dev/null || true
fi
fi
;;
esac
# Both binaries share the storage prepared above. The command may name the one to
# run; anything else is passed to the default. AGENTIC_BINARY is the alternative
# for platforms that set arguments but not the command.
case "${1:-}" in
agentic-server | agentic-llm-d)
binary=$1
shift
;;
*)
binary=${AGENTIC_BINARY:-agentic-server}
;;
esac
exec "$binary" "$@"