mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-08 01:51:14 +00:00
feat: Add opencode on FluidStack (#288)
Agent: gap-filler Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
22a4d6baee
commit
a873d26a67
2 changed files with 59 additions and 1 deletions
58
fluidstack/opencode.sh
Normal file
58
fluidstack/opencode.sh
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#!/bin/bash
|
||||
# shellcheck disable=SC2154
|
||||
set -eo pipefail
|
||||
|
||||
# Source common functions - try local file first, fall back to remote
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
|
||||
# shellcheck source=fluidstack/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/fluidstack/lib/common.sh)"
|
||||
fi
|
||||
|
||||
log_info "OpenCode on FluidStack"
|
||||
echo ""
|
||||
|
||||
# 1. Ensure FluidStack API key is configured
|
||||
ensure_fluidstack_token
|
||||
|
||||
# 2. Generate + register SSH key
|
||||
ensure_ssh_key
|
||||
|
||||
# 3. Get instance name and create instance
|
||||
SERVER_NAME=$(get_server_name)
|
||||
create_server "${SERVER_NAME}"
|
||||
|
||||
# 4. Wait for SSH connectivity and install base tools
|
||||
verify_server_connectivity
|
||||
install_base_tools
|
||||
|
||||
# 5. Install OpenCode
|
||||
log_warn "Installing OpenCode..."
|
||||
run_server "${FLUIDSTACK_SERVER_IP}" "$(opencode_install_cmd)"
|
||||
log_info "OpenCode installed"
|
||||
|
||||
# 6. Get OpenRouter API key
|
||||
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
|
||||
|
||||
# 7. Inject environment variables
|
||||
log_warn "Setting up environment variables..."
|
||||
inject_env_vars_ssh "${FLUIDSTACK_SERVER_IP}" upload_file run_server \
|
||||
"OPENROUTER_API_KEY=${OPENROUTER_API_KEY}"
|
||||
|
||||
echo ""
|
||||
log_info "FluidStack instance setup completed successfully!"
|
||||
log_info "Instance: ${SERVER_NAME} (IP: ${FLUIDSTACK_SERVER_IP})"
|
||||
echo ""
|
||||
|
||||
# 8. Start OpenCode interactively
|
||||
log_warn "Starting OpenCode..."
|
||||
sleep 1
|
||||
clear
|
||||
interactive_session "${FLUIDSTACK_SERVER_IP}" "source ~/.zshrc && opencode"
|
||||
Loading…
Add table
Add a link
Reference in a new issue