148 lines
4.6 KiB
Bash
Executable File
148 lines
4.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# Installation script for Claude Code Router
|
|
# Makes scripts executable and prepares the system
|
|
|
|
set -euo pipefail
|
|
|
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
# Colors
|
|
readonly GREEN='\033[0;32m'
|
|
readonly YELLOW='\033[1;33m'
|
|
readonly RED='\033[0;31m'
|
|
readonly NC='\033[0m'
|
|
|
|
# Logging
|
|
log_info() { echo -e "${GREEN}==>${NC} $*"; }
|
|
log_warn() { echo -e "${YELLOW}[WARN]${NC} $*" >&2; }
|
|
log_error() { echo -e "${RED}[ERR]${NC} $*" >&2; }
|
|
|
|
# Check required files
|
|
check_files() {
|
|
local required_files=(
|
|
"run-claude-openrouter.sh"
|
|
"config-manager.sh"
|
|
"ccr-config.sh"
|
|
"com.musistudio.ccr.plist"
|
|
)
|
|
|
|
log_info "Checking required files..."
|
|
|
|
for file in "${required_files[@]}"; do
|
|
if [[ ! -f "${SCRIPT_DIR}/${file}" ]]; then
|
|
log_error "Missing required file: ${file}"
|
|
return 1
|
|
fi
|
|
log_info "✓ Found: ${file}"
|
|
done
|
|
}
|
|
|
|
# Make scripts executable
|
|
make_executable() {
|
|
log_info "Making scripts executable..."
|
|
|
|
chmod +x "${SCRIPT_DIR}/run-claude-openrouter.sh"
|
|
chmod +x "${SCRIPT_DIR}/config-manager.sh"
|
|
chmod +x "${SCRIPT_DIR}/ccr-config.sh"
|
|
|
|
log_info "✓ Scripts are executable"
|
|
}
|
|
|
|
# Verify system requirements
|
|
check_requirements() {
|
|
log_info "Checking system requirements..."
|
|
|
|
# Check for bash
|
|
if ! command -v bash &> /dev/null; then
|
|
log_error "bash not found"
|
|
return 1
|
|
fi
|
|
log_info "✓ bash found"
|
|
|
|
# Check for curl
|
|
if ! command -v curl &> /dev/null; then
|
|
log_error "curl not found"
|
|
return 1
|
|
fi
|
|
log_info "✓ curl found"
|
|
|
|
# Check for Node.js/npm
|
|
if ! command -v npm &> /dev/null; then
|
|
log_warn "npm not found - will be installed on first run"
|
|
else
|
|
log_info "✓ npm found"
|
|
fi
|
|
}
|
|
|
|
# Show next steps
|
|
show_next_steps() {
|
|
cat << EOF
|
|
|
|
╔════════════════════════════════════════════════════════════════╗
|
|
║ Claude Code Router - Installation Complete! ║
|
|
╚════════════════════════════════════════════════════════════════╝
|
|
|
|
Next Steps:
|
|
───────────────────────────────────────────────────────────────
|
|
|
|
1️⃣ Get your OpenRouter API key (if you don't have one):
|
|
https://openrouter.ai
|
|
|
|
2️⃣ Run the setup command:
|
|
|
|
export OPENROUTER_API_KEY='sk-or-v1-your-key-here'
|
|
cd "${SCRIPT_DIR}"
|
|
./run-claude-openrouter.sh --setup
|
|
|
|
3️⃣ Start coding:
|
|
|
|
./run-claude-openrouter.sh --code
|
|
|
|
📚 Documentation:
|
|
───────────────────────────────────────────────────────────────
|
|
• QUICKSTART.md → 5-minute setup guide (start here!)
|
|
• SETUP.md → Comprehensive documentation
|
|
• README.md → Complete reference
|
|
|
|
🆘 Troubleshooting:
|
|
───────────────────────────────────────────────────────────────
|
|
./run-claude-openrouter.sh --help Show all commands
|
|
./run-claude-openrouter.sh --status Check status
|
|
./run-claude-openrouter.sh --validate Validate config
|
|
./ccr-config.sh help Configuration help
|
|
|
|
✨ Key Features:
|
|
───────────────────────────────────────────────────────────────
|
|
✓ Automatic system startup on reboot
|
|
✓ Secure API key storage
|
|
✓ Single instance guarantee
|
|
✓ Built-in health checks
|
|
✓ Real-time log viewing
|
|
|
|
EOF
|
|
}
|
|
|
|
# Main
|
|
main() {
|
|
echo ""
|
|
echo "╔════════════════════════════════════════════════════════════════╗"
|
|
echo "║ Claude Code Router - Installation Script ║"
|
|
echo "╚════════════════════════════════════════════════════════════════╝"
|
|
echo ""
|
|
|
|
# Run checks
|
|
check_files || exit 1
|
|
echo ""
|
|
|
|
check_requirements || exit 1
|
|
echo ""
|
|
|
|
make_executable || exit 1
|
|
echo ""
|
|
|
|
# Show next steps
|
|
show_next_steps
|
|
}
|
|
|
|
main "$@"
|