#!/usr/bin/env bash # Writes OpenClaw Groq provider config into the running clawtainer container # using GROQ_API_KEY from project .env. Run after: docker compose up -d set -e cd "$(dirname "$0")/.." if [ ! -f .env ]; then echo "No .env found. Add GROQ_API_KEY=your-key to .env" exit 1 fi # shellcheck source=/dev/null source .env if [ -z "${GROQ_API_KEY}" ]; then echo "Set GROQ_API_KEY in .env" exit 1 fi # Escape for JSON: \ and " key_esc="${GROQ_API_KEY//\\/\\\\}" key_esc="${key_esc//\"/\\\"}" tmp=$(mktemp) trap 'rm -f "$tmp"' EXIT sed "s|GROQ_API_KEY_PLACEHOLDER|$key_esc|g" scripts/openclaw-groq.json.template > "$tmp" docker exec clawtainer mkdir -p /home/kasm-user/.openclaw/canvas /home/kasm-user/.openclaw/cron /home/kasm-user/.openclaw/workspace docker cp "$tmp" clawtainer:"/home/kasm-user/.openclaw/openclaw.json" docker exec -u root clawtainer chown -R 1000:1000 /home/kasm-user/.openclaw if ! docker exec clawtainer pgrep -x openclaw >/dev/null 2>&1; then docker exec clawtainer bash -c 'nohup openclaw gateway --bind lan --allow-unconfigured >/tmp/openclaw.log 2>&1 &' echo "Gateway started." fi echo "OpenClaw configured for Groq. Control UI: http://localhost:18789 (token: clawtainer)"