diff --git a/hostinger/README.md b/hostinger/README.md new file mode 100644 index 00000000..2d8a21dc --- /dev/null +++ b/hostinger/README.md @@ -0,0 +1,151 @@ +# Hostinger VPS + +Hostinger is a budget VPS provider with cloud-init support and REST API provisioning. Starting at $4.95/month for 1 vCPU + 4GB RAM instances with hourly billing. + +## Quick Start + +Each script provisions a Hostinger VPS, installs the agent, injects OpenRouter credentials, and drops you into an interactive session. + +### Claude Code + +```bash +bash <(curl -fsSL https://raw.githubusercontent.com/OpenRouterTeam/spawn/main/hostinger/claude.sh) +``` + +### Aider + +```bash +bash <(curl -fsSL https://raw.githubusercontent.com/OpenRouterTeam/spawn/main/hostinger/aider.sh) +``` + +### OpenClaw + +```bash +bash <(curl -fsSL https://raw.githubusercontent.com/OpenRouterTeam/spawn/main/hostinger/openclaw.sh) +``` + +## Non-Interactive Mode + +All scripts support non-interactive execution via environment variables: + +```bash +export HOSTINGER_API_KEY="your-api-key" +export HOSTINGER_SERVER_NAME="my-vps" +export HOSTINGER_PLAN="kvm1" # Optional (default: kvm1) +export HOSTINGER_LOCATION="eu-central" # Optional (default: eu-central) +export OPENROUTER_API_KEY="your-key" # Optional (triggers OAuth if unset) + +bash <(curl -fsSL https://raw.githubusercontent.com/OpenRouterTeam/spawn/main/hostinger/claude.sh) +``` + +## Configuration + +### Authentication + +Get your Hostinger API key: +1. Log into hPanel: https://hpanel.hostinger.com/ +2. Click your Profile icon → Account Information +3. Navigate to API in the sidebar +4. Click 'Generate token' or 'New token' +5. Set token name and expiration, then click Generate +6. Copy the token: `export HOSTINGER_API_KEY=...` + +The token will be saved to `~/.config/spawn/hostinger.json` for reuse. + +### VPS Plans + +Common plans (hourly pricing estimated from monthly): +- `kvm1`: 1 vCPU, 4GB RAM, 50GB SSD (~$0.0068/hr) +- `kvm2`: 2 vCPU, 8GB RAM, 100GB SSD (~$0.0137/hr) +- `kvm4`: 4 vCPU, 16GB RAM, 200GB SSD (~$0.0274/hr) + +The script will show available plans if `HOSTINGER_PLAN` is not set. + +### Locations + +Available regions: +- `eu-central` (default) - Europe, Central +- `us-east` - United States, East Coast +- `asia-pacific` - Asia Pacific + +The script will show available locations if `HOSTINGER_LOCATION` is not set. + +### OS Templates + +Default: `ubuntu-24.04` + +Override with: +```bash +export HOSTINGER_OS_TEMPLATE="ubuntu-22.04" +``` + +## Environment Variables + +| Variable | Description | Default | +|----------|-------------|---------| +| `HOSTINGER_API_KEY` | API authentication token | Required (prompted if unset) | +| `HOSTINGER_SERVER_NAME` | VPS hostname | Required (prompted if unset) | +| `HOSTINGER_PLAN` | VPS plan ID | `kvm1` (interactive picker if unset) | +| `HOSTINGER_LOCATION` | Region/datacenter | `eu-central` (interactive picker if unset) | +| `HOSTINGER_OS_TEMPLATE` | Operating system | `ubuntu-24.04` | +| `OPENROUTER_API_KEY` | OpenRouter API key | OAuth flow if unset | + +## SSH Key Management + +The scripts automatically: +1. Generate `~/.ssh/spawn_ed25519` keypair if missing +2. Register the public key with Hostinger API +3. Wait for SSH connectivity after VPS creation + +To use an existing key: +```bash +export SPAWN_SSH_KEY_PATH="$HOME/.ssh/id_ed25519" +``` + +## Management + +### List VPSs + +```bash +source <(curl -fsSL https://raw.githubusercontent.com/OpenRouterTeam/spawn/main/hostinger/lib/common.sh) +ensure_hostinger_token +list_servers +``` + +### Destroy VPS + +```bash +source <(curl -fsSL https://raw.githubusercontent.com/OpenRouterTeam/spawn/main/hostinger/lib/common.sh) +ensure_hostinger_token +destroy_server "12345" # Replace with VPS ID from list_servers +``` + +## Cloud-Init Support + +All Hostinger VPS instances come with cloud-init pre-installed. The scripts inject userdata to: +- Install bun (JavaScript runtime) +- Install common tools (git, curl, zsh, etc.) +- Configure shell environment +- Set up OpenRouter API key injection + +## Pricing + +- Pay-per-hour billing (billed monthly based on usage) +- Starting at $4.95/month for kvm1 plan +- No bandwidth charges +- No setup fees + +## API Documentation + +Hostinger VPS API base: `https://api.hostinger.com/vps/v1` + +Common endpoints: +- `GET /virtual-machines` - List VPSs +- `POST /virtual-machines` - Create VPS +- `DELETE /virtual-machines/{id}` - Destroy VPS +- `GET /ssh-keys` - List SSH keys +- `POST /ssh-keys` - Register SSH key +- `GET /plans` - List available plans +- `GET /locations` - List available regions + +Authentication: Bearer token via `Authorization` header diff --git a/hostinger/aider.sh b/hostinger/aider.sh new file mode 100644 index 00000000..92fb5da3 --- /dev/null +++ b/hostinger/aider.sh @@ -0,0 +1,66 @@ +#!/bin/bash +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=hostinger/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/hostinger/lib/common.sh)" +fi + +log_info "Aider on Hostinger VPS" +echo "" + +# 1. Resolve Hostinger API key +ensure_hostinger_token + +# 2. Generate + register SSH key +ensure_ssh_key + +# 3. Get server name and create server +SERVER_NAME=$(get_server_name) +create_server "${SERVER_NAME}" + +# 4. Wait for SSH and cloud-init +verify_server_connectivity "${HOSTINGER_VPS_IP}" +wait_for_cloud_init "${HOSTINGER_VPS_IP}" 60 + +# 5. Install Aider +log_warn "Installing Aider..." +run_server "${HOSTINGER_VPS_IP}" "pip install aider-chat 2>/dev/null || pip3 install aider-chat" + +# Verify installation succeeded +if ! run_server "${HOSTINGER_VPS_IP}" "command -v aider &> /dev/null && aider --version &> /dev/null"; then + log_error "Aider installation verification failed" + log_error "The 'aider' command is not available or not working properly on VPS ${HOSTINGER_VPS_IP}" + exit 1 +fi +log_info "Aider installation verified successfully" + +# 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 + +# Get model preference +MODEL_ID=$(get_model_id_interactive "openrouter/auto" "Aider") || exit 1 + +log_warn "Setting up environment variables..." +inject_env_vars_ssh "${HOSTINGER_VPS_IP}" upload_file run_server \ + "OPENROUTER_API_KEY=${OPENROUTER_API_KEY}" + +echo "" +log_info "Hostinger VPS setup completed successfully!" +log_info "VPS: ${SERVER_NAME} (ID: ${HOSTINGER_VPS_ID}, IP: ${HOSTINGER_VPS_IP})" +echo "" + +# 9. Start Aider interactively +log_warn "Starting Aider..." +sleep 1 +clear +interactive_session "${HOSTINGER_VPS_IP}" "source ~/.zshrc && aider --model openrouter/${MODEL_ID}" diff --git a/hostinger/claude.sh b/hostinger/claude.sh new file mode 100644 index 00000000..71572a6a --- /dev/null +++ b/hostinger/claude.sh @@ -0,0 +1,76 @@ +#!/bin/bash +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=hostinger/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/hostinger/lib/common.sh)" +fi + +log_info "Claude Code on Hostinger VPS" +echo "" + +# 1. Resolve Hostinger API key +ensure_hostinger_token + +# 2. Generate + register SSH key +ensure_ssh_key + +# 3. Get server name and create server +SERVER_NAME=$(get_server_name) +create_server "${SERVER_NAME}" + +# 4. Wait for SSH and cloud-init +verify_server_connectivity "${HOSTINGER_VPS_IP}" +wait_for_cloud_init "${HOSTINGER_VPS_IP}" 60 + +# 5. Verify Claude Code is installed (fallback to manual install) +log_warn "Verifying Claude Code installation..." +if ! run_server "${HOSTINGER_VPS_IP}" "export PATH=\$HOME/.local/bin:\$PATH && command -v claude" >/dev/null 2>&1; then + log_warn "Claude Code not found, installing manually..." + run_server "${HOSTINGER_VPS_IP}" "curl -fsSL https://claude.ai/install.sh | bash" +fi + +# Verify installation succeeded +if ! run_server "${HOSTINGER_VPS_IP}" "export PATH=\$HOME/.local/bin:\$PATH && command -v claude &> /dev/null && claude --version &> /dev/null"; then + log_error "Claude Code installation verification failed" + log_error "The 'claude' command is not available or not working properly on VPS ${HOSTINGER_VPS_IP}" + exit 1 +fi +log_info "Claude Code installation verified successfully" + +# 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 + +log_warn "Setting up environment variables..." +inject_env_vars_ssh "${HOSTINGER_VPS_IP}" upload_file run_server \ + "OPENROUTER_API_KEY=${OPENROUTER_API_KEY}" \ + "ANTHROPIC_BASE_URL=https://openrouter.ai/api" \ + "ANTHROPIC_AUTH_TOKEN=${OPENROUTER_API_KEY}" \ + "ANTHROPIC_API_KEY=" \ + "CLAUDE_CODE_SKIP_ONBOARDING=1" \ + "CLAUDE_CODE_ENABLE_TELEMETRY=0" + +# 8. Configure Claude Code settings +setup_claude_code_config "${OPENROUTER_API_KEY}" \ + "upload_file ${HOSTINGER_VPS_IP}" \ + "run_server ${HOSTINGER_VPS_IP}" + +echo "" +log_info "Hostinger VPS setup completed successfully!" +log_info "VPS: ${SERVER_NAME} (ID: ${HOSTINGER_VPS_ID}, IP: ${HOSTINGER_VPS_IP})" +echo "" + +# 9. Start Claude Code interactively +log_warn "Starting Claude Code..." +sleep 1 +clear +interactive_session "${HOSTINGER_VPS_IP}" "export PATH=\$HOME/.local/bin:\$PATH && source ~/.zshrc && claude" diff --git a/hostinger/lib/common.sh b/hostinger/lib/common.sh new file mode 100644 index 00000000..0aca7157 --- /dev/null +++ b/hostinger/lib/common.sh @@ -0,0 +1,390 @@ +#!/bin/bash +set -eo pipefail +# Common bash functions for Hostinger VPS spawn scripts + +# ============================================================ +# Provider-agnostic functions +# ============================================================ + +# Source shared provider-agnostic functions (local or remote fallback) +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)" +if [[ -n "$SCRIPT_DIR" && -f "$SCRIPT_DIR/../../shared/common.sh" ]]; then + source "$SCRIPT_DIR/../../shared/common.sh" +else + eval "$(curl -fsSL https://raw.githubusercontent.com/OpenRouterTeam/spawn/main/shared/common.sh)" +fi + +# Note: Provider-agnostic functions (logging, OAuth, browser, nc_listen) are now in shared/common.sh + +# ============================================================ +# Hostinger VPS specific functions +# ============================================================ + +readonly HOSTINGER_API_BASE="https://api.hostinger.com/vps/v1" +# SSH_OPTS is now defined in shared/common.sh + +# Centralized curl wrapper for Hostinger API +hostinger_api() { + local method="$1" + local endpoint="$2" + local body="${3:-}" + # shellcheck disable=SC2154 + generic_cloud_api "$HOSTINGER_API_BASE" "$HOSTINGER_API_KEY" "$method" "$endpoint" "$body" +} + +test_hostinger_token() { + local response + response=$(hostinger_api GET "/virtual-machines") + if echo "$response" | grep -q '"error"\|"message"'; then + # Parse error details + local error_msg + error_msg=$(echo "$response" | python3 -c "import json,sys; d=json.loads(sys.stdin.read()); print(d.get('message','') or d.get('error','No details available'))" 2>/dev/null || echo "Unable to parse error") + log_error "API Error: $error_msg" + log_error "" + log_error "How to fix:" + log_error " 1. Log into hPanel at: https://hpanel.hostinger.com/" + log_error " 2. Click your Profile icon → Account Information" + log_error " 3. Navigate to API in the sidebar" + log_error " 4. Click 'Generate token' or 'New token'" + log_error " 5. Set token name and expiration, then click Generate" + log_error " 6. Copy the token and set: export HOSTINGER_API_KEY=..." + return 1 + fi + return 0 +} + +# Ensure HOSTINGER_API_KEY is available (env var → config file → prompt+save) +ensure_hostinger_token() { + ensure_api_token_with_provider \ + "Hostinger" \ + "HOSTINGER_API_KEY" \ + "$HOME/.config/spawn/hostinger.json" \ + "https://hpanel.hostinger.com/ → Profile → Account Information → API" \ + "test_hostinger_token" +} + +# Check if SSH key is registered with Hostinger +hostinger_check_ssh_key() { + local fingerprint="$1" + local existing_keys + existing_keys=$(hostinger_api GET "/ssh-keys") + echo "$existing_keys" | grep -q "$fingerprint" +} + +# Register SSH key with Hostinger +hostinger_register_ssh_key() { + local key_name="$1" + local pub_path="$2" + local pub_key + pub_key=$(cat "$pub_path") + local json_pub_key + json_pub_key=$(json_escape "$pub_key") + local register_body="{\"name\":\"$key_name\",\"public_key\":$json_pub_key}" + local register_response + register_response=$(hostinger_api POST "/ssh-keys" "$register_body") + + if echo "$register_response" | grep -q '"error"\|"message".*fail'; then + # Parse error details + local error_msg + error_msg=$(echo "$register_response" | python3 -c "import json,sys; d=json.loads(sys.stdin.read()); print(d.get('message','') or d.get('error','Unknown error'))" 2>/dev/null || echo "$register_response") + log_error "API Error: $error_msg" + log_error "" + log_error "Common causes:" + log_error " - SSH key already registered with this name" + log_error " - Invalid SSH key format (must be valid ed25519 or RSA public key)" + log_error " - API token lacks write permissions" + return 1 + fi + + return 0 +} + +# Ensure SSH key exists locally and is registered with Hostinger +ensure_ssh_key() { + ensure_ssh_key_with_provider hostinger_check_ssh_key hostinger_register_ssh_key "Hostinger" +} + +# Get server name from env var or prompt +get_server_name() { + local server_name + server_name=$(get_resource_name "HOSTINGER_SERVER_NAME" "Enter VPS name: ") || return 1 + + if ! validate_server_name "$server_name"; then + return 1 + fi + + echo "$server_name" +} + +# Fetch available VPS plans +# Outputs: "id|name|vcpus|ram_gb|disk_gb|price" lines +_list_vps_plans() { + local response + response=$(hostinger_api GET "/plans") + + echo "$response" | python3 -c " +import json, sys +data = json.loads(sys.stdin.read()) +plans = [] +for p in data.get('plans', []): + if p.get('available', True): + plan_id = p['id'] + name = p.get('name', plan_id) + vcpus = p.get('vcpus', 'N/A') + ram = p.get('ram_mb', 0) / 1024.0 + disk = p.get('disk_gb', 'N/A') + price = float(p.get('price_monthly', 0)) / 730.0 # Monthly to hourly + plans.append((price, plan_id, name, vcpus, ram, disk)) +plans.sort() +for price, pid, name, vcpus, ram, disk in plans: + print(f'{pid}|{name}|{vcpus} vCPU|{ram:.1f} GB RAM|{disk} GB disk|\${price:.4f}/hr') +" +} + +# Fetch available locations +# Outputs: "id|name|country" lines +_list_locations() { + local response + response=$(hostinger_api GET "/locations") + + echo "$response" | python3 -c " +import json, sys +data = json.loads(sys.stdin.read()) +for loc in sorted(data.get('locations', []), key=lambda l: l.get('name', '')): + loc_id = loc['id'] + name = loc.get('name', loc_id) + country = loc.get('country', 'Unknown') + print(f\"{loc_id}|{name}|{country}\") +" +} + +# Interactive location picker (skipped if HOSTINGER_LOCATION is set) +_pick_location() { + if [[ -n "${HOSTINGER_LOCATION:-}" ]]; then + echo "$HOSTINGER_LOCATION" + return + fi + + log_info "Fetching available locations..." + local locations + locations=$(_list_locations) + + if [[ -z "$locations" ]]; then + log_warn "Could not fetch locations, using default: eu-central" + echo "eu-central" + return + fi + + log_info "Available locations:" + local i=1 + local ids=() + while IFS='|' read -r id name country; do + printf " %2d) %-15s %s, %s\n" "$i" "$id" "$name" "$country" >&2 + ids+=("$id") + i=$((i + 1)) + done <<< "$locations" + + local choice + printf "\n" >&2 + choice=$(safe_read "Select location [1]: ") || choice="" + choice="${choice:-1}" + + if [[ "$choice" -ge 1 && "$choice" -le "${#ids[@]}" ]] 2>/dev/null; then + echo "${ids[$((choice - 1))]}" + else + log_warn "Invalid choice, using default: eu-central" + echo "eu-central" + fi +} + +# Interactive VPS plan picker (skipped if HOSTINGER_PLAN is set) +_pick_plan() { + if [[ -n "${HOSTINGER_PLAN:-}" ]]; then + echo "$HOSTINGER_PLAN" + return + fi + + log_info "Fetching available VPS plans..." + local plans + plans=$(_list_vps_plans) + + if [[ -z "$plans" ]]; then + log_warn "Could not fetch plans, using default: kvm1" + echo "kvm1" + return + fi + + log_info "Available VPS plans:" + local i=1 + local ids=() + local default_idx=1 + while IFS='|' read -r id name vcpus ram disk price; do + printf " %2d) %-10s %-20s %-8s %-12s %-12s %s\n" "$i" "$id" "$name" "$vcpus" "$ram" "$disk" "$price" >&2 + ids+=("$id") + if [[ "$id" == "kvm1" ]]; then + default_idx=$i + fi + i=$((i + 1)) + done <<< "$plans" + + local choice + printf "\n" >&2 + choice=$(safe_read "Select plan [${default_idx}]: ") || choice="" + choice="${choice:-$default_idx}" + + if [[ "$choice" -ge 1 && "$choice" -le "${#ids[@]}" ]] 2>/dev/null; then + echo "${ids[$((choice - 1))]}" + else + log_warn "Invalid choice, using default: kvm1" + echo "kvm1" + fi +} + +# Create a Hostinger VPS with cloud-init +create_server() { + local name="$1" + + # Interactive location + plan selection (skipped if env vars are set) + local location + location=$(_pick_location) + + local plan + plan=$(_pick_plan) + + local os_template="${HOSTINGER_OS_TEMPLATE:-ubuntu-24.04}" + + # Validate inputs to prevent injection into Python code + validate_resource_name "$plan" || { log_error "Invalid HOSTINGER_PLAN"; return 1; } + validate_region_name "$location" || { log_error "Invalid HOSTINGER_LOCATION"; return 1; } + + log_warn "Creating Hostinger VPS '$name' (plan: $plan, location: $location)..." + + # Get all SSH key IDs + local ssh_keys_response + ssh_keys_response=$(hostinger_api GET "/ssh-keys") + local ssh_key_ids + ssh_key_ids=$(extract_ssh_key_ids "$ssh_keys_response" "keys") + + # Build request body — pipe cloud-init userdata via stdin to avoid bash quoting issues + local userdata + userdata=$(get_cloud_init_userdata) + + local body + body=$(echo "$userdata" | python3 -c " +import json, sys +userdata = sys.stdin.read() +body = { + 'hostname': '$name', + 'plan': '$plan', + 'location': '$location', + 'os_template': '$os_template', + 'ssh_keys': $ssh_key_ids, + 'cloud_init': userdata, + 'start_after_create': True +} +print(json.dumps(body)) +") + + local response + response=$(hostinger_api POST "/virtual-machines" "$body") + + # Check for errors + if echo "$response" | grep -q '"error"\|"message".*fail'; then + log_error "Failed to create Hostinger VPS" + + # Parse error details + local error_msg + error_msg=$(echo "$response" | python3 -c "import json,sys; d=json.loads(sys.stdin.read()); print(d.get('message','') or d.get('error','Unknown error'))" 2>/dev/null || echo "$response") + log_error "API Error: $error_msg" + log_error "" + log_error "Common issues:" + log_error " - Insufficient account balance or payment method required" + log_error " - Plan/location unavailable (try different HOSTINGER_PLAN or HOSTINGER_LOCATION)" + log_error " - VPS limit reached for your account" + log_error " - Invalid cloud-init userdata" + log_error "" + log_error "Check your account status: https://hpanel.hostinger.com/" + return 1 + fi + + # Extract VPS ID and IP + HOSTINGER_VPS_ID=$(echo "$response" | python3 -c "import json,sys; print(json.loads(sys.stdin.read()).get('id',''))") + HOSTINGER_VPS_IP=$(echo "$response" | python3 -c "import json,sys; print(json.loads(sys.stdin.read()).get('ipv4',''))") + export HOSTINGER_VPS_ID HOSTINGER_VPS_IP + + log_info "VPS created: ID=$HOSTINGER_VPS_ID, IP=$HOSTINGER_VPS_IP" +} + +# Wait for SSH connectivity +verify_server_connectivity() { + local ip="$1" + local max_attempts=${2:-30} + # SSH_OPTS is defined in shared/common.sh + # shellcheck disable=SC2154 + generic_ssh_wait "root" "$ip" "$SSH_OPTS -o ConnectTimeout=5" "echo ok" "SSH connectivity" "$max_attempts" 5 +} + +# Run a command on the server +run_server() { + local ip="$1" + local cmd="$2" + # shellcheck disable=SC2086 + ssh $SSH_OPTS "root@$ip" "$cmd" +} + +# Upload a file to the server +upload_file() { + local ip="$1" + local local_path="$2" + local remote_path="$3" + # shellcheck disable=SC2086 + scp $SSH_OPTS "$local_path" "root@$ip:$remote_path" +} + +# Start an interactive SSH session +interactive_session() { + local ip="$1" + local cmd="$2" + # shellcheck disable=SC2086 + ssh -t $SSH_OPTS "root@$ip" "$cmd" +} + +# Destroy a Hostinger VPS +destroy_server() { + local vps_id="$1" + + log_warn "Destroying VPS $vps_id..." + local response + response=$(hostinger_api DELETE "/virtual-machines/$vps_id") + + if echo "$response" | grep -q '"error"\|"message".*fail'; then + log_error "Failed to destroy VPS: $response" + return 1 + fi + + log_info "VPS $vps_id destroyed" +} + +# List all Hostinger VPSs +list_servers() { + local response + response=$(hostinger_api GET "/virtual-machines") + + python3 -c " +import json, sys +data = json.loads(sys.stdin.read()) +vpss = data.get('virtual_machines', []) +if not vpss: + print('No VPS instances found') + sys.exit(0) +print(f\"{'NAME':<25} {'ID':<12} {'STATUS':<12} {'IP':<16} {'PLAN':<10}\") +print('-' * 75) +for v in vpss: + name = v.get('hostname', 'N/A') + vid = str(v.get('id', 'N/A')) + status = v.get('status', 'unknown') + ip = v.get('ipv4', 'N/A') + plan = v.get('plan', 'N/A') + print(f'{name:<25} {vid:<12} {status:<12} {ip:<16} {plan:<10}') +" <<< "$response" +} diff --git a/hostinger/openclaw.sh b/hostinger/openclaw.sh new file mode 100644 index 00000000..82628c1f --- /dev/null +++ b/hostinger/openclaw.sh @@ -0,0 +1,66 @@ +#!/bin/bash +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=hostinger/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/hostinger/lib/common.sh)" +fi + +log_info "OpenClaw on Hostinger VPS" +echo "" + +# 1. Resolve Hostinger API key +ensure_hostinger_token + +# 2. Generate + register SSH key +ensure_ssh_key + +# 3. Get server name and create server +SERVER_NAME=$(get_server_name) +create_server "${SERVER_NAME}" + +# 4. Wait for SSH and cloud-init +verify_server_connectivity "${HOSTINGER_VPS_IP}" +wait_for_cloud_init "${HOSTINGER_VPS_IP}" 60 + +# 5. Install openclaw via bun +log_warn "Installing openclaw..." +run_server "${HOSTINGER_VPS_IP}" "source ~/.bashrc && bun install -g openclaw" +log_info "OpenClaw 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 + +# Get model preference +MODEL_ID=$(get_model_id_interactive "openrouter/auto" "Openclaw") || exit 1 + +log_warn "Setting up environment variables..." +inject_env_vars_ssh "${HOSTINGER_VPS_IP}" upload_file run_server \ + "OPENROUTER_API_KEY=${OPENROUTER_API_KEY}" \ + "ANTHROPIC_API_KEY=${OPENROUTER_API_KEY}" \ + "ANTHROPIC_BASE_URL=https://openrouter.ai/api" + +# 9. Configure openclaw +setup_openclaw_config "${OPENROUTER_API_KEY}" "${MODEL_ID}" \ + "upload_file ${HOSTINGER_VPS_IP}" \ + "run_server ${HOSTINGER_VPS_IP}" + +echo "" +log_info "Hostinger VPS setup completed successfully!" +log_info "VPS: ${SERVER_NAME} (ID: ${HOSTINGER_VPS_ID}, IP: ${HOSTINGER_VPS_IP})" +echo "" + +# 10. Start openclaw gateway in background and launch TUI +log_warn "Starting openclaw..." +run_server "${HOSTINGER_VPS_IP}" "source ~/.zshrc && nohup openclaw gateway > /tmp/openclaw-gateway.log 2>&1 &" +sleep 2 +interactive_session "${HOSTINGER_VPS_IP}" "source ~/.zshrc && openclaw tui" diff --git a/manifest.json b/manifest.json index 29862dbc..f06e3aca 100644 --- a/manifest.json +++ b/manifest.json @@ -675,6 +675,22 @@ "image": "ubuntu-24.04" }, "notes": "Budget European VPS provider starting at $4.95/mo. Uses OAuth2 password grant (client credentials + user credentials). Requires 4 values from https://my.contabo.com/api/details: Client ID, Client Secret, API User, API Password." + }, + "hostinger": { + "name": "Hostinger", + "description": "Hostinger VPS hosting via REST API with cloud-init support", + "url": "https://www.hostinger.com/", + "type": "api", + "auth": "HOSTINGER_API_KEY", + "provision_method": "POST /vps/v1/virtual-machines with cloud_init", + "exec_method": "ssh root@IP", + "interactive_method": "ssh -t root@IP", + "defaults": { + "plan": "kvm1", + "location": "eu-central", + "os_template": "ubuntu-24.04" + }, + "notes": "Budget VPS provider with cloud-init pre-installed. Starting at $4.95/mo. Requires HOSTINGER_API_KEY from hPanel → Profile → Account Information → API. API docs at developers.hostinger.com" } }, "matrix": { @@ -1097,6 +1113,21 @@ "contabo/opencode": "missing", "contabo/plandex": "missing", "contabo/kilocode": "missing", - "contabo/continue": "missing" + "contabo/continue": "missing", + "hostinger/claude": "implemented", + "hostinger/openclaw": "implemented", + "hostinger/nanoclaw": "missing", + "hostinger/aider": "implemented", + "hostinger/goose": "missing", + "hostinger/codex": "missing", + "hostinger/interpreter": "missing", + "hostinger/gemini": "missing", + "hostinger/amazonq": "missing", + "hostinger/cline": "missing", + "hostinger/gptme": "missing", + "hostinger/opencode": "missing", + "hostinger/plandex": "missing", + "hostinger/kilocode": "missing", + "hostinger/continue": "missing" } } \ No newline at end of file