Files
internalai-setup/install.sh

146 lines
4.6 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
set -euo pipefail
# InternalAI Platform Installer
# Usage: bash <(curl -fsSL https://gitea.app.monadical.io/jose/internalai-setup/raw/branch/main/install.sh)
# ============================================================================
# Configuration
# ============================================================================
SETUP_URL="https://gitea.app.monadical.io/jose/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 "$@"