mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-02 22:00:19 +00:00
- 5 nanoclaw scripts only create DOTENV_TEMP but trap referenced both - Causes trap to fail silently when trying to rm undefined variable - Fix: Change trap from both temps to just DOTENV_TEMP - Affected: digitalocean, hetzner, linode, sprite, vultr Root cause: Automated trap addition in Round 19 incorrectly detected these files as using both temp variables (DOTENV_TEMP contains substring ENV_TEMP which caused false positive in grep check)
42 lines
1.8 KiB
Bash
Executable file
42 lines
1.8 KiB
Bash
Executable file
#!/bin/bash
|
|
set -eo pipefail
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
|
|
# shellcheck source=linode/lib/common.sh
|
|
if [[ -f "${SCRIPT_DIR}/lib/common.sh" ]]; then source "${SCRIPT_DIR}/lib/common.sh"
|
|
else eval "$(curl -fsSL https://raw.githubusercontent.com/OpenRouterTeam/spawn/main/linode/lib/common.sh)"; fi
|
|
log_info "NanoClaw on Linode"
|
|
echo ""
|
|
ensure_linode_token
|
|
ensure_ssh_key
|
|
SERVER_NAME=$(get_server_name)
|
|
create_server "${SERVER_NAME}"
|
|
verify_server_connectivity "${LINODE_SERVER_IP}"
|
|
wait_for_cloud_init "${LINODE_SERVER_IP}" 60
|
|
log_warn "Installing tsx..."
|
|
run_server "${LINODE_SERVER_IP}" "source ~/.bashrc && bun install -g tsx"
|
|
log_warn "Cloning and building nanoclaw..."
|
|
run_server "${LINODE_SERVER_IP}" "git clone https://github.com/gavrielc/nanoclaw.git ~/nanoclaw && cd ~/nanoclaw && npm install && npm run build"
|
|
log_info "NanoClaw installed"
|
|
echo ""
|
|
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_ssh "${LINODE_SERVER_IP}" upload_file run_server \
|
|
"OPENROUTER_API_KEY=${OPENROUTER_API_KEY}" \
|
|
"ANTHROPIC_API_KEY=${OPENROUTER_API_KEY}" \
|
|
"ANTHROPIC_BASE_URL=https://openrouter.ai/api"
|
|
log_warn "Configuring nanoclaw..."
|
|
DOTENV_TEMP=$(mktemp)
|
|
trap 'rm -f "${DOTENV_TEMP}"' EXIT
|
|
chmod 600 "${DOTENV_TEMP}"
|
|
cat > "${DOTENV_TEMP}" << EOF
|
|
ANTHROPIC_API_KEY=${OPENROUTER_API_KEY}
|
|
EOF
|
|
upload_file "${LINODE_SERVER_IP}" "${DOTENV_TEMP}" "/root/nanoclaw/.env"
|
|
echo ""
|
|
log_info "Linode setup completed successfully!"
|
|
echo ""
|
|
log_warn "Starting nanoclaw..."
|
|
log_warn "You will need to scan a WhatsApp QR code to authenticate."
|
|
echo ""
|
|
interactive_session "${LINODE_SERVER_IP}" "cd ~/nanoclaw && source ~/.zshrc && npm run dev"
|