chore: add initial InternalAI platform installer setup
Add installer scripts and documentation for the InternalAI platform setup repository. This provides a streamlined installation process for the private InternalAI monorepo platform. + Add .gitignore with macOS, editor, and temporary file exclusions + Add comprehensive README.md with installation instructions, prerequisites, CLI commands, and troubleshooting guide + Add install.sh one-liner script that downloads and executes the main setup
This commit is contained in:
41
.gitignore
vendored
Normal file
41
.gitignore
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# macOS
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
.project
|
||||
.classpath
|
||||
.c9/
|
||||
*.launch
|
||||
.settings/
|
||||
*.sublime-workspace
|
||||
|
||||
# Temporary files
|
||||
*.tmp
|
||||
*.temp
|
||||
.cache/
|
||||
291
README.md
Normal file
291
README.md
Normal file
@@ -0,0 +1,291 @@
|
||||
# InternalAI Platform Setup
|
||||
|
||||
Official installer for the InternalAI Platform - a multi-service monorepo platform combining Python backends and TypeScript frontends for internal tools.
|
||||
|
||||
## Quick Start
|
||||
|
||||
Run this one-liner to install the InternalAI platform:
|
||||
|
||||
```bash
|
||||
bash <(curl -fsSL https://gitea.app.monadical.io/monadical/internalai-setup/raw/branch/main/install.sh)
|
||||
```
|
||||
|
||||
This will:
|
||||
1. Check system dependencies
|
||||
2. Prompt for Gitea authentication
|
||||
3. Clone the InternalAI platform repository
|
||||
4. Install the `internalai` command-line tool
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Before installing, ensure you have:
|
||||
|
||||
- **Git** - Version control system
|
||||
- **Docker** - Container runtime (v20.10+)
|
||||
- **Docker Compose** - Container orchestration (v2.0+)
|
||||
- **Just** - Command runner (will auto-install if missing)
|
||||
|
||||
### Platform Requirements
|
||||
|
||||
- **macOS** 10.15+ or **Linux** (Ubuntu 20.04+, Debian 11+, etc.)
|
||||
- **4GB RAM** minimum (8GB+ recommended)
|
||||
- **10GB disk space** for platform and data
|
||||
- **Ports available**: 42000 (or custom port)
|
||||
|
||||
## Authentication
|
||||
|
||||
The InternalAI platform repository is private. You'll need one of:
|
||||
|
||||
### Option 1: Personal Access Token (Recommended)
|
||||
|
||||
1. Go to [Gitea Token Settings](https://gitea.app.monadical.io/user/settings/applications)
|
||||
2. Click "Generate New Token"
|
||||
3. Give it a name (e.g., "InternalAI Setup")
|
||||
4. Select the `repo` scope
|
||||
5. Click "Generate Token" and copy it
|
||||
6. Enter the token when prompted by the installer
|
||||
|
||||
### Option 2: SSH Key
|
||||
|
||||
1. Generate an SSH key if you don't have one:
|
||||
```bash
|
||||
ssh-keygen -t ed25519 -C "your.email@monadical.com"
|
||||
```
|
||||
|
||||
2. Add your SSH key to [Gitea SSH Settings](https://gitea.app.monadical.io/user/settings/keys)
|
||||
|
||||
3. Select SSH authentication when prompted by the installer
|
||||
|
||||
## Installation Steps
|
||||
|
||||
### 1. Run the Installer
|
||||
|
||||
```bash
|
||||
bash <(curl -fsSL https://gitea.app.monadical.io/monadical/internalai-setup/raw/branch/main/install.sh)
|
||||
```
|
||||
|
||||
### 2. Follow the Prompts
|
||||
|
||||
The installer will guide you through:
|
||||
- Dependency checking
|
||||
- Authentication setup
|
||||
- Repository cloning
|
||||
- CLI installation
|
||||
|
||||
### 3. Configure the Platform
|
||||
|
||||
After installation, run:
|
||||
|
||||
```bash
|
||||
internalai install
|
||||
```
|
||||
|
||||
This will:
|
||||
- Set up environment configuration
|
||||
- Configure API keys (Hunter.io, Apollo.io, LLM)
|
||||
- Set up Caddy reverse proxy with authentication
|
||||
- Optionally configure HTTPS with a custom domain
|
||||
- Create data directories
|
||||
- Build and start all services
|
||||
|
||||
### 4. Verify Installation
|
||||
|
||||
Check the platform status:
|
||||
|
||||
```bash
|
||||
internalai status
|
||||
```
|
||||
|
||||
## Default Installation Location
|
||||
|
||||
The platform installs to: `$HOME/internalai`
|
||||
|
||||
You can change this during setup or set the `PLATFORM_ROOT` environment variable.
|
||||
|
||||
## CLI Commands
|
||||
|
||||
After installation, use these commands:
|
||||
|
||||
```bash
|
||||
internalai install # Full platform setup
|
||||
internalai start # Start all services
|
||||
internalai stop # Stop all services
|
||||
internalai restart # Restart services
|
||||
internalai status # Show service status
|
||||
internalai logs [svc] # View logs
|
||||
internalai upgrade # Upgrade platform
|
||||
internalai caddy # Manage Caddy proxy
|
||||
internalai help # Show all commands
|
||||
```
|
||||
|
||||
## Services
|
||||
|
||||
The platform includes:
|
||||
|
||||
- **ContactDB** - Unified contact management with relationship tracking
|
||||
- **DataIndex** - Data aggregation and semantic search engine
|
||||
- **Meeting Prep** - AI-powered meeting preparation assistant
|
||||
- **Caddy** - Reverse proxy with authentication
|
||||
|
||||
## Accessing the Platform
|
||||
|
||||
Once started, access services at:
|
||||
|
||||
- **Dashboard**: http://localhost:42000 (or your configured URL)
|
||||
- **ContactDB**: http://localhost:42000/contactdb/
|
||||
- **DataIndex**: http://localhost:42000/dataindex/
|
||||
- **Meeting Prep**: http://localhost:42000/meeting-prep/
|
||||
|
||||
Default credentials (if authentication is enabled):
|
||||
- **Username**: `admin`
|
||||
- **Password**: Generated during setup (saved in cache)
|
||||
|
||||
## Configuration
|
||||
|
||||
### Environment Variables
|
||||
|
||||
Configuration is stored in `$HOME/internalai/.env`
|
||||
|
||||
Key variables:
|
||||
- `PLATFORM_BASE_URL` - Base URL for the platform
|
||||
- `CONTACTDB_SELF_EMAIL` - Your email for contact management
|
||||
- `SHARED_HUNTER_API_KEY` - Hunter.io API key
|
||||
- `SHARED_APOLLO_API_KEY` - Apollo.io API key
|
||||
- `SHARED_LLM_API_KEY` - LLM API key
|
||||
|
||||
### Credential Cache
|
||||
|
||||
Credentials are cached in `$HOME/internalai/.credentials.cache`
|
||||
|
||||
You can optionally encrypt this cache with AES-256-CBC during installation.
|
||||
|
||||
View or edit the cache:
|
||||
```bash
|
||||
internalai cache show
|
||||
internalai cache edit
|
||||
```
|
||||
|
||||
## Updating the CLI
|
||||
|
||||
To update the CLI tool to the latest version:
|
||||
|
||||
```bash
|
||||
internalai update
|
||||
```
|
||||
|
||||
This will re-download and reinstall the CLI from the latest version in the repository.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Dependencies Not Found
|
||||
|
||||
If the installer can't find Docker, Just, or other dependencies:
|
||||
|
||||
**macOS:**
|
||||
```bash
|
||||
brew install docker just
|
||||
```
|
||||
|
||||
**Linux:**
|
||||
```bash
|
||||
# Docker (Ubuntu/Debian)
|
||||
curl -fsSL https://get.docker.com | sh
|
||||
|
||||
# Just
|
||||
cargo install just # Or download from releases
|
||||
```
|
||||
|
||||
### Authentication Failed
|
||||
|
||||
If git clone fails with authentication error:
|
||||
|
||||
1. **For Token auth**: Verify your token has `repo` scope
|
||||
2. **For SSH auth**: Test connection with `ssh -T git@gitea.app.monadical.io`
|
||||
3. Check you're a member of the Monadical organization on Gitea
|
||||
|
||||
### Port Already in Use
|
||||
|
||||
If port 42000 is already in use, you can change it:
|
||||
|
||||
1. Edit `$HOME/internalai/.env`
|
||||
2. Change `PLATFORM_BASE_URL=http://localhost:YOURPORT`
|
||||
3. Restart: `internalai restart`
|
||||
|
||||
### Services Won't Start
|
||||
|
||||
Check logs for specific services:
|
||||
```bash
|
||||
internalai logs contactdb
|
||||
internalai logs dataindex
|
||||
```
|
||||
|
||||
Common issues:
|
||||
- Docker not running: `docker info` should work
|
||||
- Port conflicts: Check with `lsof -i :42000`
|
||||
- Permission issues: Ensure Docker doesn't require sudo
|
||||
|
||||
## Manual Installation
|
||||
|
||||
If the automated installer doesn't work, you can install manually:
|
||||
|
||||
1. Clone the repository:
|
||||
```bash
|
||||
git clone git@gitea.app.monadical.io:monadical/internalai.git ~/internalai
|
||||
cd ~/internalai
|
||||
```
|
||||
|
||||
2. Install the CLI:
|
||||
```bash
|
||||
./scripts/install.sh
|
||||
```
|
||||
|
||||
3. Configure the platform:
|
||||
```bash
|
||||
internalai install
|
||||
```
|
||||
|
||||
## Uninstallation
|
||||
|
||||
To remove the InternalAI platform:
|
||||
|
||||
```bash
|
||||
cd ~/internalai
|
||||
just down # Stop services
|
||||
cd ~
|
||||
rm -rf ~/internalai # Remove platform files
|
||||
sudo rm /usr/local/bin/internalai # Remove CLI
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
### Repository Structure
|
||||
|
||||
```
|
||||
internalai-setup/
|
||||
├── install.sh # One-liner installer
|
||||
├── setup.sh # Main setup script
|
||||
└── README.md # This file
|
||||
```
|
||||
|
||||
The actual platform code is in the private `internalai` repository.
|
||||
|
||||
### Contributing
|
||||
|
||||
To contribute to the installer:
|
||||
|
||||
1. Fork the `internalai-setup` repository
|
||||
2. Make your changes
|
||||
3. Test thoroughly
|
||||
4. Submit a pull request
|
||||
|
||||
## Support
|
||||
|
||||
For issues or questions:
|
||||
|
||||
- **Platform Issues**: Check `~/internalai/docs/`
|
||||
- **CLI Issues**: Run `internalai help`
|
||||
- **Setup Issues**: Create an issue in this repository
|
||||
|
||||
## License
|
||||
|
||||
Copyright © 2024 Monadical SAS. All rights reserved.
|
||||
145
install.sh
Executable file
145
install.sh
Executable file
@@ -0,0 +1,145 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# InternalAI Platform Installer
|
||||
# Usage: bash <(curl -fsSL https://gitea.app.monadical.io/monadical/internalai-setup/raw/branch/main/install.sh)
|
||||
|
||||
# ============================================================================
|
||||
# Configuration
|
||||
# ============================================================================
|
||||
|
||||
SETUP_URL="https://gitea.app.monadical.io/monadical/internalai-setup/raw/branch/main/setup.sh"
|
||||
INSTALLER_VERSION="1.0.0"
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
# ============================================================================
|
||||
# Logging Functions
|
||||
# ============================================================================
|
||||
|
||||
log_info() {
|
||||
echo -e "${BLUE}ℹ${NC} $1"
|
||||
}
|
||||
|
||||
log_success() {
|
||||
echo -e "${GREEN}✓${NC} $1"
|
||||
}
|
||||
|
||||
log_warning() {
|
||||
echo -e "${YELLOW}⚠${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}✗${NC} $1"
|
||||
}
|
||||
|
||||
log_header() {
|
||||
echo ""
|
||||
echo -e "${BLUE}═══════════════════════════════════════════════════════════${NC}"
|
||||
echo -e "${BLUE} $1${NC}"
|
||||
echo -e "${BLUE}═══════════════════════════════════════════════════════════${NC}"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Installer Functions
|
||||
# ============================================================================
|
||||
|
||||
check_requirements() {
|
||||
log_header "Checking Requirements"
|
||||
|
||||
# Check curl
|
||||
if command -v curl &> /dev/null; then
|
||||
log_success "curl is installed"
|
||||
else
|
||||
log_error "curl is required but not installed"
|
||||
log_info "Install curl and try again:"
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
log_info " brew install curl"
|
||||
else
|
||||
log_info " sudo apt-get install curl # Debian/Ubuntu"
|
||||
log_info " sudo yum install curl # RHEL/CentOS"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check bash version
|
||||
if [ "${BASH_VERSINFO[0]}" -lt 4 ]; then
|
||||
log_warning "Bash version ${BASH_VERSION} detected. Version 4+ recommended."
|
||||
else
|
||||
log_success "bash ${BASH_VERSION} is installed"
|
||||
fi
|
||||
}
|
||||
|
||||
download_and_run_setup() {
|
||||
log_header "Downloading Setup Script"
|
||||
|
||||
# Create temporary file
|
||||
TMP_FILE=$(mktemp)
|
||||
trap "rm -f $TMP_FILE" EXIT
|
||||
|
||||
log_info "Downloading setup script from:"
|
||||
log_info " $SETUP_URL"
|
||||
echo ""
|
||||
|
||||
# Download the script
|
||||
if ! curl -fsSL "$SETUP_URL" -o "$TMP_FILE"; then
|
||||
log_error "Failed to download setup script"
|
||||
log_info "Please check:"
|
||||
log_info " • Your internet connection"
|
||||
log_info " • The repository URL is correct"
|
||||
log_info " • You have access to the repository"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verify it's a valid bash script
|
||||
if ! head -n 1 "$TMP_FILE" | grep -q "^#!/"; then
|
||||
log_error "Downloaded file does not appear to be a valid script"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_success "Setup script downloaded successfully"
|
||||
|
||||
# Run the setup script
|
||||
log_header "Running Setup"
|
||||
echo ""
|
||||
|
||||
chmod +x "$TMP_FILE"
|
||||
bash "$TMP_FILE" "$@"
|
||||
}
|
||||
|
||||
show_welcome() {
|
||||
clear
|
||||
echo ""
|
||||
echo -e "${BLUE}╔══════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${BLUE}║ ║${NC}"
|
||||
echo -e "${BLUE}║ ${GREEN}InternalAI Platform Installer${BLUE} ║${NC}"
|
||||
echo -e "${BLUE}║ ║${NC}"
|
||||
echo -e "${BLUE}║ Version ${INSTALLER_VERSION} ║${NC}"
|
||||
echo -e "${BLUE}║ ║${NC}"
|
||||
echo -e "${BLUE}╚══════════════════════════════════════════════════════╝${NC}"
|
||||
echo ""
|
||||
log_info "This installer will:"
|
||||
echo " • Check system dependencies"
|
||||
echo " • Set up Gitea authentication"
|
||||
echo " • Clone the InternalAI platform repository"
|
||||
echo " • Install the 'internalai' command-line tool"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Main Installation Flow
|
||||
# ============================================================================
|
||||
|
||||
main() {
|
||||
show_welcome
|
||||
check_requirements
|
||||
download_and_run_setup "$@"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
440
setup.sh
Executable file
440
setup.sh
Executable file
@@ -0,0 +1,440 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# InternalAI Platform Setup Script
|
||||
# This script handles authentication and clones the private internalai monorepo
|
||||
|
||||
# ============================================================================
|
||||
# Configuration
|
||||
# ============================================================================
|
||||
|
||||
PLATFORM_NAME="InternalAI Platform"
|
||||
DEFAULT_INSTALL_DIR="$HOME/internalai"
|
||||
REPO_URL="https://gitea.app.monadical.io/monadical/internalai.git"
|
||||
REPO_SSH="git@gitea.app.monadical.io:monadical/internalai.git"
|
||||
CLI_INSTALL_DIR="/usr/local/bin"
|
||||
CLI_NAME="internalai"
|
||||
VERSION="1.0.0"
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
CYAN='\033[0;36m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m'
|
||||
|
||||
# ============================================================================
|
||||
# Logging Functions
|
||||
# ============================================================================
|
||||
|
||||
log_info() {
|
||||
echo -e "${BLUE}ℹ${NC} $1"
|
||||
}
|
||||
|
||||
log_success() {
|
||||
echo -e "${GREEN}✓${NC} $1"
|
||||
}
|
||||
|
||||
log_warning() {
|
||||
echo -e "${YELLOW}⚠${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}✗${NC} $1"
|
||||
}
|
||||
|
||||
log_header() {
|
||||
echo ""
|
||||
echo -e "${CYAN}═══════════════════════════════════════════════════════════${NC}"
|
||||
echo -e "${CYAN} $1${NC}"
|
||||
echo -e "${CYAN}═══════════════════════════════════════════════════════════${NC}"
|
||||
echo ""
|
||||
}
|
||||
|
||||
print_banner() {
|
||||
clear
|
||||
echo -e "${BOLD}${CYAN}"
|
||||
cat << 'EOF'
|
||||
╔═════════════════════════════════════════════════════════════════════════════════════════╗
|
||||
║ ║
|
||||
║ ██╗███╗ ██╗████████╗███████╗██████╗ ███╗ ██╗ █████╗ ██╗ █████╗ ██╗ ║
|
||||
║ ██║████╗ ██║╚══██╔══╝██╔════╝██╔══██╗████╗ ██║██╔══██╗██║ ██╔══██╗██║ ║
|
||||
║ ██║██╔██╗ ██║ ██║ █████╗ ██████╔╝██╔██╗ ██║███████║██║ ███████║██║ ║
|
||||
║ ██║██║╚██╗██║ ██║ ██╔══╝ ██╔══██╗██║╚██╗██║██╔══██║██║ ██╔══██║██║ ║
|
||||
║ ██║██║ ╚████║ ██║ ███████╗██║ ██║██║ ╚████║██║ ██║███████╗ ██║ ██║██║ ║
|
||||
║ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝╚═╝ ║
|
||||
║ ║
|
||||
║ Platform Setup v${VERSION} ║
|
||||
╚═════════════════════════════════════════════════════════════════════════════════════════╝
|
||||
EOF
|
||||
echo -e "${NC}"
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Utility Functions
|
||||
# ============================================================================
|
||||
|
||||
prompt() {
|
||||
local varname=$1
|
||||
local prompt_text=$2
|
||||
local default_value=$3
|
||||
local is_secret=${4:-false}
|
||||
|
||||
if [ -n "$default_value" ]; then
|
||||
prompt_text="$prompt_text [${default_value}]"
|
||||
fi
|
||||
|
||||
if [ "$is_secret" = true ]; then
|
||||
echo -ne "${YELLOW}${prompt_text}: ${NC}"
|
||||
value=""
|
||||
while IFS= read -r -s -n1 char; do
|
||||
if [[ $char == $'\0' ]]; then
|
||||
break
|
||||
fi
|
||||
if [[ $char == $'\177' ]] || [[ $char == $'\b' ]]; then
|
||||
if [ ${#value} -gt 0 ]; then
|
||||
value="${value%?}"
|
||||
echo -ne "\b \b"
|
||||
fi
|
||||
else
|
||||
value+="$char"
|
||||
echo -n "*"
|
||||
fi
|
||||
done
|
||||
echo ""
|
||||
else
|
||||
read -p "$(echo -e ${YELLOW}${prompt_text}: ${NC})" value
|
||||
fi
|
||||
|
||||
if [ -z "$value" ] && [ -n "$default_value" ]; then
|
||||
value="$default_value"
|
||||
fi
|
||||
|
||||
eval "$varname='$value'"
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Dependency Checking
|
||||
# ============================================================================
|
||||
|
||||
check_dependencies() {
|
||||
log_header "Checking Dependencies"
|
||||
|
||||
local deps_ok=true
|
||||
|
||||
# Check Git
|
||||
if command -v git &> /dev/null; then
|
||||
log_success "git installed ($(git --version | head -n1))"
|
||||
else
|
||||
log_error "git is not installed"
|
||||
deps_ok=false
|
||||
fi
|
||||
|
||||
# Check Docker
|
||||
if command -v docker &> /dev/null; then
|
||||
log_success "docker installed ($(docker --version | head -n1))"
|
||||
else
|
||||
log_error "docker is not installed"
|
||||
deps_ok=false
|
||||
fi
|
||||
|
||||
# Check Docker Compose
|
||||
if docker compose version &> /dev/null 2>&1; then
|
||||
log_success "docker compose installed ($(docker compose version | head -n1))"
|
||||
elif command -v docker-compose &> /dev/null; then
|
||||
log_success "docker-compose installed ($(docker-compose --version | head -n1))"
|
||||
else
|
||||
log_error "docker compose is not installed"
|
||||
deps_ok=false
|
||||
fi
|
||||
|
||||
# Check Just
|
||||
if command -v just &> /dev/null; then
|
||||
log_success "just installed ($(just --version | head -n1))"
|
||||
else
|
||||
log_warning "just is not installed (will attempt to install)"
|
||||
install_just
|
||||
fi
|
||||
|
||||
if [ "$deps_ok" = false ]; then
|
||||
log_error "Please install missing dependencies and try again"
|
||||
echo ""
|
||||
log_info "Installation guides:"
|
||||
log_info " • Git: https://git-scm.com/downloads"
|
||||
log_info " • Docker: https://docs.docker.com/get-docker/"
|
||||
log_info " • Just: https://github.com/casey/just#installation"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_just() {
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
if command -v brew &> /dev/null; then
|
||||
log_info "Installing just via Homebrew..."
|
||||
brew install just
|
||||
log_success "just installed"
|
||||
else
|
||||
log_error "Homebrew not found. Please install just manually: https://github.com/casey/just#installation"
|
||||
exit 1
|
||||
fi
|
||||
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
if command -v cargo &> /dev/null; then
|
||||
log_info "Installing just via cargo..."
|
||||
cargo install just
|
||||
log_success "just installed"
|
||||
else
|
||||
log_error "Cargo not found. Please install Rust or just manually: https://github.com/casey/just#installation"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
log_error "Unsupported OS. Please install just manually: https://github.com/casey/just#installation"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Gitea Authentication
|
||||
# ============================================================================
|
||||
|
||||
AUTH_TYPE=""
|
||||
GITEA_TOKEN=""
|
||||
|
||||
setup_gitea_auth() {
|
||||
log_header "Gitea Authentication"
|
||||
|
||||
log_info "The InternalAI platform repository is private and requires authentication."
|
||||
echo ""
|
||||
log_info "Choose authentication method:"
|
||||
echo " 1) Personal Access Token (recommended)"
|
||||
echo " 2) SSH Key (if already configured)"
|
||||
echo ""
|
||||
|
||||
prompt AUTH_CHOICE "Select authentication method" "1"
|
||||
|
||||
case "$AUTH_CHOICE" in
|
||||
1)
|
||||
AUTH_TYPE="token"
|
||||
echo ""
|
||||
log_info "To create a personal access token:"
|
||||
log_info " 1. Go to: https://gitea.app.monadical.io/user/settings/applications"
|
||||
log_info " 2. Click 'Generate New Token'"
|
||||
log_info " 3. Give it a name (e.g., 'InternalAI Setup')"
|
||||
log_info " 4. Give it Read repository scope"
|
||||
log_info " 5. Click 'Generate Token' and copy it"
|
||||
echo ""
|
||||
prompt GITEA_TOKEN "Enter your Gitea Personal Access Token" "" true
|
||||
|
||||
if [ -z "$GITEA_TOKEN" ]; then
|
||||
log_error "Token is required"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
2)
|
||||
AUTH_TYPE="ssh"
|
||||
log_info "Using SSH authentication"
|
||||
log_info "Ensure your SSH key is added to Gitea:"
|
||||
log_info " https://gitea.app.monadical.io/user/settings/keys"
|
||||
|
||||
# Test SSH connection
|
||||
echo ""
|
||||
log_info "Testing SSH connection..."
|
||||
if ssh -T git@gitea.app.monadical.io 2>&1 | grep -q "Hi there"; then
|
||||
log_success "SSH connection successful"
|
||||
else
|
||||
log_warning "Could not verify SSH connection, but will try to continue..."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
log_error "Invalid choice"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
prepare_git_url() {
|
||||
if [ "$AUTH_TYPE" = "token" ] && [ -n "$GITEA_TOKEN" ]; then
|
||||
echo "$REPO_URL" | sed "s|https://gitea.app.monadical.io/|https://${GITEA_TOKEN}@gitea.app.monadical.io/|"
|
||||
elif [ "$AUTH_TYPE" = "ssh" ]; then
|
||||
echo "$REPO_SSH"
|
||||
else
|
||||
echo "$REPO_URL"
|
||||
fi
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Git Credential Caching
|
||||
# ============================================================================
|
||||
|
||||
configure_git_credentials() {
|
||||
log_header "Configuring Git Credentials"
|
||||
|
||||
if [ "$AUTH_TYPE" = "ssh" ]; then
|
||||
log_info "Using SSH - no credential caching needed"
|
||||
return
|
||||
fi
|
||||
|
||||
# Detect OS and configure appropriate credential helper
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# macOS - use keychain
|
||||
log_info "Configuring git to use macOS Keychain..."
|
||||
git config --global credential.helper osxkeychain
|
||||
log_success "Git credentials will be stored in macOS Keychain"
|
||||
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
# Linux - try to use libsecret, fall back to cache
|
||||
if command -v git-credential-libsecret &> /dev/null; then
|
||||
log_info "Configuring git to use libsecret..."
|
||||
git config --global credential.helper libsecret
|
||||
log_success "Git credentials will be stored in system keyring"
|
||||
else
|
||||
log_info "Configuring git credential cache (1 hour)..."
|
||||
git config --global credential.helper 'cache --timeout=3600'
|
||||
log_success "Git credentials will be cached in memory for 1 hour"
|
||||
log_info "For persistent storage, install: libsecret"
|
||||
fi
|
||||
else
|
||||
# Unknown OS - use cache
|
||||
log_info "Configuring git credential cache (1 hour)..."
|
||||
git config --global credential.helper 'cache --timeout=3600'
|
||||
log_success "Git credentials will be cached in memory for 1 hour"
|
||||
fi
|
||||
|
||||
# Store credentials by triggering a git operation
|
||||
if [ "$AUTH_TYPE" = "token" ] && [ -n "$INSTALL_DIR" ] && [ -d "$INSTALL_DIR/.git" ]; then
|
||||
log_info "Caching credentials..."
|
||||
cd "$INSTALL_DIR"
|
||||
# Trigger credential storage by doing a fetch (which uses credentials)
|
||||
git fetch --dry-run 2>&1 | grep -v "password\|token" > /dev/null || true
|
||||
log_success "Credentials cached successfully"
|
||||
fi
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Repository Cloning
|
||||
# ============================================================================
|
||||
|
||||
clone_repository() {
|
||||
log_header "Cloning Repository"
|
||||
|
||||
prompt INSTALL_DIR "Installation directory" "$DEFAULT_INSTALL_DIR"
|
||||
|
||||
if [ -d "$INSTALL_DIR" ]; then
|
||||
if [ -d "$INSTALL_DIR/.git" ]; then
|
||||
log_warning "Directory already exists and appears to be a git repository"
|
||||
prompt UPDATE_CHOICE "Update existing repository? (y/n)" "y"
|
||||
if [[ "$UPDATE_CHOICE" =~ ^[Yy] ]]; then
|
||||
log_info "Pulling latest changes..."
|
||||
cd "$INSTALL_DIR"
|
||||
git pull
|
||||
log_success "Repository updated"
|
||||
return
|
||||
else
|
||||
log_info "Using existing repository"
|
||||
return
|
||||
fi
|
||||
else
|
||||
log_error "Directory exists but is not a git repository"
|
||||
log_info "Please remove or rename: $INSTALL_DIR"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
local git_url=$(prepare_git_url)
|
||||
|
||||
log_info "Cloning repository to: $INSTALL_DIR"
|
||||
log_info "This may take a few minutes..."
|
||||
|
||||
if git clone "$git_url" "$INSTALL_DIR" 2>&1 | grep -v "password\|token"; then
|
||||
log_success "Repository cloned successfully"
|
||||
else
|
||||
log_error "Failed to clone repository"
|
||||
log_info "Please check your credentials and try again"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# CLI Installation
|
||||
# ============================================================================
|
||||
|
||||
install_cli() {
|
||||
log_header "Installing CLI Tool"
|
||||
|
||||
local cli_script="$INSTALL_DIR/scripts/$CLI_NAME"
|
||||
|
||||
if [ ! -f "$cli_script" ]; then
|
||||
log_error "CLI script not found at: $cli_script"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "Installing $CLI_NAME to $CLI_INSTALL_DIR..."
|
||||
|
||||
if [ -w "$CLI_INSTALL_DIR" ]; then
|
||||
cp "$cli_script" "$CLI_INSTALL_DIR/$CLI_NAME"
|
||||
chmod +x "$CLI_INSTALL_DIR/$CLI_NAME"
|
||||
else
|
||||
log_warning "Need sudo permissions to write to $CLI_INSTALL_DIR"
|
||||
sudo cp "$cli_script" "$CLI_INSTALL_DIR/$CLI_NAME"
|
||||
sudo chmod +x "$CLI_INSTALL_DIR/$CLI_NAME"
|
||||
fi
|
||||
|
||||
if command -v "$CLI_NAME" &> /dev/null; then
|
||||
log_success "$CLI_NAME installed successfully!"
|
||||
else
|
||||
log_warning "$CLI_NAME installed but not found in PATH"
|
||||
log_info "You may need to restart your terminal or run:"
|
||||
log_info " export PATH=\"$CLI_INSTALL_DIR:\$PATH\""
|
||||
fi
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Post-Installation
|
||||
# ============================================================================
|
||||
|
||||
show_next_steps() {
|
||||
log_header "Installation Complete!"
|
||||
|
||||
echo -e "${GREEN}${BOLD}The InternalAI platform has been set up successfully!${NC}"
|
||||
echo ""
|
||||
echo -e "${BOLD}Platform Location:${NC} ${CYAN}$INSTALL_DIR${NC}"
|
||||
echo ""
|
||||
echo -e "${BOLD}Next Steps:${NC}"
|
||||
echo ""
|
||||
echo " 1. Configure and start the platform:"
|
||||
echo -e " ${GREEN}$CLI_NAME install${NC}"
|
||||
echo ""
|
||||
echo " 2. View available commands:"
|
||||
echo -e " ${GREEN}$CLI_NAME help${NC}"
|
||||
echo ""
|
||||
echo " 3. Check platform status:"
|
||||
echo -e " ${GREEN}$CLI_NAME status${NC}"
|
||||
echo ""
|
||||
echo -e "${BOLD}Documentation:${NC}"
|
||||
echo " • Platform docs: $INSTALL_DIR/docs/"
|
||||
echo " • README: $INSTALL_DIR/README.md"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Main Installation Flow
|
||||
# ============================================================================
|
||||
|
||||
main() {
|
||||
print_banner
|
||||
|
||||
log_info "Starting InternalAI Platform setup..."
|
||||
echo ""
|
||||
|
||||
check_dependencies
|
||||
setup_gitea_auth
|
||||
clone_repository
|
||||
configure_git_credentials
|
||||
install_cli
|
||||
show_next_steps
|
||||
|
||||
echo -e "${GREEN}${BOLD}Setup completed successfully!${NC}"
|
||||
echo ""
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user