#!/bin/bash set -e # Remotifex Install Script # Usage: curl -fsSL https://get.remotifex.com | sh REMOTIFEX_DIR="${REMOTIFEX_DIR:-/opt/remotifex}" REPO_URL="https://github.com/remotifex/remotifex.git" echo "" echo " ╔══════════════════════════════════════╗" echo " ║ Remotifex Installer ║" echo " ║ AI-Powered Development Platform ║" echo " ╚══════════════════════════════════════╝" echo "" # Check for required tools check_requirements() { local missing=() if ! command -v docker &> /dev/null; then missing+=("docker") fi if ! command -v docker compose &> /dev/null && ! command -v docker-compose &> /dev/null; then missing+=("docker-compose") fi if ! command -v git &> /dev/null; then missing+=("git") fi if [ ${#missing[@]} -gt 0 ]; then echo "Missing required tools: ${missing[*]}" echo "" echo "Please install them first:" echo " Docker: https://docs.docker.com/engine/install/" echo " Git: sudo apt-get install git" exit 1 fi echo "[OK] All requirements met" } # Generate random secret generate_secret() { openssl rand -base64 32 2>/dev/null || head -c 32 /dev/urandom | base64 } # Detect public IP detect_ip() { # Try external service local ip ip=$(curl -s --max-time 5 https://api.ipify.org 2>/dev/null) && echo "$ip" && return # Fallback: hostname -based ip=$(hostname -I 2>/dev/null | awk '{print $1}') && [ -n "$ip" ] && echo "$ip" && return echo "localhost" } # Clone or update repository setup_repo() { if [ -d "$REMOTIFEX_DIR" ]; then echo "[..] Updating existing installation..." cd "$REMOTIFEX_DIR" git pull --ff-only else echo "[..] Cloning Remotifex..." git clone "$REPO_URL" "$REMOTIFEX_DIR" cd "$REMOTIFEX_DIR" fi echo "[OK] Repository ready" } # Create .env file setup_env() { if [ -f "$REMOTIFEX_DIR/.env" ]; then echo "[OK] .env file already exists, keeping it" return fi echo "[..] Creating .env configuration..." JWT_SECRET=$(generate_secret) ENCRYPTION_KEY=$(generate_secret) cat > "$REMOTIFEX_DIR/.env" << EOF # Remotifex Configuration # Generated by install script on $(date -u +"%Y-%m-%dT%H:%M:%SZ") # All settings are managed via the web UI — no need to edit this file. # Security (auto-generated) JWT_SECRET=${JWT_SECRET} ENCRYPTION_KEY=${ENCRYPTION_KEY} # MongoDB MONGODB_URL=mongodb://mongo:27017/remotifex # Redis REDIS_URL=redis://redis:6379/0 # Data directory PROJECTS_DATA_DIR=/data/projects EOF chmod 600 "$REMOTIFEX_DIR/.env" echo "[OK] .env created with generated secrets" } # Build and start services start_services() { echo "[..] Building and starting Remotifex..." cd "$REMOTIFEX_DIR" docker compose build docker compose up -d echo "[OK] All services started" } # Main echo "Step 1/4: Checking requirements..." check_requirements echo "" echo "Step 2/4: Setting up repository..." setup_repo echo "" echo "Step 3/4: Configuring environment..." setup_env echo "" echo "Step 4/4: Starting services..." start_services SERVER_IP=$(detect_ip) echo "" echo " ╔══════════════════════════════════════╗" echo " ║ Remotifex is running! ║" echo " ╚══════════════════════════════════════╝" echo "" echo " Open http://${SERVER_IP} in your browser" echo " Complete the setup wizard to get started." echo "" echo " Domains, AI keys, and all other settings" echo " are configured via the web UI." echo "" echo " To update Remotifex:" echo " cd $REMOTIFEX_DIR && git pull && docker compose up -d --build" echo ""