From 734a8ed6e80a908000f5b6392517b283b0d98aa4 Mon Sep 17 00:00:00 2001 From: master3395 Date: Mon, 26 Jan 2026 21:09:29 +0100 Subject: [PATCH 1/9] Fix OS variable persistence - use eval with get_os_info in install_dependencies - Remove debug output that wasn't showing - Use eval with get_os_info() to properly capture OS variables - Add better error messages showing actual variable values - Ensure variables are properly exported before calling manage_dependencies --- install.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index 94be2eff8..9ba721b80 100644 --- a/install.sh +++ b/install.sh @@ -148,11 +148,13 @@ YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color -# Global variables -SERVER_OS="" -OS_FAMILY="" -PACKAGE_MANAGER="" -ARCHITECTURE="" +# Global variables (exported so they persist across function calls) +# Note: These are initialized as empty but will be set by detect_operating_system() +# We export them here so they're available to all functions +export SERVER_OS +export OS_FAMILY +export PACKAGE_MANAGER +export ARCHITECTURE BRANCH_NAME="" # Logging function @@ -246,15 +248,14 @@ detect_operating_system() { 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) + # Re-detect if they're not set, using get_os_info() to capture values 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 + # Use get_os_info() to properly capture the values + eval $(get_os_info) 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 @@ -266,10 +267,11 @@ install_dependencies() { # 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" + print_status "$RED" " SERVER_OS='$SERVER_OS', OS_FAMILY='$OS_FAMILY', PACKAGE_MANAGER='$PACKAGE_MANAGER'" return 1 fi - print_status "$BLUE" "Calling manage_dependencies with: SERVER_OS='$SERVER_OS', OS_FAMILY='$OS_FAMILY', PACKAGE_MANAGER='$PACKAGE_MANAGER'" + print_status "$BLUE" "Installing dependencies for $SERVER_OS ($OS_FAMILY) using $PACKAGE_MANAGER..." if manage_dependencies "$SERVER_OS" "$OS_FAMILY" "$PACKAGE_MANAGER"; then print_status "$GREEN" "✅ Dependencies installed successfully" From 19f1ca62cb881ee436ae232a67c3e2240c276713 Mon Sep 17 00:00:00 2001 From: master3395 Date: Mon, 26 Jan 2026 21:11:18 +0100 Subject: [PATCH 2/9] Always re-capture OS variables in install_dependencies to ensure they persist - Always call detect_os() and get_os_info() in install_dependencies() - This ensures variables are fresh and properly captured - Add confirmation message showing captured values - Fixes issue where variables were detected but empty when passed to manage_dependencies --- install.sh | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/install.sh b/install.sh index 9ba721b80..733e8d6bf 100644 --- a/install.sh +++ b/install.sh @@ -248,25 +248,21 @@ detect_operating_system() { install_dependencies() { print_status "$BLUE" "📦 Installing dependencies..." - # Ensure variables are set (they should be from detect_operating_system) - # Re-detect if they're not set, using get_os_info() to capture values - 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 - # Use get_os_info() to properly capture the values - eval $(get_os_info) - 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 + # Always re-capture OS variables using get_os_info() to ensure we have the latest values + # This is necessary because variables might not persist between function calls + if detect_os; then + # Use get_os_info() to properly capture the values from the module + eval $(get_os_info) + export SERVER_OS OS_FAMILY PACKAGE_MANAGER ARCHITECTURE + print_status "$GREEN" "✅ Captured OS info: 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 - # Verify variables one more time before calling + # Verify variables are set before calling manage_dependencies if [ -z "$SERVER_OS" ] || [ -z "$OS_FAMILY" ] || [ -z "$PACKAGE_MANAGER" ]; then - print_status "$RED" "❌ OS variables still not set after re-detection" + print_status "$RED" "❌ OS variables not set after detection" print_status "$RED" " SERVER_OS='$SERVER_OS', OS_FAMILY='$OS_FAMILY', PACKAGE_MANAGER='$PACKAGE_MANAGER'" return 1 fi From 87a38b5a1b20fa364923a558b85d630951475703 Mon Sep 17 00:00:00 2001 From: master3395 Date: Mon, 26 Jan 2026 21:13:02 +0100 Subject: [PATCH 3/9] Simplify install.sh to match stable branch approach - Remove complex modular architecture that was causing variable persistence issues - Use simple OS detection like stable branch - Download cyberpanel.sh directly for v2.5.5-dev branch - Add disk space checking (10GB minimum) - Support both yum and dnf for RHEL-based systems - Fallback to standard cyberpanel.sh if branch-specific download fails - Much simpler and more reliable approach --- install.sh | 565 +++++++++++------------------------------------------ 1 file changed, 119 insertions(+), 446 deletions(-) diff --git a/install.sh b/install.sh index 733e8d6bf..0ddc603cc 100644 --- a/install.sh +++ b/install.sh @@ -1,458 +1,131 @@ -#!/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 (exported so they persist across function calls) -# Note: These are initialized as empty but will be set by detect_operating_system() -# We export them here so they're available to all functions -export SERVER_OS -export OS_FAMILY -export PACKAGE_MANAGER -export 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..." - - # Always re-capture OS variables using get_os_info() to ensure we have the latest values - # This is necessary because variables might not persist between function calls - if detect_os; then - # Use get_os_info() to properly capture the values from the module - eval $(get_os_info) - export SERVER_OS OS_FAMILY PACKAGE_MANAGER ARCHITECTURE - print_status "$GREEN" "✅ Captured OS info: 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 - - # Verify variables are set before calling manage_dependencies - if [ -z "$SERVER_OS" ] || [ -z "$OS_FAMILY" ] || [ -z "$PACKAGE_MANAGER" ]; then - print_status "$RED" "❌ OS variables not set after detection" - print_status "$RED" " SERVER_OS='$SERVER_OS', OS_FAMILY='$OS_FAMILY', PACKAGE_MANAGER='$PACKAGE_MANAGER'" - return 1 - fi - - print_status "$BLUE" "Installing dependencies for $SERVER_OS ($OS_FAMILY) using $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" +rm -f cyberpanel.sh +rm -f install.tar.gz + +# 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 cyberpanel.sh "https://raw.githubusercontent.com/master3395/cyberpanel/$BRANCH_NAME/cyberpanel.sh" 2>/dev/null; then + if [ -f cyberpanel.sh ] && [ -s cyberpanel.sh ]; then + chmod +x cyberpanel.sh + echo "✅ Downloaded cyberpanel.sh from branch $BRANCH_NAME" + ./cyberpanel.sh "$@" + exit $? + fi + fi +fi + +# Fallback to standard cyberpanel.sh download +curl --silent -o cyberpanel.sh "https://cyberpanel.sh/?dl&$SERVER_OS" 2>/dev/null || \ +wget -q -O cyberpanel.sh "https://cyberpanel.sh/?dl&$SERVER_OS" 2>/dev/null + +if [ -f cyberpanel.sh ] && [ -s cyberpanel.sh ]; then + chmod +x cyberpanel.sh + ./cyberpanel.sh "$@" +else + echo "❌ Failed to download cyberpanel.sh" + echo "Please check your internet connection and try again" + exit 1 +fi From 6161081b9857376d7864dfabacc2b18047ab1cc0 Mon Sep 17 00:00:00 2001 From: master3395 Date: Mon, 26 Jan 2026 21:14:59 +0100 Subject: [PATCH 4/9] Fix permission denied error - use absolute path and exec for cyberpanel.sh - Use absolute path (/tmp/cyberpanel-96375.sh) instead of relative path - Use exec instead of ./ to execute the script - Ensures proper permissions and execution in process substitution context - Clean up script file after execution --- install.sh | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/install.sh b/install.sh index 0ddc603cc..96ff30cd5 100644 --- a/install.sh +++ b/install.sh @@ -101,31 +101,34 @@ check_disk_space # Download and execute cyberpanel.sh for the specified branch echo "Downloading CyberPanel installer for branch: $BRANCH_NAME" -rm -f cyberpanel.sh -rm -f install.tar.gz + +# Use absolute path for downloaded script +SCRIPT_PATH="/tmp/cyberpanel-$$.sh" +rm -f "$SCRIPT_PATH" cyberpanel.sh install.tar.gz # 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 cyberpanel.sh "https://raw.githubusercontent.com/master3395/cyberpanel/$BRANCH_NAME/cyberpanel.sh" 2>/dev/null; then - if [ -f cyberpanel.sh ] && [ -s cyberpanel.sh ]; then - chmod +x cyberpanel.sh + 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 + chmod +x "$SCRIPT_PATH" echo "✅ Downloaded cyberpanel.sh from branch $BRANCH_NAME" - ./cyberpanel.sh "$@" - exit $? + exec "$SCRIPT_PATH" "$@" fi fi fi # Fallback to standard cyberpanel.sh download -curl --silent -o cyberpanel.sh "https://cyberpanel.sh/?dl&$SERVER_OS" 2>/dev/null || \ -wget -q -O cyberpanel.sh "https://cyberpanel.sh/?dl&$SERVER_OS" 2>/dev/null - -if [ -f cyberpanel.sh ] && [ -s cyberpanel.sh ]; then - chmod +x cyberpanel.sh - ./cyberpanel.sh "$@" -else - echo "❌ Failed to download cyberpanel.sh" - echo "Please check your internet connection and try again" - exit 1 +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 + chmod +x "$SCRIPT_PATH" + echo "✅ Downloaded cyberpanel.sh from standard source" + exec "$SCRIPT_PATH" "$@" + 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 From 4b99e46bfd182780fda9fac503bd0a34744170ac Mon Sep 17 00:00:00 2001 From: master3395 Date: Mon, 26 Jan 2026 21:16:01 +0100 Subject: [PATCH 5/9] Use sh to execute cyberpanel.sh to avoid permission issues - Execute with 'sh' instead of relying on exec permissions - More reliable in process substitution context - Handles cases where chmod might not work properly --- install.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 96ff30cd5..d45668845 100644 --- a/install.sh +++ b/install.sh @@ -111,9 +111,10 @@ 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 - chmod +x "$SCRIPT_PATH" + chmod +x "$SCRIPT_PATH" 2>/dev/null || true echo "✅ Downloaded cyberpanel.sh from branch $BRANCH_NAME" - exec "$SCRIPT_PATH" "$@" + # Use sh to execute to avoid permission issues + exec sh "$SCRIPT_PATH" "$@" fi fi fi @@ -122,9 +123,10 @@ fi 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 - chmod +x "$SCRIPT_PATH" + chmod +x "$SCRIPT_PATH" 2>/dev/null || true echo "✅ Downloaded cyberpanel.sh from standard source" - exec "$SCRIPT_PATH" "$@" + # Use sh to execute to avoid permission issues + exec sh "$SCRIPT_PATH" "$@" fi fi From 5ee18f1cc3bfb127d761396e2de0db605924a5bf Mon Sep 17 00:00:00 2001 From: master3395 Date: Mon, 26 Jan 2026 21:17:34 +0100 Subject: [PATCH 6/9] Use bash instead of sh to execute cyberpanel.sh - cyberpanel.sh uses #!/bin/bash so should be executed with bash - Change to /tmp directory before execution to ensure writable location - Fixes permission issues when cyberpanel.sh tries to execute other scripts --- install.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index d45668845..5127590c9 100644 --- a/install.sh +++ b/install.sh @@ -113,8 +113,10 @@ if [ "$BRANCH_NAME" = "v2.5.5-dev" ] || [ "$BRANCH_NAME" = "stable" ]; then if [ -f "$SCRIPT_PATH" ] && [ -s "$SCRIPT_PATH" ]; then chmod +x "$SCRIPT_PATH" 2>/dev/null || true echo "✅ Downloaded cyberpanel.sh from branch $BRANCH_NAME" - # Use sh to execute to avoid permission issues - exec sh "$SCRIPT_PATH" "$@" + # Use bash to execute (cyberpanel.sh uses #!/bin/bash) + # Change to /tmp to ensure we're in a writable directory + cd /tmp + exec bash "$SCRIPT_PATH" "$@" fi fi fi @@ -125,8 +127,10 @@ if curl --silent -o "$SCRIPT_PATH" "https://cyberpanel.sh/?dl&$SERVER_OS" 2>/dev if [ -f "$SCRIPT_PATH" ] && [ -s "$SCRIPT_PATH" ]; then chmod +x "$SCRIPT_PATH" 2>/dev/null || true echo "✅ Downloaded cyberpanel.sh from standard source" - # Use sh to execute to avoid permission issues - exec sh "$SCRIPT_PATH" "$@" + # Use bash to execute (cyberpanel.sh uses #!/bin/bash) + # Change to /tmp to ensure we're in a writable directory + cd /tmp + exec bash "$SCRIPT_PATH" "$@" fi fi From a71c91b99af5020706ea2ec6ef0249f16335dca7 Mon Sep 17 00:00:00 2001 From: master3395 Date: Mon, 26 Jan 2026 21:22:18 +0100 Subject: [PATCH 7/9] Fix script execution: use bash without exec and ensure proper exit codes - Replace exec with direct bash execution followed by exit - This allows cyberpanel.sh to properly execute ./cyberpanel_installer.sh - Add fallback directories for cd command - Preserve exit codes from cyberpanel.sh execution --- install.sh | 54 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/install.sh b/install.sh index 5127590c9..4f7e0118d 100644 --- a/install.sh +++ b/install.sh @@ -102,21 +102,35 @@ 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 -SCRIPT_PATH="/tmp/cyberpanel-$$.sh" -rm -f "$SCRIPT_PATH" cyberpanel.sh install.tar.gz +# 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 - chmod +x "$SCRIPT_PATH" 2>/dev/null || true - echo "✅ Downloaded cyberpanel.sh from branch $BRANCH_NAME" - # Use bash to execute (cyberpanel.sh uses #!/bin/bash) - # Change to /tmp to ensure we're in a writable directory - cd /tmp - exec bash "$SCRIPT_PATH" "$@" + # 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 @@ -125,12 +139,22 @@ fi 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 - chmod +x "$SCRIPT_PATH" 2>/dev/null || true - echo "✅ Downloaded cyberpanel.sh from standard source" - # Use bash to execute (cyberpanel.sh uses #!/bin/bash) - # Change to /tmp to ensure we're in a writable directory - cd /tmp - exec bash "$SCRIPT_PATH" "$@" + # 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 From 4f323d7a8de10fb9b81d2141f2936c3d9ee4d6ea Mon Sep 17 00:00:00 2001 From: master3395 Date: Mon, 26 Jan 2026 21:27:16 +0100 Subject: [PATCH 8/9] Fix cyberpanel_installer.sh execution permission issues - Use bash to execute cyberpanel_installer.sh instead of relying on execute bit - Verify file exists before execution - Use absolute path to ensure correct file location - Improve chmod error handling with verification - Fixes 'Permission denied' error when cyberpanel.sh tries to execute installer --- cyberpanel.sh | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/cyberpanel.sh b/cyberpanel.sh index be7af7c01..da9a9462a 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -628,7 +628,11 @@ 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..." @@ -696,10 +700,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]} From c13d23ad58c8d1f0d753461ff34d9543333207a0 Mon Sep 17 00:00:00 2001 From: master3395 Date: Mon, 26 Jan 2026 21:30:49 +0100 Subject: [PATCH 9/9] Update cyberpanel.sh to use master3395 fork instead of usmannasir - Change installer URL from usmannasir/cyberpanel to master3395/cyberpanel - Update archive URL to use master3395 fork - This ensures our fixes (bash execution, permission handling) are used - Fixes issue where old version without fixes was being downloaded --- cyberpanel.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cyberpanel.sh b/cyberpanel.sh index da9a9462a..f5441b811 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -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 @@ -636,9 +637,9 @@ install_cyberpanel_direct() { # 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 @@ -655,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