Skip to content

Commit fedf2f0

Browse files
Thomas TupperThomas Tupper
authored andcommitted
Add env validation script and wire into external smoke
1 parent 0a09e65 commit fedf2f0

3 files changed

Lines changed: 50 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ bash scripts/smoke-one.sh
5353
```bash
5454
cp .env.example .env
5555
# set OPENAI_BASE_URL and OPENAI_API_KEY for your provider
56+
bash scripts/validate-env.sh
5657
bash scripts/smoke-external.sh
5758
```
5859

scripts/smoke-external.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ if [ ! -f .env ]; then
55
echo "Create .env from .env.example and set OPENAI_BASE_URL/OPENAI_API_KEY first." >&2
66
exit 1
77
fi
8+
./scripts/validate-env.sh
89
cleanup(){ docker compose -f compose.external.yml down -v >/dev/null 2>&1 || true; }
910
trap cleanup EXIT
1011

scripts/validate-env.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
cd "$(dirname "$0")/.."
5+
6+
ENV_FILE=".env"
7+
if [ ! -f "$ENV_FILE" ]; then
8+
echo "Missing .env (copy from .env.example first)." >&2
9+
exit 1
10+
fi
11+
12+
required=(
13+
OPENAI_BASE_URL
14+
OPENAI_API_KEY
15+
MEM0_LLM_MODEL
16+
MEM0_EMBED_MODEL
17+
QDRANT_COLLECTION
18+
)
19+
20+
# At least one Qdrant endpoint form must be present
21+
has_qdrant_url=0
22+
has_qdrant_hostport=0
23+
24+
if grep -Eq '^QDRANT_URL=.+$' "$ENV_FILE"; then
25+
has_qdrant_url=1
26+
fi
27+
if grep -Eq '^QDRANT_HOST=.+$' "$ENV_FILE" && grep -Eq '^QDRANT_PORT=.+$' "$ENV_FILE"; then
28+
has_qdrant_hostport=1
29+
fi
30+
31+
missing=()
32+
for key in "${required[@]}"; do
33+
if ! grep -Eq "^${key}=.+$" "$ENV_FILE"; then
34+
missing+=("$key")
35+
fi
36+
done
37+
38+
if [ ${#missing[@]} -gt 0 ]; then
39+
echo "Missing required env vars in .env: ${missing[*]}" >&2
40+
exit 1
41+
fi
42+
43+
if [ "$has_qdrant_url" -eq 0 ] && [ "$has_qdrant_hostport" -eq 0 ]; then
44+
echo "Missing Qdrant endpoint: set QDRANT_URL or both QDRANT_HOST and QDRANT_PORT." >&2
45+
exit 1
46+
fi
47+
48+
echo "env-validate: OK"

0 commit comments

Comments
 (0)