#!/bin/bash # LXS - Coolify Installation Script # Description: Install and manage Coolify deployment platform # Author: LXS # Date: 2025 # Load LXS common library (colors, separator, run_spinner, loggers, helpers) LXS_RAW_BASE="${LXS_RAW_BASE:-https://git.hyko.cx/hykocx/lxs/raw/branch/main}" _lib=$(curl -fsSL "${LXS_RAW_BASE}/lib/common.sh") || { echo "Failed to fetch lib/common.sh" >&2; exit 1; } eval "$_lib" unset _lib export LXS_LOG_FILE="/tmp/lxs_coolify.log" require_root "$0" "$@" # ═══════════════════════════════════════════════════════════════════════════ # Configuration # ═══════════════════════════════════════════════════════════════════════════ INSTALL_DIR="/data/coolify" PORT=8000 # ═══════════════════════════════════════════════════════════════════════════ # Helper Functions # ═══════════════════════════════════════════════════════════════════════════ is_installed() { [ -d "$INSTALL_DIR" ] && docker ps | grep -q "coolify" } check_requirements() { echo -e "${WHITE}Checking System Requirements...${NC}" local cpu_cores=$(nproc) [ $cpu_cores -lt 2 ] && echo -e "${YELLOW}[!] Warning: Recommended minimum is 2 CPU cores (found: $cpu_cores)${NC}" || echo -e "${GREEN}[✓] CPU cores: $cpu_cores${NC}" local total_mem_gb=$(($(grep MemTotal /proc/meminfo | awk '{print $2}') / 1024 / 1024)) [ $total_mem_gb -lt 2 ] && echo -e "${YELLOW}[!] Warning: Recommended minimum is 2GB RAM (found: ${total_mem_gb}GB)${NC}" || echo -e "${GREEN}[✓] Memory: ${total_mem_gb}GB${NC}" local available_gb=$(($(df / | awk 'NR==2 {print $4}') / 1024 / 1024)) [ $available_gb -lt 30 ] && echo -e "${YELLOW}[!] Warning: Recommended minimum is 30GB free space (found: ${available_gb}GB)${NC}" || echo -e "${GREEN}[✓] Disk space: ${available_gb}GB available${NC}" local arch=$(uname -m) if [[ "$arch" != "x86_64" && "$arch" != "aarch64" ]]; then echo -e "${RED}[✗] Unsupported architecture: $arch${NC}" return 1 fi echo -e "${GREEN}[✓] Architecture: $arch${NC}" return 0 } # ═══════════════════════════════════════════════════════════════════════════ # Installation Functions # ═══════════════════════════════════════════════════════════════════════════ install_coolify() { local start_time=$(date +%s) apt_noninteractive echo -e "${WHITE}${BOLD}COOLIFY INSTALLATION${NC}\n" if is_installed; then echo -e "${YELLOW}Coolify is already installed!${NC}" return 0 fi check_requirements || return 1 echo "" wait_for_apt || return 1 echo "" echo -e "${WHITE}Running Official Coolify Installer${NC}" echo -e "${GRAY}[i] Installing Docker and all dependencies...${NC}" curl -fsSL https://cdn.coollabs.io/coolify/install.sh | bash if [ $? -ne 0 ]; then echo -e "${RED}[✗] Installation failed!${NC}" return 1 fi echo -e "${PURPLE}[*] Waiting for Coolify to start...${NC}" sleep 10 local max_retries=30 local retry=0 while [ $retry -lt $max_retries ]; do docker ps | grep -q "coolify" && break retry=$((retry + 1)) sleep 2 done ufw_allow 80/tcp "Coolify HTTP" ufw_allow 443/tcp "Coolify HTTPS" ufw_allow "${PORT}/tcp" "Coolify dashboard" local duration=$(( $(date +%s) - start_time )) local minutes=$((duration / 60)) local seconds=$((duration % 60)) echo "" echo -e "${GREEN}${BOLD}Installation Completed Successfully!${NC}" echo -e "${GRAY}Installation time: ${minutes}m ${seconds}s${NC}" echo "" echo -e "${CYAN}Access URL: ${BOLD}http://$(get_public_ip):$PORT${NC}" echo "" echo -e "${RED}${BOLD}IMPORTANT:${NC} ${RED}Create your admin account immediately!${NC}" echo -e "${RED}Visit the URL now to secure your installation.${NC}" } update_coolify() { echo -e "${WHITE}${BOLD}COOLIFY UPDATE${NC}\n" apt_noninteractive if ! is_installed; then echo -e "${RED}Coolify is not installed!${NC}" return 1 fi curl -fsSL https://cdn.coollabs.io/coolify/install.sh | bash [ $? -eq 0 ] && echo -e "${GREEN}[✓] Update completed${NC}" || echo -e "${RED}[✗] Update failed${NC}" } show_status() { echo -e "${WHITE}${BOLD}COOLIFY STATUS${NC}\n" if ! is_installed; then echo -e "${RED}Coolify is not installed!${NC}" return 1 fi if docker ps | grep -q "coolify"; then echo -e "${GREEN}Coolify is running${NC}\n" docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" | grep -E "(NAMES|coolify)" echo "" echo -e "${CYAN}Access URL: ${BOLD}http://$(get_public_ip):$PORT${NC}" else echo -e "${RED}Coolify is not running${NC}" fi return 0 } # ═══════════════════════════════════════════════════════════════════════════ # Main Menu # ═══════════════════════════════════════════════════════════════════════════ show_post_installation_guide() { clear echo -e "${WHITE}${BOLD}COOLIFY POST-INSTALLATION GUIDE${NC}\n" show_separator echo -e "${CYAN}${BOLD}1. Domain Name${NC}" echo -e "${GRAY} Settings -> General${NC}" echo -e "${WHITE} Name${NC}" echo "" show_separator echo -e "${CYAN}${BOLD}2. Timezone${NC}" echo -e "${GRAY} Settings -> General${NC}" echo -e "${WHITE} Timezone: Toronto${NC}" echo "" show_separator echo -e "${CYAN}${BOLD}3. Do Not Track Activation${NC}" echo -e "${GRAY} Settings -> Advanced${NC}" echo "" show_separator echo -e "${CYAN}${BOLD}4. Discord Notifications${NC}" echo -e "${GRAY} Notifications -> Discord${NC}" echo "" echo -e "${WHITE} Configuration:${NC}" echo -e " ${GREEN}[x]${NC} Deployment Success" echo -e " ${GREEN}[x]${NC} Deployment Failure" echo -e " ${GRAY}[ ]${NC} Container Status Changes" echo -e " ${GREEN}[x]${NC} Backup Success" echo -e " ${GREEN}[x]${NC} Backup Failure" echo -e " ${GRAY}[ ]${NC} Scheduled Task Success" echo -e " ${GREEN}[x]${NC} Scheduled Task Failure" echo -e " ${GRAY}[ ]${NC} Docker Cleanup Success" echo -e " ${GREEN}[x]${NC} Docker Cleanup Failure" echo -e " ${GREEN}[x]${NC} Server Disk Usage" echo -e " ${GREEN}[x]${NC} Server Reachable" echo -e " ${GREEN}[x]${NC} Server Unreachable" echo "" show_separator echo -e "${CYAN}${BOLD}5. S3 Storage for Backups${NC}" echo -e "${GRAY} S3 Storages${NC}" echo "" echo -e "${WHITE} Configuration:${NC}" echo -e " ${GRAY}Name:${NC} Provider name (ex. Backblaze)" echo -e " ${GRAY}Endpoint:${NC} " echo -e " ${GRAY}Bucket:${NC} " echo -e " ${GRAY}Access Key:${NC} " echo -e " ${GRAY}Secret Key:${NC} " echo "" show_separator echo -e "${CYAN}${BOLD}6. Coolify Backup Configuration${NC}" echo -e "${GRAY} Settings -> Backup${NC}" echo "" echo -e "${WHITE} Configuration:${NC}" echo -e " ${GREEN}[x]${NC} S3 Enabled" echo -e " ${GRAY}Number of backups to keep:${NC} 7" echo "" show_separator echo -e "${CYAN}${BOLD}7. Server Timezone${NC}" echo -e "${GRAY} Servers -> localhost -> General${NC}" echo -e "${WHITE} Timezone: Toronto${NC}" echo "" show_separator echo -e "${CYAN}${BOLD}8. Docker Cleanup Schedule${NC}" echo -e "${GRAY} Servers -> localhost -> Docker Cleanup${NC}" echo "" echo -e "${WHITE} Schedule (every hour):${NC}" echo -e " ${GRAY}0 * * * *${NC}" echo "" show_separator echo "" } show_menu() { clear echo -e "${WHITE}${BOLD}COOLIFY MANAGEMENT${NC}\n" echo -e " ${GREEN}[1]${NC} Install Coolify" echo -e " ${YELLOW}[2]${NC} Update Coolify" echo -e " ${CYAN}[3]${NC} View Status" echo -e " ${PURPLE}[4]${NC} Post-Installation Guide" echo -e " ${RED}[0]${NC} Back to main menu" echo "" echo -n "Choice [0-4]: " } main() { while true; do show_menu read -r choice echo "" case $choice in 1) install_coolify ;; 2) update_coolify ;; 3) show_status ;; 4) show_post_installation_guide ;; 0) return 75 ;; *) echo -e "${RED}Invalid option${NC}" ;; esac echo "" read -p "Press Enter to continue..." done } main