Fix config file paths and missing OPENROUTER_API_KEY env check

The refactor in f9dd9a7 hardcoded /root/ as the upload destination for
Claude Code and OpenClaw config files, breaking all non-root providers
(Lambda, AWS Lightsail, GCP, Sprite, E2B, Modal, Fly). Upload to /tmp/
first then mv to ~/ via run_callback so the remote shell expands ~ to
the correct home directory.

Also add OPENROUTER_API_KEY env var check to sprite scripts (claude,
openclaw, nanoclaw) so the OAuth flow is skipped when the key is already
set, and fix echo -e to printf for macOS bash 3.x compat.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Sprite 2026-02-08 04:52:49 +00:00
parent 2f78a77c44
commit bb397d0bc6
4 changed files with 28 additions and 13 deletions

View file

@ -19,15 +19,15 @@ NC='\033[0m' # No Color
# Print colored messages (to stderr so they don't pollute command substitution output)
log_info() {
echo -e "${GREEN}${1}${NC}" >&2
printf '%b\n' "${GREEN}${1}${NC}" >&2
}
log_warn() {
echo -e "${YELLOW}${1}${NC}" >&2
printf '%b\n' "${YELLOW}${1}${NC}" >&2
}
log_error() {
echo -e "${RED}${1}${NC}" >&2
printf '%b\n' "${RED}${1}${NC}" >&2
}
# ============================================================
@ -317,7 +317,7 @@ get_model_id_interactive() {
get_openrouter_api_key_manual() {
echo ""
log_warn "Manual API Key Entry"
echo -e "${YELLOW}Get your API key from: https://openrouter.ai/settings/keys${NC}"
printf '%b\n' "${YELLOW}Get your API key from: https://openrouter.ai/settings/keys${NC}"
echo ""
local api_key=""
@ -1109,7 +1109,8 @@ setup_claude_code_config() {
}
EOF
${upload_callback} "${settings_temp}" "/root/.claude/settings.json"
${upload_callback} "${settings_temp}" "/tmp/claude_settings_$$"
${run_callback} "mv /tmp/claude_settings_$$ ~/.claude/settings.json"
# Create .claude.json global state
local global_state_temp
@ -1124,7 +1125,8 @@ EOF
}
EOF
${upload_callback} "${global_state_temp}" "/root/.claude.json"
${upload_callback} "${global_state_temp}" "/tmp/claude_global_$$"
${run_callback} "mv /tmp/claude_global_$$ ~/.claude.json"
# Create empty CLAUDE.md
${run_callback} "touch ~/.claude/CLAUDE.md"
@ -1195,7 +1197,8 @@ setup_openclaw_config() {
}
EOF
${upload_callback} "${config_temp}" "/root/.openclaw/openclaw.json"
${upload_callback} "${config_temp}" "/tmp/openclaw_config_$$"
${run_callback} "mv /tmp/openclaw_config_$$ ~/.openclaw/openclaw.json"
}
# ============================================================

View file

@ -37,9 +37,13 @@ if ! run_sprite "${SPRITE_NAME}" "command -v claude &> /dev/null && claude --ver
fi
log_info "Claude Code installation verified successfully"
# Get OpenRouter API key via OAuth
# Get OpenRouter API key
echo ""
OPENROUTER_API_KEY=$(get_openrouter_api_key_oauth 5180)
if [[ -n "${OPENROUTER_API_KEY:-}" ]]; then
log_info "Using OpenRouter API key from environment"
else
OPENROUTER_API_KEY=$(get_openrouter_api_key_oauth 5180)
fi
log_warn "Setting up environment variables..."
inject_env_vars_sprite "${SPRITE_NAME}" \

View file

@ -33,9 +33,13 @@ run_sprite "${SPRITE_NAME}" "/.sprite/languages/bun/bin/bun install -g tsx"
log_warn "Cloning nanoclaw..."
run_sprite "${SPRITE_NAME}" "git clone https://github.com/gavrielc/nanoclaw.git ~/nanoclaw && cd ~/nanoclaw && npm install && npm run build"
# Get OpenRouter API key via OAuth
# Get OpenRouter API key
echo ""
OPENROUTER_API_KEY=$(get_openrouter_api_key_oauth 5180)
if [[ -n "${OPENROUTER_API_KEY:-}" ]]; then
log_info "Using OpenRouter API key from environment"
else
OPENROUTER_API_KEY=$(get_openrouter_api_key_oauth 5180)
fi
log_warn "Setting up environment variables..."
inject_env_vars_sprite "${SPRITE_NAME}" \

View file

@ -28,9 +28,13 @@ setup_shell_environment "${SPRITE_NAME}"
log_warn "Installing openclaw..."
run_sprite "${SPRITE_NAME}" "/.sprite/languages/bun/bin/bun install -g openclaw"
# Get OpenRouter API key via OAuth
# Get OpenRouter API key
echo ""
OPENROUTER_API_KEY=$(get_openrouter_api_key_oauth 5180)
if [[ -n "${OPENROUTER_API_KEY:-}" ]]; then
log_info "Using OpenRouter API key from environment"
else
OPENROUTER_API_KEY=$(get_openrouter_api_key_oauth 5180)
fi
# Get model preference
MODEL_ID=$(get_model_id_interactive "openrouter/auto" "Openclaw") || exit 1