Merge pull request #1659 from master3395/v2.5.5-dev

V2.5.5 dev
This commit is contained in:
Master3395
2026-01-26 21:33:02 +01:00
committed by GitHub
2 changed files with 184 additions and 460 deletions

View File

@@ -610,16 +610,17 @@ install_cyberpanel_direct() {
cd "$temp_dir" || return 1
# Download the working CyberPanel installation files
echo "Downloading from: https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/cyberpanel.sh"
# Use master3395 fork which has our fixes
echo "Downloading from: https://raw.githubusercontent.com/master3395/cyberpanel/v2.5.5-dev/cyberpanel.sh"
# Try development branch first, fallback to stable
local installer_url="https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.5.5-dev/cyberpanel.sh"
local installer_url="https://raw.githubusercontent.com/master3395/cyberpanel/v2.5.5-dev/cyberpanel.sh"
# Test if the development branch exists
if ! curl -s --head "$installer_url" | grep -q "200 OK"; then
echo " Development branch not available, falling back to stable"
installer_url="https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/cyberpanel.sh"
installer_url="https://raw.githubusercontent.com/master3395/cyberpanel/stable/cyberpanel.sh"
else
echo " Using development branch (v2.5.5-dev)"
echo " Using development branch (v2.5.5-dev) from master3395/cyberpanel"
fi
curl --silent -o cyberpanel_installer.sh "$installer_url" 2>/dev/null
@@ -628,13 +629,17 @@ install_cyberpanel_direct() {
return 1
fi
chmod +x cyberpanel_installer.sh
# Make script executable and verify
chmod 755 cyberpanel_installer.sh 2>/dev/null || true
if [ ! -x "cyberpanel_installer.sh" ]; then
print_status "WARNING: Could not make cyberpanel_installer.sh executable, will use bash to execute"
fi
# Download the install directory
echo "Downloading installation files..."
local archive_url="https://github.com/usmannasir/cyberpanel/archive/v2.5.5-dev.tar.gz"
if [ "$installer_url" = "https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/cyberpanel.sh" ]; then
archive_url="https://github.com/usmannasir/cyberpanel/archive/stable.tar.gz"
local archive_url="https://github.com/master3395/cyberpanel/archive/v2.5.5-dev.tar.gz"
if [ "$installer_url" = "https://raw.githubusercontent.com/master3395/cyberpanel/stable/cyberpanel.sh" ]; then
archive_url="https://github.com/master3395/cyberpanel/archive/stable.tar.gz"
fi
curl --silent -L -o install_files.tar.gz "$archive_url" 2>/dev/null
@@ -651,7 +656,7 @@ install_cyberpanel_direct() {
fi
# Copy install directory to current location
if [ "$installer_url" = "https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/cyberpanel.sh" ]; then
if [ "$installer_url" = "https://raw.githubusercontent.com/master3395/cyberpanel/stable/cyberpanel.sh" ]; then
cp -r cyberpanel-stable/install . 2>/dev/null || true
cp -r cyberpanel-stable/install.sh . 2>/dev/null || true
else
@@ -696,10 +701,25 @@ install_cyberpanel_direct() {
echo ""
# Run installer and show live output, capturing the password
if [ "$DEBUG_MODE" = true ]; then
./cyberpanel_installer.sh --debug 2>&1 | tee /var/log/CyberPanel/install_output.log
# Use bash to execute to avoid permission issues
local installer_script="cyberpanel_installer.sh"
if [ ! -f "$installer_script" ]; then
print_status "ERROR: cyberpanel_installer.sh not found in current directory: $(pwd)"
return 1
fi
# Get absolute path to installer script
local installer_path
if [[ "$installer_script" = /* ]]; then
installer_path="$installer_script"
else
./cyberpanel_installer.sh 2>&1 | tee /var/log/CyberPanel/install_output.log
installer_path="$(pwd)/$installer_script"
fi
if [ "$DEBUG_MODE" = true ]; then
bash "$installer_path" --debug 2>&1 | tee /var/log/CyberPanel/install_output.log
else
bash "$installer_path" 2>&1 | tee /var/log/CyberPanel/install_output.log
fi
local install_exit_code=${PIPESTATUS[0]}

View File

@@ -1,460 +1,164 @@
#!/bin/bash
#!/bin/sh
# Enhanced CyberPanel Installer with Modular Architecture
# This installer uses modules for better organization and maintainability
# Each module is kept under 500 lines for easy management
# CyberPanel v2.5.5-dev Installer
# Simplified approach similar to stable branch
# Note: We use 'set -e' carefully - some operations need to handle failures gracefully
set -e
# Get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Early logging function (before main functions are defined)
early_log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
}
# Check if script is being executed via curl/wget (SCRIPT_DIR will be /dev/fd/...)
# In that case, we need to clone the repository first
if [[ "$SCRIPT_DIR" == /dev/fd/* ]] || [[ ! -d "$SCRIPT_DIR/modules" ]]; then
# Script is being executed via curl/wget, need to clone repo first
early_log "📥 Detected curl/wget execution - cloning repository..."
# Determine branch from arguments or use default
BRANCH_NAME="v2.5.5-dev"
ARGS=("$@")
for i in "${!ARGS[@]}"; do
if [[ "${ARGS[i]}" == "-b" ]] || [[ "${ARGS[i]}" == "--branch" ]]; then
if [[ -n "${ARGS[i+1]}" ]]; then
BRANCH_NAME="${ARGS[i+1]}"
fi
break
fi
done
# Clone repository to temporary directory
# Try multiple locations if /tmp is full
TEMP_DIR=""
early_log "Checking available disk space..."
# Try to clean up old temp directories first
rm -rf /tmp/cyberpanel-installer-* 2>/dev/null || true
rm -rf /var/tmp/cyberpanel-installer-* 2>/dev/null || true
# Try multiple temp locations (disable set -e for this section)
set +e
for temp_location in "/tmp/cyberpanel-installer-$$" "/var/tmp/cyberpanel-installer-$$" "$HOME/cyberpanel-installer-$$" "/root/cyberpanel-installer-$$"; do
if mkdir -p "$temp_location" 2>/dev/null; then
TEMP_DIR="$temp_location"
early_log "Using temporary directory: $TEMP_DIR"
break
fi
done
set -e
# If we still don't have a temp dir, skip git clone and use fallback
if [ -z "$TEMP_DIR" ]; then
early_log "⚠️ Cannot create temporary directory (disk may be full)"
early_log "Skipping git clone, using fallback installer directly..."
# Skip to fallback installer
TEMP_DIR=""
fi
# Only attempt git clone if we have a temp directory
if [ -n "$TEMP_DIR" ]; then
early_log "📦 Cloning CyberPanel repository (branch: $BRANCH_NAME)..."
early_log "This may take a minute depending on your connection speed..."
# Try git clone with timeout and better error handling
GIT_CLONE_SUCCESS=false
if command -v timeout >/dev/null 2>&1; then
if timeout 180 git clone --depth 1 --branch "$BRANCH_NAME" https://github.com/master3395/cyberpanel.git "$TEMP_DIR/cyberpanel" >/tmp/git-clone.log 2>&1; then
GIT_CLONE_SUCCESS=true
fi
else
# No timeout command, try without timeout
if git clone --depth 1 --branch "$BRANCH_NAME" https://github.com/master3395/cyberpanel.git "$TEMP_DIR/cyberpanel" >/tmp/git-clone.log 2>&1; then
GIT_CLONE_SUCCESS=true
fi
fi
# Verify clone was successful and structure is valid
if [ "$GIT_CLONE_SUCCESS" = true ] && [ -d "$TEMP_DIR/cyberpanel" ] && [ -f "$TEMP_DIR/cyberpanel/install.sh" ] && [ -d "$TEMP_DIR/cyberpanel/modules" ]; then
SCRIPT_DIR="$TEMP_DIR/cyberpanel"
cd "$SCRIPT_DIR"
early_log "✅ Repository cloned successfully"
else
# Git clone failed or structure invalid, use fallback
GIT_ERROR=$(tail -3 /tmp/git-clone.log 2>/dev/null | tr '\n' ' ')
early_log "⚠️ Git clone failed or incomplete"
if [ -n "$GIT_ERROR" ]; then
early_log "Last error: $GIT_ERROR"
fi
early_log "Falling back to legacy installer..."
rm -rf "$TEMP_DIR/cyberpanel" 2>/dev/null || true
TEMP_DIR="" # Clear TEMP_DIR to trigger fallback
fi
fi
# If git clone failed or we couldn't create temp dir, use fallback
if [ -z "$TEMP_DIR" ] || [ ! -d "$TEMP_DIR/cyberpanel" ] || [ ! -f "$TEMP_DIR/cyberpanel/install.sh" ]; then
# Fallback: try to download install.sh from the old method
early_log "Using fallback installer method..."
OUTPUT=$(cat /etc/*release 2>/dev/null || echo "")
if echo "$OUTPUT" | grep -qE "(CentOS|AlmaLinux|CloudLinux|Rocky)" ; then
SERVER_OS="CentOS8"
yum install -y -q curl wget 2>/dev/null || dnf install -y -q curl wget 2>/dev/null || true
elif echo "$OUTPUT" | grep -qE "Ubuntu" ; then
SERVER_OS="Ubuntu"
apt install -y -qq wget curl 2>/dev/null || true
else
early_log "❌ Unable to detect OS for fallback installer"
exit 1
fi
# Try multiple locations for fallback script
FALLBACK_SCRIPT=""
for fallback_location in "/tmp/cyberpanel.sh" "/var/tmp/cyberpanel.sh" "$HOME/cyberpanel.sh"; do
rm -f "$fallback_location" 2>/dev/null || true
if curl --silent -o "$fallback_location" "https://cyberpanel.sh/?dl&$SERVER_OS" 2>/dev/null || \
wget -q -O "$fallback_location" "https://cyberpanel.sh/?dl&$SERVER_OS" 2>/dev/null; then
if [ -f "$fallback_location" ]; then
FALLBACK_SCRIPT="$fallback_location"
chmod +x "$FALLBACK_SCRIPT"
break
fi
fi
done
if [ -n "$FALLBACK_SCRIPT" ] && [ -f "$FALLBACK_SCRIPT" ]; then
early_log "✅ Fallback installer downloaded, executing..."
exec "$FALLBACK_SCRIPT" "$@"
else
early_log "❌ Failed to download fallback installer"
early_log "Please free up disk space or check your internet connection"
exit 1
fi
fi
fi # Close the if [[ "$SCRIPT_DIR" == /dev/fd/* ]] block
MODULES_DIR="$SCRIPT_DIR/modules"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Global variables
SERVER_OS=""
OS_FAMILY=""
PACKAGE_MANAGER=""
ARCHITECTURE=""
BRANCH_NAME=""
# Logging function
log_message() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [MAIN-INSTALLER] $1" | tee -a "/var/log/cyberpanel_install.log" 2>/dev/null || echo "[$(date '+%Y-%m-%d %H:%M:%S')] [MAIN-INSTALLER] $1"
}
# Print colored output
print_status() {
local color=$1
local message=$2
echo -e "${color}${message}${NC}"
log_message "$message"
}
# Function to load modules
load_module() {
local module_path="$1"
local module_name="$2"
if [ -f "$module_path" ]; then
source "$module_path"
print_status "$GREEN" "✅ Loaded module: $module_name"
return 0
else
print_status "$RED" "❌ Module not found: $module_path"
return 1
fi
}
# Function to initialize modules
initialize_modules() {
print_status "$BLUE" "🔧 Initializing modules..."
# Load OS detection module
if ! load_module "$MODULES_DIR/os/detect.sh" "OS Detection"; then
print_status "$RED" "❌ Failed to load OS detection module"
exit 1
fi
# Load dependency manager module
if ! load_module "$MODULES_DIR/deps/manager.sh" "Dependency Manager"; then
print_status "$RED" "❌ Failed to load dependency manager module"
exit 1
fi
# Load CyberPanel installer module
if ! load_module "$MODULES_DIR/install/cyberpanel_installer.sh" "CyberPanel Installer"; then
print_status "$RED" "❌ Failed to load CyberPanel installer module"
exit 1
fi
# Load fixes module
if ! load_module "$MODULES_DIR/fixes/cyberpanel_fixes.sh" "CyberPanel Fixes"; then
print_status "$RED" "❌ Failed to load fixes module"
exit 1
fi
print_status "$GREEN" "✅ All modules loaded successfully"
}
# Function to detect operating system
detect_operating_system() {
print_status "$BLUE" "🔍 Detecting operating system..."
if detect_os; then
# Get OS information using get_os_info() to ensure we capture the values
# This outputs variable assignments that we can eval
eval $(get_os_info)
# Export them to ensure they're available to all functions
export SERVER_OS OS_FAMILY PACKAGE_MANAGER ARCHITECTURE
print_status "$GREEN" "✅ OS detected: $SERVER_OS ($OS_FAMILY)"
print_status "$GREEN" "✅ Package manager: $PACKAGE_MANAGER"
print_status "$GREEN" "✅ Architecture: $ARCHITECTURE"
# Verify variables are set
if [ -z "$SERVER_OS" ] || [ -z "$OS_FAMILY" ] || [ -z "$PACKAGE_MANAGER" ]; then
print_status "$RED" "❌ OS variables not properly set after detection"
return 1
fi
return 0
else
print_status "$RED" "❌ Failed to detect operating system"
exit 1
fi
}
# Function to install dependencies
install_dependencies() {
print_status "$BLUE" "📦 Installing dependencies..."
# Debug: Show current variable values
print_status "$YELLOW" "DEBUG: SERVER_OS='$SERVER_OS', OS_FAMILY='$OS_FAMILY', PACKAGE_MANAGER='$PACKAGE_MANAGER'"
# Ensure variables are set (they should be from detect_operating_system)
if [ -z "$SERVER_OS" ] || [ -z "$OS_FAMILY" ] || [ -z "$PACKAGE_MANAGER" ]; then
print_status "$YELLOW" "⚠️ OS variables not set, re-detecting..."
# Try to get them again
if detect_os; then
# Variables should be set by detect_os() in the sourced module
export SERVER_OS OS_FAMILY PACKAGE_MANAGER ARCHITECTURE
print_status "$GREEN" "✅ Re-detected: SERVER_OS=$SERVER_OS, OS_FAMILY=$OS_FAMILY, PACKAGE_MANAGER=$PACKAGE_MANAGER"
else
print_status "$RED" "❌ Failed to detect OS for dependency installation"
return 1
fi
fi
# Verify variables one more time before calling
if [ -z "$SERVER_OS" ] || [ -z "$OS_FAMILY" ] || [ -z "$PACKAGE_MANAGER" ]; then
print_status "$RED" "❌ OS variables still not set after re-detection"
return 1
fi
print_status "$BLUE" "Calling manage_dependencies with: SERVER_OS='$SERVER_OS', OS_FAMILY='$OS_FAMILY', PACKAGE_MANAGER='$PACKAGE_MANAGER'"
if manage_dependencies "$SERVER_OS" "$OS_FAMILY" "$PACKAGE_MANAGER"; then
print_status "$GREEN" "✅ Dependencies installed successfully"
return 0
else
print_status "$YELLOW" "⚠️ Dependency installation had issues, continuing..."
return 1
fi
}
# Function to install CyberPanel
install_cyberpanel_main() {
print_status "$BLUE" "🚀 Installing CyberPanel..."
# Prepare installation arguments
local install_args=()
for arg in "$@"; do
install_args+=("$arg")
done
if install_cyberpanel_main "$SERVER_OS" "$BRANCH_NAME" "${install_args[@]}"; then
print_status "$GREEN" "✅ CyberPanel installed successfully"
return 0
else
print_status "$RED" "❌ CyberPanel installation failed"
return 1
fi
}
# Function to apply fixes
apply_fixes() {
print_status "$BLUE" "🔧 Applying installation fixes..."
if apply_cyberpanel_fixes "$PACKAGE_MANAGER"; then
print_status "$GREEN" "✅ All fixes applied successfully"
return 0
else
print_status "$YELLOW" "⚠️ Some fixes had issues, but continuing..."
return 1
fi
}
# Function to show firewall information
show_firewall_info() {
echo ""
echo "🔥 FIREWALL CONFIGURATION REQUIRED:"
echo "═══════════════════════════════════════════════════════════════════════════════════════════════════════════════"
echo "If your provider has a network-level firewall, please ensure these ports are open:"
echo ""
echo "• TCP 8090 - CyberPanel Web Interface"
echo "• TCP 80, 443 - Web Server (HTTP/HTTPS)"
echo "• TCP 7080 - LiteSpeed Admin Console"
echo "• TCP 21, 40110-40210 - FTP Service"
echo "• TCP 25, 587, 465, 110, 143, 993 - Mail Services"
echo "• TCP/UDP 53 - DNS Service"
echo ""
}
# Function to show final restart prompt
show_restart_prompt() {
echo ""
echo "╔═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╗"
echo "║ ║"
echo "║ 🔄 SERVER RESTART PROMPT 🔄 ║"
echo "║ ║"
echo "╚═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╝"
echo ""
print_status "$GREEN" "✅ Installation completed! Safe to restart server."
echo "Would you like to restart your server now? [Y/n]: "
read -r response
case "$response" in
[yY]|[yY][eE][sS]|"")
print_status "$GREEN" "🔄 Restarting server..."
shutdown -r now
;;
*)
print_status "$BLUE" "Server restart cancelled. You can restart manually when ready."
# Determine branch from arguments or use default
BRANCH_NAME="v2.5.5-dev"
for arg in "$@"; do
case "$arg" in
-b|--branch)
BRANCH_NAME="$2"
shift 2
;;
esac
}
done
# Function to parse command line arguments
parse_arguments() {
while [[ $# -gt 0 ]]; do
case $1 in
-b|--branch)
BRANCH_NAME="$2"
shift 2
;;
--debug)
set -x
shift
;;
-h|--help)
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -b, --branch BRANCH Install from specific branch/commit"
echo " --debug Enable debug mode"
echo " -h, --help Show this help message"
exit 0
;;
*)
print_status "$YELLOW" "Unknown option: $1"
shift
;;
esac
done
}
# Function to check disk space
# Check disk space (10GB minimum)
check_disk_space() {
local required_gb=10 # Minimum 10GB required
local root_available_gb=0
# Get available space on root filesystem
if command -v df >/dev/null 2>&1; then
root_available_gb=$(df -BG / | awk 'NR==2 {print $4}' | sed 's/G//' | cut -d. -f1)
if [ -z "$root_available_gb" ] || [ "$root_available_gb" = "" ]; then
# Try alternative method
root_available_gb=$(df -BG / | tail -1 | awk '{print $4}' | sed 's/G//' | cut -d. -f1)
available_gb=$(df -BG / 2>/dev/null | awk 'NR==2 {print $4}' | sed 's/G//' | cut -d. -f1)
if [ -z "$available_gb" ] || ! [[ "$available_gb" =~ ^[0-9]+$ ]]; then
available_gb=$(df / 2>/dev/null | awk 'NR==2 {print $4}' | awk '{printf "%.0f", $1/1024/1024}')
fi
if [[ "$available_gb" =~ ^[0-9]+$ ]]; then
echo "💾 Disk space: ${available_gb}GB available (10GB minimum required)"
if [ "$available_gb" -lt 10 ]; then
echo "⚠️ Warning: Less than 10GB available. Installation may fail."
fi
fi
fi
# If we couldn't get the value, try without -BG flag
if [ -z "$root_available_gb" ] || ! [[ "$root_available_gb" =~ ^[0-9]+$ ]]; then
root_available_gb=$(df / | awk 'NR==2 {print $4}' | awk '{printf "%.0f", $1/1024/1024}')
fi
print_status "$BLUE" "💾 Checking disk space..."
print_status "$BLUE" " Required: ${required_gb}GB minimum"
if [[ "$root_available_gb" =~ ^[0-9]+$ ]] && [ "$root_available_gb" -ge "$required_gb" ]; then
print_status "$GREEN" " Available: ${root_available_gb}GB (✅ Sufficient)"
return 0
elif [[ "$root_available_gb" =~ ^[0-9]+$ ]]; then
print_status "$YELLOW" " Available: ${root_available_gb}GB (⚠️ Less than ${required_gb}GB recommended)"
print_status "$YELLOW" " Installation may fail if disk space runs out"
return 1
else
print_status "$YELLOW" " Could not determine available disk space"
print_status "$YELLOW" " Please ensure at least ${required_gb}GB is available"
return 1
fi
}
# Main installation function
main() {
# Initialize log file
mkdir -p /var/log
touch "/var/log/cyberpanel_install.log"
print_status "$BLUE" "🚀 Enhanced CyberPanel Installer Starting..."
print_status "$BLUE" "Log file: /var/log/cyberpanel_install.log"
# Check disk space before proceeding
check_disk_space
# Parse command line arguments
parse_arguments "$@"
# Initialize modules
initialize_modules
# Detect operating system
detect_operating_system
# Install dependencies
install_dependencies
# Install CyberPanel
install_cyberpanel_main "$@"
# Apply fixes
apply_fixes
# Show firewall information
show_firewall_info
# Show restart prompt
show_restart_prompt
print_status "$GREEN" "🎉 CyberPanel installation process completed!"
}
# Detect OS and set SERVER_OS (similar to stable branch)
OUTPUT=$(cat /etc/*release 2>/dev/null || echo "")
# Run main function
main "$@"
if echo "$OUTPUT" | grep -q "CentOS Linux 7" ; then
echo "Checking and installing curl and wget"
yum install curl wget -y 1> /dev/null 2>&1 || dnf install curl wget -y 1> /dev/null 2>&1 || true
yum update curl wget ca-certificates -y 1> /dev/null 2>&1 || dnf update curl wget ca-certificates -y 1> /dev/null 2>&1 || true
SERVER_OS="CentOS"
elif echo "$OUTPUT" | grep -q "CentOS Linux 8" ; then
echo -e "\nDetecting CentOS 8...\n"
SERVER_OS="CentOS8"
yum install curl wget -y 1> /dev/null 2>&1 || dnf install curl wget -y 1> /dev/null 2>&1 || true
yum update curl wget ca-certificates -y 1> /dev/null 2>&1 || dnf update curl wget ca-certificates -y 1> /dev/null 2>&1 || true
elif echo "$OUTPUT" | grep -q "AlmaLinux 8" ; then
echo -e "\nDetecting AlmaLinux 8...\n"
SERVER_OS="CentOS8"
yum install curl wget -y 1> /dev/null 2>&1 || dnf install curl wget -y 1> /dev/null 2>&1 || true
yum update curl wget ca-certificates -y 1> /dev/null 2>&1 || dnf update curl wget ca-certificates -y 1> /dev/null 2>&1 || true
elif echo "$OUTPUT" | grep -q "AlmaLinux 9" ; then
echo -e "\nDetecting AlmaLinux 9...\n"
SERVER_OS="CentOS8"
yum install curl wget -y 1> /dev/null 2>&1 || dnf install curl wget -y 1> /dev/null 2>&1 || true
yum update curl wget ca-certificates -y 1> /dev/null 2>&1 || dnf update curl wget ca-certificates -y 1> /dev/null 2>&1 || true
elif echo "$OUTPUT" | grep -q "AlmaLinux 10" ; then
echo -e "\nDetecting AlmaLinux 10...\n"
SERVER_OS="CentOS8"
yum install curl wget -y 1> /dev/null 2>&1 || dnf install curl wget -y 1> /dev/null 2>&1 || true
yum update curl wget ca-certificates -y 1> /dev/null 2>&1 || dnf update curl wget ca-certificates -y 1> /dev/null 2>&1 || true
elif echo "$OUTPUT" | grep -q "CloudLinux 7" ; then
echo "Checking and installing curl and wget"
yum install curl wget -y 1> /dev/null 2>&1 || dnf install curl wget -y 1> /dev/null 2>&1 || true
yum update curl wget ca-certificates -y 1> /dev/null 2>&1 || dnf update curl wget ca-certificates -y 1> /dev/null 2>&1 || true
SERVER_OS="CloudLinux"
elif echo "$OUTPUT" | grep -q "CloudLinux 8" ; then
echo "Checking and installing curl and wget"
yum install curl wget -y 1> /dev/null 2>&1 || dnf install curl wget -y 1> /dev/null 2>&1 || true
yum update curl wget ca-certificates -y 1> /dev/null 2>&1 || dnf update curl wget ca-certificates -y 1> /dev/null 2>&1 || true
SERVER_OS="CloudLinux"
elif echo "$OUTPUT" | grep -q "Ubuntu 18.04" ; then
apt install -y -qq wget curl 2>/dev/null || true
SERVER_OS="Ubuntu"
elif echo "$OUTPUT" | grep -q "Ubuntu 20.04" ; then
apt install -y -qq wget curl 2>/dev/null || true
SERVER_OS="Ubuntu"
elif echo "$OUTPUT" | grep -q "Ubuntu 22.04" ; then
apt install -y -qq wget curl 2>/dev/null || true
SERVER_OS="Ubuntu"
elif echo "$OUTPUT" | grep -q "Ubuntu 24.04" ; then
apt install -y -qq wget curl 2>/dev/null || true
SERVER_OS="Ubuntu"
elif echo "$OUTPUT" | grep -q "openEuler 20.03" ; then
echo -e "\nDetecting openEuler 20.03...\n"
SERVER_OS="openEuler"
yum install curl wget -y 1> /dev/null 2>&1 || dnf install curl wget -y 1> /dev/null 2>&1 || true
yum update curl wget ca-certificates -y 1> /dev/null 2>&1 || dnf update curl wget ca-certificates -y 1> /dev/null 2>&1 || true
elif echo "$OUTPUT" | grep -q "openEuler 22.03" ; then
echo -e "\nDetecting openEuler 22.03...\n"
SERVER_OS="openEuler"
yum install curl wget -y 1> /dev/null 2>&1 || dnf install curl wget -y 1> /dev/null 2>&1 || true
yum update curl wget ca-certificates -y 1> /dev/null 2>&1 || dnf update curl wget ca-certificates -y 1> /dev/null 2>&1 || true
else
echo -e "\nUnable to detect your OS...\n"
echo -e "\nCyberPanel is supported on Ubuntu 18.04, Ubuntu 20.04, Ubuntu 22.04, Ubuntu 24.04, AlmaLinux 8, AlmaLinux 9, AlmaLinux 10 and CloudLinux 7.x...\n"
exit 1
fi
# Check disk space
check_disk_space
# Download and execute cyberpanel.sh for the specified branch
echo "Downloading CyberPanel installer for branch: $BRANCH_NAME"
# Use absolute path for downloaded script in a writable directory
TEMP_DIR="/tmp"
SCRIPT_PATH="$TEMP_DIR/cyberpanel-$$.sh"
rm -f "$SCRIPT_PATH" "$TEMP_DIR/cyberpanel.sh" "$TEMP_DIR/install.tar.gz"
# Ensure temp directory exists and is writable
mkdir -p "$TEMP_DIR" 2>/dev/null || true
# For v2.5.5-dev, try to get the cyberpanel.sh from the branch
if [ "$BRANCH_NAME" = "v2.5.5-dev" ] || [ "$BRANCH_NAME" = "stable" ]; then
# Try to download from the branch-specific URL
if curl --silent -o "$SCRIPT_PATH" "https://raw.githubusercontent.com/master3395/cyberpanel/$BRANCH_NAME/cyberpanel.sh" 2>/dev/null; then
if [ -f "$SCRIPT_PATH" ] && [ -s "$SCRIPT_PATH" ]; then
# Make script executable
chmod 755 "$SCRIPT_PATH" 2>/dev/null || true
# Verify it's executable
if [ -x "$SCRIPT_PATH" ]; then
echo "✅ Downloaded cyberpanel.sh from branch $BRANCH_NAME"
# Change to temp directory and execute with bash
# Use absolute path to avoid any relative path issues
cd "$TEMP_DIR" || cd /tmp || cd /
bash "$SCRIPT_PATH" "$@"
exit $?
else
echo "⚠️ Warning: Could not make script executable, trying alternative method..."
cd "$TEMP_DIR" || cd /tmp || cd /
bash -c "bash '$SCRIPT_PATH' $*"
exit $?
fi
fi
fi
fi
# Fallback to standard cyberpanel.sh download
if curl --silent -o "$SCRIPT_PATH" "https://cyberpanel.sh/?dl&$SERVER_OS" 2>/dev/null || \
wget -q -O "$SCRIPT_PATH" "https://cyberpanel.sh/?dl&$SERVER_OS" 2>/dev/null; then
if [ -f "$SCRIPT_PATH" ] && [ -s "$SCRIPT_PATH" ]; then
# Make script executable
chmod 755 "$SCRIPT_PATH" 2>/dev/null || true
# Verify it's executable
if [ -x "$SCRIPT_PATH" ]; then
echo "✅ Downloaded cyberpanel.sh from standard source"
# Change to temp directory and execute with bash
# Use absolute path to avoid any relative path issues
cd "$TEMP_DIR" || cd /tmp || cd /
bash "$SCRIPT_PATH" "$@"
exit $?
else
echo "⚠️ Warning: Could not make script executable, trying alternative method..."
cd "$TEMP_DIR" || cd /tmp || cd /
bash -c "bash '$SCRIPT_PATH' $*"
exit $?
fi
fi
fi
# If we get here, download failed
echo "❌ Failed to download cyberpanel.sh"
echo "Please check your internet connection and try again"
exit 1