Skip to content

Commit 6af56ba

Browse files
author
Kasikrit (Gus) Chantharuang
committed
Edited nemoclaw-start.sh
1 parent d527aa7 commit 6af56ba

File tree

1 file changed

+51
-11
lines changed

1 file changed

+51
-11
lines changed

sandboxes/nemoclaw/nemoclaw-start.sh

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,75 @@
1414
# NVIDIA_INFERENCE_API_KEY — key for inference-api.nvidia.com
1515
# NVIDIA_INTEGRATE_API_KEY — key for integrate.api.nvidia.com
1616
#
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/ \
1919
# --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
2323
set -euo pipefail
2424

2525
# --------------------------------------------------------------------------
2626
# Runtime API key injection
2727
#
2828
# The build bakes __NVIDIA_*_API_KEY__ placeholders into the bundled JS.
2929
# 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.
3036
# --------------------------------------------------------------------------
3137
BUNDLE="$(npm root -g)/openclaw/dist/control-ui/assets/nemoclaw-devx.js"
3238

3339
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."
3852
fi
3953

4054
# --------------------------------------------------------------------------
4155
# Onboard and start the gateway
4256
# --------------------------------------------------------------------------
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+
"
4484

45-
nohup openclaw gateway run > /tmp/gateway.log 2>&1 &
85+
nohup openclaw gateway > /tmp/gateway.log 2>&1 &
4686

4787
CONFIG_FILE="${HOME}/.openclaw/openclaw.json"
4888
token=$(grep -o '"token"\s*:\s*"[^"]*"' "${CONFIG_FILE}" 2>/dev/null | head -1 | cut -d'"' -f4 || true)

0 commit comments

Comments
 (0)