|
14 | 14 | # NVIDIA_INFERENCE_API_KEY — key for inference-api.nvidia.com |
15 | 15 | # NVIDIA_INTEGRATE_API_KEY — key for integrate.api.nvidia.com |
16 | 16 | # |
17 | | -# Usage: |
18 | | -# nemoclaw sandbox create --from nemoclaw-launchable-ui \ |
| 17 | +# Usage (env vars inlined via env command to avoid nemoclaw -e quoting bug): |
| 18 | +# nemoclaw sandbox create --name nemoclaw --from sandboxes/nemoclaw/ \ |
19 | 19 | # --forward 18789 \ |
20 | | -# -e NVIDIA_INFERENCE_API_KEY=<key> \ |
21 | | -# -e NVIDIA_INTEGRATE_API_KEY=<key> \ |
22 | | -# -- openclaw-start |
| 20 | +# -- env NVIDIA_INFERENCE_API_KEY=<key> \ |
| 21 | +# NVIDIA_INTEGRATE_API_KEY=<key> \ |
| 22 | +# nemoclaw-start |
23 | 23 | set -euo pipefail |
24 | 24 |
|
25 | 25 | # -------------------------------------------------------------------------- |
26 | 26 | # Runtime API key injection |
27 | 27 | # |
28 | 28 | # The build bakes __NVIDIA_*_API_KEY__ placeholders into the bundled JS. |
29 | 29 | # Replace them with the real values supplied via environment variables. |
| 30 | +# |
| 31 | +# /usr is read-only under Landlock, so sed -i (which creates a temp file |
| 32 | +# in the same directory) fails. Instead we sed to /tmp and write back |
| 33 | +# via shell redirection (truncate-write to the existing inode). If even |
| 34 | +# that is blocked, we skip gracefully — users can still enter keys via |
| 35 | +# the API Keys page in the OpenClaw UI. |
30 | 36 | # -------------------------------------------------------------------------- |
31 | 37 | BUNDLE="$(npm root -g)/openclaw/dist/control-ui/assets/nemoclaw-devx.js" |
32 | 38 |
|
33 | 39 | if [ -f "$BUNDLE" ]; then |
34 | | - [ -n "${NVIDIA_INFERENCE_API_KEY:-}" ] && \ |
35 | | - sed -i "s|__NVIDIA_INFERENCE_API_KEY__|${NVIDIA_INFERENCE_API_KEY}|g" "$BUNDLE" |
36 | | - [ -n "${NVIDIA_INTEGRATE_API_KEY:-}" ] && \ |
37 | | - sed -i "s|__NVIDIA_INTEGRATE_API_KEY__|${NVIDIA_INTEGRATE_API_KEY}|g" "$BUNDLE" |
| 40 | + ( |
| 41 | + set +e |
| 42 | + tmp="/tmp/_nemoclaw_bundle_$$" |
| 43 | + cp "$BUNDLE" "$tmp" 2>/dev/null |
| 44 | + if [ $? -ne 0 ]; then exit 0; fi |
| 45 | + [ -n "${NVIDIA_INFERENCE_API_KEY:-}" ] && \ |
| 46 | + sed -i "s|__NVIDIA_INFERENCE_API_KEY__|${NVIDIA_INFERENCE_API_KEY}|g" "$tmp" |
| 47 | + [ -n "${NVIDIA_INTEGRATE_API_KEY:-}" ] && \ |
| 48 | + sed -i "s|__NVIDIA_INTEGRATE_API_KEY__|${NVIDIA_INTEGRATE_API_KEY}|g" "$tmp" |
| 49 | + cp "$tmp" "$BUNDLE" 2>/dev/null |
| 50 | + rm -f "$tmp" 2>/dev/null |
| 51 | + ) || echo "Note: API key injection into UI bundle skipped (read-only /usr). Keys can be set via the API Keys page." |
38 | 52 | fi |
39 | 53 |
|
40 | 54 | # -------------------------------------------------------------------------- |
41 | 55 | # Onboard and start the gateway |
42 | 56 | # -------------------------------------------------------------------------- |
43 | | -openclaw onboard |
| 57 | +export NVIDIA_API_KEY="${NVIDIA_INFERENCE_API_KEY:- }" |
| 58 | +openclaw onboard \ |
| 59 | + --non-interactive \ |
| 60 | + --accept-risk \ |
| 61 | + --mode local \ |
| 62 | + --no-install-daemon \ |
| 63 | + --skip-skills \ |
| 64 | + --skip-health \ |
| 65 | + --auth-choice custom-api-key \ |
| 66 | + --custom-base-url "https://inference-api.nvidia.com/v1" \ |
| 67 | + --custom-model-id "aws/anthropic/bedrock-claude-opus-4-6" \ |
| 68 | + --custom-api-key "${NVIDIA_API_KEY}" \ |
| 69 | + --secret-input-mode plaintext \ |
| 70 | + --custom-compatibility openai \ |
| 71 | + --gateway-port 18789 \ |
| 72 | + --gateway-bind loopback |
| 73 | + |
| 74 | +export NVIDIA_API_KEY=" " |
| 75 | +python3 -c " |
| 76 | +import json, os |
| 77 | +cfg = json.load(open(os.environ['HOME'] + '/.openclaw/openclaw.json')) |
| 78 | +cfg['gateway']['controlUi'] = { |
| 79 | + 'allowInsecureAuth': True, |
| 80 | + 'allowedOrigins': [os.environ['BREV_UI_URL']] |
| 81 | +} |
| 82 | +json.dump(cfg, open(os.environ['HOME'] + '/.openclaw/openclaw.json', 'w'), indent=2) |
| 83 | +" |
44 | 84 |
|
45 | | -nohup openclaw gateway run > /tmp/gateway.log 2>&1 & |
| 85 | +nohup openclaw gateway > /tmp/gateway.log 2>&1 & |
46 | 86 |
|
47 | 87 | CONFIG_FILE="${HOME}/.openclaw/openclaw.json" |
48 | 88 | token=$(grep -o '"token"\s*:\s*"[^"]*"' "${CONFIG_FILE}" 2>/dev/null | head -1 | cut -d'"' -f4 || true) |
|
0 commit comments