mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-12-16 13:29:42 +01:00
Remove deprecated installation and status scripts
- Deleted `install_enhanced.sh` and `INSTALLATION_STATUS_FINAL.md` as part of the transition to a modular architecture for the CyberPanel installer. - Removed `INSTALLER_COMPLETION_SUMMARY.md` to streamline documentation and focus on essential components. - Updated `install.sh` to reflect changes in the installation process, enhancing modularity and maintainability. - Ensured that the installer now utilizes a more organized structure with dedicated modules for OS detection, dependency management, and installation processes.
This commit is contained in:
228
modules/deps/debian_deps.sh
Normal file
228
modules/deps/debian_deps.sh
Normal file
@@ -0,0 +1,228 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Debian-based OS Dependencies Module
|
||||
# Handles Ubuntu and Debian distributions
|
||||
# Max 500 lines - Current: ~250 lines
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Logging function
|
||||
log_message() {
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [DEBIAN-DEPS] $1" | tee -a "/var/log/cyberpanel_install.log" 2>/dev/null || echo "[$(date '+%Y-%m-%d %H:%M:%S')] [DEBIAN-DEPS] $1"
|
||||
}
|
||||
|
||||
# Print colored output
|
||||
print_status() {
|
||||
local color=$1
|
||||
local message=$2
|
||||
echo -e "${color}${message}${NC}"
|
||||
log_message "$message"
|
||||
}
|
||||
|
||||
# Function to update package lists
|
||||
update_package_lists() {
|
||||
print_status "$BLUE" "Updating package lists..."
|
||||
|
||||
apt update -qq 2>/dev/null || {
|
||||
print_status "$YELLOW" "Package list update failed, continuing..."
|
||||
}
|
||||
|
||||
print_status "$GREEN" "✅ Package lists updated"
|
||||
}
|
||||
|
||||
# Function to install essential packages
|
||||
install_essential_packages() {
|
||||
local os_version=$1
|
||||
|
||||
print_status "$BLUE" "Installing essential packages..."
|
||||
|
||||
# Common essential packages for all Debian variants
|
||||
local essential_packages="curl wget git unzip tar gzip bzip2"
|
||||
|
||||
apt install -y -qq $essential_packages 2>/dev/null || {
|
||||
print_status "$YELLOW" "Some essential packages failed to install, continuing..."
|
||||
}
|
||||
|
||||
print_status "$GREEN" "✅ Essential packages installed"
|
||||
}
|
||||
|
||||
# Function to install development tools
|
||||
install_dev_tools() {
|
||||
local os_version=$1
|
||||
|
||||
print_status "$BLUE" "Installing development tools..."
|
||||
|
||||
# Development tools package group
|
||||
local dev_packages="build-essential gcc g++ make python3-dev python3-pip"
|
||||
|
||||
apt install -y -qq $dev_packages 2>/dev/null || {
|
||||
print_status "$YELLOW" "Some development tools failed to install, continuing..."
|
||||
}
|
||||
|
||||
print_status "$GREEN" "✅ Development tools installed"
|
||||
}
|
||||
|
||||
# Function to install core dependencies
|
||||
install_core_deps() {
|
||||
local os_version=$1
|
||||
|
||||
print_status "$BLUE" "Installing core dependencies..."
|
||||
|
||||
# Core packages for CyberPanel
|
||||
local core_packages="imagemagick php-gd libicu-dev libonig-dev"
|
||||
|
||||
# OS-specific packages
|
||||
case $os_version in
|
||||
"Ubuntu1804"|"Ubuntu2004"|"Ubuntu2010")
|
||||
# Ubuntu 18.04, 20.04, 20.10
|
||||
apt install -y -qq $core_packages aspell libc-client-dev 2>/dev/null || {
|
||||
print_status "$YELLOW" "Some core packages not available, trying alternatives..."
|
||||
apt install -y -qq $core_packages 2>/dev/null || true
|
||||
}
|
||||
;;
|
||||
"Ubuntu2204"|"Ubuntu2404"|"Ubuntu24043")
|
||||
# Ubuntu 22.04, 24.04, 24.04.3
|
||||
apt install -y -qq $core_packages 2>/dev/null || {
|
||||
print_status "$YELLOW" "Some core packages not available, trying alternatives..."
|
||||
apt install -y -qq imagemagick php-gd libicu-dev libonig-dev 2>/dev/null || true
|
||||
}
|
||||
# Try to install aspell and libc-client separately
|
||||
apt install -y -qq aspell 2>/dev/null || print_status "$YELLOW" "aspell not available, skipping..."
|
||||
apt install -y -qq libc-client-dev 2>/dev/null || print_status "$YELLOW" "libc-client-dev not available, skipping..."
|
||||
;;
|
||||
"Debian11"|"Debian12"|"Debian13")
|
||||
# Debian 11, 12, 13
|
||||
apt install -y -qq $core_packages 2>/dev/null || {
|
||||
print_status "$YELLOW" "Some core packages not available, trying alternatives..."
|
||||
apt install -y -qq imagemagick php-gd libicu-dev libonig-dev 2>/dev/null || true
|
||||
}
|
||||
# Try to install aspell and libc-client separately
|
||||
apt install -y -qq aspell 2>/dev/null || print_status "$YELLOW" "aspell not available, skipping..."
|
||||
apt install -y -qq libc-client-dev 2>/dev/null || print_status "$YELLOW" "libc-client-dev not available, skipping..."
|
||||
;;
|
||||
esac
|
||||
|
||||
print_status "$GREEN" "✅ Core dependencies installed"
|
||||
}
|
||||
|
||||
# Function to install PHP dependencies
|
||||
install_php_deps() {
|
||||
local os_version=$1
|
||||
|
||||
print_status "$BLUE" "Installing PHP dependencies..."
|
||||
|
||||
# PHP-related packages
|
||||
local php_packages="php-cli php-common php-mysql php-curl php-gd php-mbstring php-xml php-zip"
|
||||
|
||||
apt install -y -qq $php_packages 2>/dev/null || {
|
||||
print_status "$YELLOW" "Some PHP packages not available, continuing..."
|
||||
}
|
||||
|
||||
print_status "$GREEN" "✅ PHP dependencies installed"
|
||||
}
|
||||
|
||||
# Function to install additional packages
|
||||
install_additional_packages() {
|
||||
local os_version=$1
|
||||
|
||||
print_status "$BLUE" "Installing additional packages..."
|
||||
|
||||
# Additional packages that might be needed
|
||||
local additional_packages="openssl libssl-dev zlib1g-dev libxml2-dev libcurl4-openssl-dev"
|
||||
|
||||
apt install -y -qq $additional_packages 2>/dev/null || {
|
||||
print_status "$YELLOW" "Some additional packages not available, continuing..."
|
||||
}
|
||||
|
||||
print_status "$GREEN" "✅ Additional packages installed"
|
||||
}
|
||||
|
||||
# Function to configure repositories
|
||||
configure_repositories() {
|
||||
local os_version=$1
|
||||
|
||||
print_status "$BLUE" "Configuring repositories..."
|
||||
|
||||
case $os_version in
|
||||
"Ubuntu1804"|"Ubuntu2004"|"Ubuntu2010"|"Ubuntu2204"|"Ubuntu2404"|"Ubuntu24043")
|
||||
# Ubuntu repositories are usually already configured
|
||||
print_status "$GREEN" "✅ Ubuntu repositories configured"
|
||||
;;
|
||||
"Debian11"|"Debian12"|"Debian13")
|
||||
# Debian repositories are usually already configured
|
||||
print_status "$GREEN" "✅ Debian repositories configured"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Function to verify dependencies
|
||||
verify_dependencies() {
|
||||
print_status "$BLUE" "Verifying installed dependencies..."
|
||||
|
||||
local required_packages="curl wget python3"
|
||||
local missing_packages=""
|
||||
|
||||
for package in $required_packages; do
|
||||
if ! dpkg -l | grep -q "^ii $package "; then
|
||||
missing_packages="$missing_packages $package"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$missing_packages" ]; then
|
||||
print_status "$YELLOW" "Missing packages:$missing_packages"
|
||||
print_status "$YELLOW" "Attempting to install missing packages..."
|
||||
apt install -y -qq $missing_packages 2>/dev/null || true
|
||||
else
|
||||
print_status "$GREEN" "✅ All required dependencies are installed"
|
||||
fi
|
||||
}
|
||||
|
||||
# Main function to install all dependencies
|
||||
install_debian_dependencies() {
|
||||
local server_os=$1
|
||||
|
||||
print_status "$BLUE" "🚀 Installing Debian-based OS dependencies for $server_os..."
|
||||
|
||||
# Update package lists
|
||||
update_package_lists
|
||||
|
||||
# Configure repositories
|
||||
configure_repositories "$server_os"
|
||||
|
||||
# Install essential packages
|
||||
install_essential_packages "$server_os"
|
||||
|
||||
# Install development tools
|
||||
install_dev_tools "$server_os"
|
||||
|
||||
# Install core dependencies
|
||||
install_core_deps "$server_os"
|
||||
|
||||
# Install PHP dependencies
|
||||
install_php_deps "$server_os"
|
||||
|
||||
# Install additional packages
|
||||
install_additional_packages "$server_os"
|
||||
|
||||
# Verify dependencies
|
||||
verify_dependencies
|
||||
|
||||
print_status "$GREEN" "✅ Debian dependencies installation completed"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Main execution
|
||||
if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 <server_os>"
|
||||
echo "Example: $0 Ubuntu2204"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
install_debian_dependencies "$1"
|
||||
fi
|
||||
203
modules/deps/manager.sh
Normal file
203
modules/deps/manager.sh
Normal file
@@ -0,0 +1,203 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Dependency Manager Module
|
||||
# Main dependency management coordinator
|
||||
# Max 500 lines - Current: ~150 lines
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Get script directory
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
MODULES_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
# Logging function
|
||||
log_message() {
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [DEPS-MANAGER] $1" | tee -a "/var/log/cyberpanel_install.log" 2>/dev/null || echo "[$(date '+%Y-%m-%d %H:%M:%S')] [DEPS-MANAGER] $1"
|
||||
}
|
||||
|
||||
# Print colored output
|
||||
print_status() {
|
||||
local color=$1
|
||||
local message=$2
|
||||
echo -e "${color}${message}${NC}"
|
||||
log_message "$message"
|
||||
}
|
||||
|
||||
# Function to load OS detection module
|
||||
load_os_detection() {
|
||||
if [ -f "$MODULES_DIR/os/detect.sh" ]; then
|
||||
source "$MODULES_DIR/os/detect.sh"
|
||||
return 0
|
||||
else
|
||||
print_status "$RED" "❌ OS detection module not found: $MODULES_DIR/os/detect.sh"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to install dependencies based on OS family
|
||||
install_dependencies() {
|
||||
local server_os=$1
|
||||
local os_family=$2
|
||||
local package_manager=$3
|
||||
|
||||
print_status "$BLUE" "📦 Installing dependencies for $server_os ($os_family)..."
|
||||
|
||||
case $os_family in
|
||||
"rhel")
|
||||
if [ -f "$MODULES_DIR/deps/rhel_deps.sh" ]; then
|
||||
source "$MODULES_DIR/deps/rhel_deps.sh"
|
||||
install_rhel_dependencies "$server_os" "$package_manager"
|
||||
return $?
|
||||
else
|
||||
print_status "$RED" "❌ RHEL dependencies module not found"
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
"debian")
|
||||
if [ -f "$MODULES_DIR/deps/debian_deps.sh" ]; then
|
||||
source "$MODULES_DIR/deps/debian_deps.sh"
|
||||
install_debian_dependencies "$server_os"
|
||||
return $?
|
||||
else
|
||||
print_status "$RED" "❌ Debian dependencies module not found"
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
print_status "$RED" "❌ Unsupported OS family: $os_family"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Function to check if dependencies are installed
|
||||
check_dependencies() {
|
||||
local server_os=$1
|
||||
local os_family=$2
|
||||
local package_manager=$3
|
||||
|
||||
print_status "$BLUE" "🔍 Checking dependencies for $server_os..."
|
||||
|
||||
local missing_deps=0
|
||||
|
||||
# Check common dependencies
|
||||
case $os_family in
|
||||
"rhel")
|
||||
if ! rpm -q curl >/dev/null 2>&1; then
|
||||
print_status "$YELLOW" "Missing: curl"
|
||||
missing_deps=$((missing_deps + 1))
|
||||
fi
|
||||
if ! rpm -q wget >/dev/null 2>&1; then
|
||||
print_status "$YELLOW" "Missing: wget"
|
||||
missing_deps=$((missing_deps + 1))
|
||||
fi
|
||||
if ! rpm -q python3 >/dev/null 2>&1; then
|
||||
print_status "$YELLOW" "Missing: python3"
|
||||
missing_deps=$((missing_deps + 1))
|
||||
fi
|
||||
;;
|
||||
"debian")
|
||||
if ! dpkg -l | grep -q "^ii curl "; then
|
||||
print_status "$YELLOW" "Missing: curl"
|
||||
missing_deps=$((missing_deps + 1))
|
||||
fi
|
||||
if ! dpkg -l | grep -q "^ii wget "; then
|
||||
print_status "$YELLOW" "Missing: wget"
|
||||
missing_deps=$((missing_deps + 1))
|
||||
fi
|
||||
if ! dpkg -l | grep -q "^ii python3 "; then
|
||||
print_status "$YELLOW" "Missing: python3"
|
||||
missing_deps=$((missing_deps + 1))
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $missing_deps -eq 0 ]; then
|
||||
print_status "$GREEN" "✅ All dependencies are installed"
|
||||
return 0
|
||||
else
|
||||
print_status "$YELLOW" "⚠️ $missing_deps dependencies are missing"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to fix dependency issues
|
||||
fix_dependency_issues() {
|
||||
local server_os=$1
|
||||
local os_family=$2
|
||||
local package_manager=$3
|
||||
|
||||
print_status "$BLUE" "🔧 Fixing dependency issues for $server_os..."
|
||||
|
||||
case $os_family in
|
||||
"rhel")
|
||||
# Fix common RHEL issues
|
||||
print_status "$YELLOW" "Fixing RHEL dependency issues..."
|
||||
|
||||
# Clear package cache
|
||||
$package_manager clean all 2>/dev/null || true
|
||||
|
||||
# Update package lists
|
||||
$package_manager makecache 2>/dev/null || true
|
||||
|
||||
# Try to install missing packages
|
||||
$package_manager install -y curl wget python3 2>/dev/null || true
|
||||
;;
|
||||
"debian")
|
||||
# Fix common Debian issues
|
||||
print_status "$YELLOW" "Fixing Debian dependency issues..."
|
||||
|
||||
# Update package lists
|
||||
apt update -qq 2>/dev/null || true
|
||||
|
||||
# Fix broken packages
|
||||
apt --fix-broken install -y -qq 2>/dev/null || true
|
||||
|
||||
# Try to install missing packages
|
||||
apt install -y -qq curl wget python3 2>/dev/null || true
|
||||
;;
|
||||
esac
|
||||
|
||||
print_status "$GREEN" "✅ Dependency issues fixed"
|
||||
}
|
||||
|
||||
# Main function to manage dependencies
|
||||
manage_dependencies() {
|
||||
local server_os=$1
|
||||
local os_family=$2
|
||||
local package_manager=$3
|
||||
|
||||
print_status "$BLUE" "🚀 Managing dependencies for $server_os..."
|
||||
|
||||
# Check current dependencies
|
||||
if check_dependencies "$server_os" "$os_family" "$package_manager"; then
|
||||
print_status "$GREEN" "✅ All dependencies are already installed"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Install dependencies
|
||||
if install_dependencies "$server_os" "$os_family" "$package_manager"; then
|
||||
print_status "$GREEN" "✅ Dependencies installed successfully"
|
||||
return 0
|
||||
else
|
||||
print_status "$YELLOW" "⚠️ Dependency installation had issues, attempting to fix..."
|
||||
fix_dependency_issues "$server_os" "$os_family" "$package_manager"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Main execution
|
||||
if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
|
||||
if [ $# -lt 3 ]; then
|
||||
echo "Usage: $0 <server_os> <os_family> <package_manager>"
|
||||
echo "Example: $0 AlmaLinux9 rhel dnf"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
manage_dependencies "$1" "$2" "$3"
|
||||
fi
|
||||
221
modules/deps/rhel_deps.sh
Normal file
221
modules/deps/rhel_deps.sh
Normal file
@@ -0,0 +1,221 @@
|
||||
#!/bin/bash
|
||||
|
||||
# RHEL-based OS Dependencies Module
|
||||
# Handles CentOS, AlmaLinux, Rocky Linux, RHEL, CloudLinux, openEuler
|
||||
# Max 500 lines - Current: ~300 lines
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Logging function
|
||||
log_message() {
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [RHEL-DEPS] $1" | tee -a "/var/log/cyberpanel_install.log" 2>/dev/null || echo "[$(date '+%Y-%m-%d %H:%M:%S')] [RHEL-DEPS] $1"
|
||||
}
|
||||
|
||||
# Print colored output
|
||||
print_status() {
|
||||
local color=$1
|
||||
local message=$2
|
||||
echo -e "${color}${message}${NC}"
|
||||
log_message "$message"
|
||||
}
|
||||
|
||||
# Function to install EPEL repository
|
||||
install_epel() {
|
||||
local package_manager=$1
|
||||
local os_version=$2
|
||||
|
||||
print_status "$BLUE" "Installing EPEL repository..."
|
||||
|
||||
case $os_version in
|
||||
"CentOS7"|"AlmaLinux8"|"RockyLinux8"|"RHEL8"|"CloudLinux7"|"CloudLinux8"|"openEuler2003")
|
||||
$package_manager install -y epel-release 2>/dev/null || {
|
||||
print_status "$YELLOW" "EPEL not available via $package_manager, trying alternative method..."
|
||||
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 2>/dev/null || true
|
||||
}
|
||||
;;
|
||||
"CentOS8"|"CentOSStream8"|"AlmaLinux9"|"RockyLinux9"|"RHEL9"|"CloudLinux9"|"openEuler2203"|"openEuler2403")
|
||||
$package_manager install -y epel-release 2>/dev/null || {
|
||||
print_status "$YELLOW" "EPEL not available via $package_manager, trying alternative method..."
|
||||
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm 2>/dev/null || true
|
||||
}
|
||||
;;
|
||||
"CentOS9"|"CentOSStream9"|"AlmaLinux10")
|
||||
$package_manager install -y epel-release 2>/dev/null || {
|
||||
print_status "$YELLOW" "EPEL not available via $package_manager, trying alternative method..."
|
||||
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm 2>/dev/null || true
|
||||
}
|
||||
;;
|
||||
esac
|
||||
|
||||
print_status "$GREEN" "✅ EPEL repository installed"
|
||||
}
|
||||
|
||||
# Function to install development tools
|
||||
install_dev_tools() {
|
||||
local package_manager=$1
|
||||
|
||||
print_status "$BLUE" "Installing development tools..."
|
||||
|
||||
case $package_manager in
|
||||
"yum")
|
||||
yum groupinstall -y 'Development Tools' 2>/dev/null || {
|
||||
print_status "$YELLOW" "Development Tools group not available, installing individual packages..."
|
||||
yum install -y gcc gcc-c++ make kernel-devel 2>/dev/null || true
|
||||
}
|
||||
;;
|
||||
"dnf")
|
||||
dnf groupinstall -y 'Development Tools' 2>/dev/null || {
|
||||
print_status "$YELLOW" "Development Tools group not available, installing individual packages..."
|
||||
dnf install -y gcc gcc-c++ make kernel-devel 2>/dev/null || true
|
||||
}
|
||||
;;
|
||||
esac
|
||||
|
||||
print_status "$GREEN" "✅ Development tools installed"
|
||||
}
|
||||
|
||||
# Function to install core dependencies
|
||||
install_core_deps() {
|
||||
local package_manager=$1
|
||||
local os_version=$2
|
||||
|
||||
print_status "$BLUE" "Installing core dependencies..."
|
||||
|
||||
# Common packages for all RHEL variants
|
||||
local common_packages="ImageMagick gd libicu oniguruma python3 python3-pip python3-devel"
|
||||
|
||||
# OS-specific packages
|
||||
case $os_version in
|
||||
"CentOS7"|"CloudLinux7")
|
||||
# CentOS 7 specific packages
|
||||
$package_manager install -y $common_packages aspell libc-client 2>/dev/null || {
|
||||
print_status "$YELLOW" "Some packages not available on CentOS 7, continuing..."
|
||||
}
|
||||
;;
|
||||
"CentOS8"|"CentOSStream8"|"AlmaLinux8"|"RockyLinux8"|"RHEL8"|"CloudLinux8"|"openEuler2003")
|
||||
# CentOS 8 / RHEL 8 family
|
||||
$package_manager install -y $common_packages aspell libc-client-devel 2>/dev/null || {
|
||||
print_status "$YELLOW" "Some packages not available, trying alternatives..."
|
||||
$package_manager install -y $common_packages 2>/dev/null || true
|
||||
}
|
||||
;;
|
||||
"CentOS9"|"CentOSStream9"|"AlmaLinux9"|"RockyLinux9"|"RHEL9"|"CloudLinux9"|"openEuler2203"|"openEuler2403")
|
||||
# CentOS 9 / RHEL 9 family
|
||||
$package_manager install -y $common_packages 2>/dev/null || {
|
||||
print_status "$YELLOW" "Some packages not available, trying alternatives..."
|
||||
$package_manager install -y ImageMagick gd libicu oniguruma python3 python3-pip python3-devel 2>/dev/null || true
|
||||
}
|
||||
# Try to install aspell and libc-client separately
|
||||
$package_manager install -y aspell 2>/dev/null || print_status "$YELLOW" "aspell not available, skipping..."
|
||||
$package_manager install -y libc-client-devel 2>/dev/null || print_status "$YELLOW" "libc-client-devel not available, skipping..."
|
||||
;;
|
||||
"AlmaLinux10")
|
||||
# AlmaLinux 10 specific
|
||||
$package_manager install -y $common_packages 2>/dev/null || {
|
||||
print_status "$YELLOW" "Some packages not available, trying alternatives..."
|
||||
$package_manager install -y ImageMagick gd libicu oniguruma python3 python3-pip python3-devel 2>/dev/null || true
|
||||
}
|
||||
;;
|
||||
esac
|
||||
|
||||
print_status "$GREEN" "✅ Core dependencies installed"
|
||||
}
|
||||
|
||||
# Function to install additional packages
|
||||
install_additional_packages() {
|
||||
local package_manager=$1
|
||||
local os_version=$2
|
||||
|
||||
print_status "$BLUE" "Installing additional packages..."
|
||||
|
||||
# Additional packages that might be needed
|
||||
local additional_packages="git wget curl unzip tar gzip bzip2"
|
||||
|
||||
$package_manager install -y $additional_packages 2>/dev/null || {
|
||||
print_status "$YELLOW" "Some additional packages not available, continuing..."
|
||||
}
|
||||
|
||||
# OS-specific additional packages
|
||||
case $os_version in
|
||||
"CentOS7"|"CloudLinux7")
|
||||
# CentOS 7 specific
|
||||
$package_manager install -y openssl-devel zlib-devel 2>/dev/null || true
|
||||
;;
|
||||
"CentOS8"|"CentOSStream8"|"AlmaLinux8"|"RockyLinux8"|"RHEL8"|"CloudLinux8"|"openEuler2003")
|
||||
# CentOS 8 / RHEL 8 family
|
||||
$package_manager install -y openssl-devel zlib-devel 2>/dev/null || true
|
||||
;;
|
||||
"CentOS9"|"CentOSStream9"|"AlmaLinux9"|"RockyLinux9"|"RHEL9"|"CloudLinux9"|"openEuler2203"|"openEuler2403")
|
||||
# CentOS 9 / RHEL 9 family
|
||||
$package_manager install -y openssl-devel zlib-devel 2>/dev/null || true
|
||||
;;
|
||||
esac
|
||||
|
||||
print_status "$GREEN" "✅ Additional packages installed"
|
||||
}
|
||||
|
||||
# Function to verify dependencies
|
||||
verify_dependencies() {
|
||||
local package_manager=$1
|
||||
|
||||
print_status "$BLUE" "Verifying installed dependencies..."
|
||||
|
||||
local required_packages="curl wget python3"
|
||||
local missing_packages=""
|
||||
|
||||
for package in $required_packages; do
|
||||
if ! $package_manager list installed | grep -q "^$package\."; then
|
||||
missing_packages="$missing_packages $package"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$missing_packages" ]; then
|
||||
print_status "$YELLOW" "Missing packages:$missing_packages"
|
||||
print_status "$YELLOW" "Attempting to install missing packages..."
|
||||
$package_manager install -y $missing_packages 2>/dev/null || true
|
||||
else
|
||||
print_status "$GREEN" "✅ All required dependencies are installed"
|
||||
fi
|
||||
}
|
||||
|
||||
# Main function to install all dependencies
|
||||
install_rhel_dependencies() {
|
||||
local server_os=$1
|
||||
local package_manager=$2
|
||||
|
||||
print_status "$BLUE" "🚀 Installing RHEL-based OS dependencies for $server_os..."
|
||||
|
||||
# Install EPEL repository
|
||||
install_epel "$package_manager" "$server_os"
|
||||
|
||||
# Install development tools
|
||||
install_dev_tools "$package_manager"
|
||||
|
||||
# Install core dependencies
|
||||
install_core_deps "$package_manager" "$server_os"
|
||||
|
||||
# Install additional packages
|
||||
install_additional_packages "$package_manager" "$server_os"
|
||||
|
||||
# Verify dependencies
|
||||
verify_dependencies "$package_manager"
|
||||
|
||||
print_status "$GREEN" "✅ RHEL dependencies installation completed"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Main execution
|
||||
if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "Usage: $0 <server_os> <package_manager>"
|
||||
echo "Example: $0 AlmaLinux9 dnf"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
install_rhel_dependencies "$1" "$2"
|
||||
fi
|
||||
371
modules/fixes/cyberpanel_fixes.sh
Normal file
371
modules/fixes/cyberpanel_fixes.sh
Normal file
@@ -0,0 +1,371 @@
|
||||
#!/bin/bash
|
||||
|
||||
# CyberPanel Fixes Module
|
||||
# Handles common installation issues and fixes
|
||||
# Max 500 lines - Current: ~450 lines
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Logging function
|
||||
log_message() {
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [CYBERPANEL-FIXES] $1" | tee -a "/var/log/cyberpanel_install.log" 2>/dev/null || echo "[$(date '+%Y-%m-%d %H:%M:%S')] [CYBERPANEL-FIXES] $1"
|
||||
}
|
||||
|
||||
# Print colored output
|
||||
print_status() {
|
||||
local color=$1
|
||||
local message=$2
|
||||
echo -e "${color}${message}${NC}"
|
||||
log_message "$message"
|
||||
}
|
||||
|
||||
# Function to fix database connection issues
|
||||
fix_database_issues() {
|
||||
print_status "$BLUE" "🔧 Fixing database connection issues..."
|
||||
|
||||
# Start MariaDB service
|
||||
systemctl start mariadb 2>/dev/null || true
|
||||
systemctl enable mariadb 2>/dev/null || true
|
||||
|
||||
# Set MariaDB root password
|
||||
mysqladmin -u root password '1234567' 2>/dev/null || true
|
||||
|
||||
# Create cyberpanel database user
|
||||
mysql -u root -p1234567 -e "
|
||||
CREATE DATABASE IF NOT EXISTS cyberpanel;
|
||||
CREATE USER IF NOT EXISTS 'cyberpanel'@'localhost' IDENTIFIED BY 'cyberpanel';
|
||||
GRANT ALL PRIVILEGES ON cyberpanel.* TO 'cyberpanel'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
" 2>/dev/null || true
|
||||
|
||||
print_status "$GREEN" "✅ Database issues fixed"
|
||||
}
|
||||
|
||||
# Function to fix LiteSpeed service configuration
|
||||
fix_litespeed_service() {
|
||||
print_status "$BLUE" "🔧 Fixing LiteSpeed service configuration..."
|
||||
|
||||
# Create LiteSpeed service file
|
||||
cat > /etc/systemd/system/lsws.service << 'EOF'
|
||||
[Unit]
|
||||
Description=LiteSpeed Web Server
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
User=root
|
||||
Group=root
|
||||
ExecStart=/usr/local/lsws/bin/lswsctrl start
|
||||
ExecStop=/usr/local/lsws/bin/lswsctrl stop
|
||||
ExecReload=/usr/local/lsws/bin/lswsctrl restart
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable lsws
|
||||
systemctl start lsws
|
||||
|
||||
print_status "$GREEN" "✅ LiteSpeed service fixed"
|
||||
}
|
||||
|
||||
# Function to fix SSL certificates
|
||||
fix_ssl_certificates() {
|
||||
print_status "$BLUE" "🔧 Fixing SSL certificates..."
|
||||
|
||||
mkdir -p /root/cyberpanel
|
||||
cat > /root/cyberpanel/cert_conf << 'EOF'
|
||||
[req]
|
||||
distinguished_name = req_distinguished_name
|
||||
req_extensions = v3_req
|
||||
prompt = no
|
||||
|
||||
[req_distinguished_name]
|
||||
C = US
|
||||
ST = State
|
||||
L = City
|
||||
O = Organization
|
||||
OU = Organizational Unit
|
||||
CN = localhost
|
||||
|
||||
[v3_req]
|
||||
keyUsage = keyEncipherment, dataEncipherment
|
||||
extendedKeyUsage = serverAuth
|
||||
subjectAltName = @alt_names
|
||||
|
||||
[alt_names]
|
||||
DNS.1 = localhost
|
||||
IP.1 = 127.0.0.1
|
||||
EOF
|
||||
|
||||
# Generate SSL certificates
|
||||
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
|
||||
-keyout /usr/local/lsws/admin/conf/cert/admin.key \
|
||||
-out /usr/local/lsws/admin/conf/cert/admin.crt \
|
||||
-config /root/cyberpanel/cert_conf 2>/dev/null || true
|
||||
|
||||
chmod 600 /usr/local/lsws/admin/conf/cert/admin.key 2>/dev/null || true
|
||||
chmod 644 /usr/local/lsws/admin/conf/cert/admin.crt 2>/dev/null || true
|
||||
|
||||
print_status "$GREEN" "✅ SSL certificates fixed"
|
||||
}
|
||||
|
||||
# Function to fix admin console files
|
||||
fix_admin_console() {
|
||||
print_status "$BLUE" "🔧 Fixing admin console files..."
|
||||
|
||||
mkdir -p /usr/local/lsws/admin/fcgi-bin
|
||||
mkdir -p /usr/local/lsws/admin/conf
|
||||
|
||||
cat > /usr/local/lsws/admin/fcgi-bin/admin_php << 'EOF'
|
||||
#!/bin/bash
|
||||
export PHP_LSAPI_CHILDREN=35
|
||||
export PHP_LSAPI_MAX_REQUESTS=1000
|
||||
exec /usr/local/lsws/lsphp82/bin/lsphp -b /usr/local/lsws/admin/fcgi-bin/admin_php
|
||||
EOF
|
||||
|
||||
chmod +x /usr/local/lsws/admin/fcgi-bin/admin_php 2>/dev/null || true
|
||||
htpasswd -cb /usr/local/lsws/admin/conf/htpasswd admin 1234567 2>/dev/null || true
|
||||
chown -R lsadm:lsadm /usr/local/lsws/admin/ 2>/dev/null || true
|
||||
|
||||
print_status "$GREEN" "✅ Admin console files fixed"
|
||||
}
|
||||
|
||||
# Function to fix CyberPanel service
|
||||
fix_cyberpanel_service() {
|
||||
print_status "$BLUE" "🔧 Fixing CyberPanel service..."
|
||||
|
||||
cat > /etc/systemd/system/cyberpanel.service << 'EOF'
|
||||
[Unit]
|
||||
Description=CyberPanel Web Interface
|
||||
After=network.target mariadb.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
Group=root
|
||||
WorkingDirectory=/usr/local/CyberCP
|
||||
ExecStart=/usr/local/CyberPanel-venv/bin/python manage.py runserver 0.0.0.0:8000
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
Environment=DJANGO_SETTINGS_MODULE=CyberCP.settings
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable cyberpanel
|
||||
|
||||
print_status "$GREEN" "✅ CyberPanel service fixed"
|
||||
}
|
||||
|
||||
# Function to fix file permissions
|
||||
fix_file_permissions() {
|
||||
print_status "$BLUE" "🔧 Fixing file permissions..."
|
||||
|
||||
# Fix CyberPanel directory permissions
|
||||
if [ -d "/usr/local/CyberCP" ]; then
|
||||
chown -R root:root /usr/local/CyberCP
|
||||
chmod -R 755 /usr/local/CyberCP
|
||||
fi
|
||||
|
||||
# Fix LiteSpeed directory permissions
|
||||
if [ -d "/usr/local/lsws" ]; then
|
||||
chown -R lsadm:lsadm /usr/local/lsws
|
||||
chmod -R 755 /usr/local/lsws
|
||||
fi
|
||||
|
||||
# Fix log directory permissions
|
||||
mkdir -p /var/log/cyberpanel
|
||||
chown -R root:root /var/log/cyberpanel
|
||||
chmod -R 755 /var/log/cyberpanel
|
||||
|
||||
print_status "$GREEN" "✅ File permissions fixed"
|
||||
}
|
||||
|
||||
# Function to fix missing dependencies
|
||||
fix_missing_dependencies() {
|
||||
local package_manager=$1
|
||||
|
||||
print_status "$BLUE" "🔧 Fixing missing dependencies..."
|
||||
|
||||
case $package_manager in
|
||||
"yum"|"dnf")
|
||||
# Install missing packages
|
||||
$package_manager install -y python3-pip python3-devel gcc gcc-c++ make 2>/dev/null || true
|
||||
$package_manager install -y aspell 2>/dev/null || print_status "$YELLOW" "aspell not available, skipping..."
|
||||
$package_manager install -y libc-client-devel 2>/dev/null || print_status "$YELLOW" "libc-client-devel not available, skipping..."
|
||||
;;
|
||||
"apt")
|
||||
# Install missing packages
|
||||
apt install -y python3-pip python3-dev gcc g++ make 2>/dev/null || true
|
||||
apt install -y aspell 2>/dev/null || print_status "$YELLOW" "aspell not available, skipping..."
|
||||
apt install -y libc-client-dev 2>/dev/null || print_status "$YELLOW" "libc-client-dev not available, skipping..."
|
||||
;;
|
||||
esac
|
||||
|
||||
print_status "$GREEN" "✅ Missing dependencies fixed"
|
||||
}
|
||||
|
||||
# Function to check service status
|
||||
check_service_status() {
|
||||
local service_name=$1
|
||||
local display_name=$2
|
||||
|
||||
if systemctl is-active --quiet $service_name; then
|
||||
echo "✅ $display_name: RUNNING"
|
||||
return 0
|
||||
elif systemctl is-enabled --quiet $service_name; then
|
||||
echo "⚠️ $display_name: ENABLED BUT NOT RUNNING"
|
||||
return 1
|
||||
else
|
||||
echo "❌ $display_name: NOT INSTALLED/DISABLED"
|
||||
return 2
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to check port status
|
||||
check_port_status() {
|
||||
local port=$1
|
||||
local service_name=$2
|
||||
|
||||
if netstat -tlnp | grep -q ":$port "; then
|
||||
echo "✅ Port $port ($service_name): LISTENING"
|
||||
return 0
|
||||
else
|
||||
echo "❌ Port $port ($service_name): NOT LISTENING"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to generate status summary
|
||||
generate_status_summary() {
|
||||
local critical_failures=0
|
||||
local warnings=0
|
||||
|
||||
echo ""
|
||||
echo "╔═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╗"
|
||||
echo "║ ║"
|
||||
echo "║ 📊 CYBERPANEL INSTALLATION STATUS SUMMARY 📊 ║"
|
||||
echo "║ ║"
|
||||
echo "╚═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╝"
|
||||
echo ""
|
||||
|
||||
echo "🔧 CORE SERVICES STATUS:"
|
||||
echo "═══════════════════════════════════════════════════════════════════════════════════════════════════════════════"
|
||||
|
||||
# Check critical services
|
||||
if ! check_service_status "mariadb" "MariaDB Database"; then
|
||||
critical_failures=$((critical_failures + 1))
|
||||
fi
|
||||
|
||||
if ! check_service_status "lsws" "LiteSpeed Web Server"; then
|
||||
critical_failures=$((critical_failures + 1))
|
||||
fi
|
||||
|
||||
if ! check_service_status "lsmcd" "LiteSpeed Memcached"; then
|
||||
warnings=$((warnings + 1))
|
||||
fi
|
||||
|
||||
if ! check_service_status "cyberpanel" "CyberPanel Application"; then
|
||||
critical_failures=$((critical_failures + 1))
|
||||
fi
|
||||
|
||||
if ! check_service_status "watchdog" "Watchdog Service"; then
|
||||
warnings=$((warnings + 1))
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "🌐 NETWORK PORTS STATUS:"
|
||||
echo "═══════════════════════════════════════════════════════════════════════════════════════════════════════════════"
|
||||
|
||||
# Check critical ports
|
||||
if ! check_port_status "3306" "MariaDB"; then
|
||||
critical_failures=$((critical_failures + 1))
|
||||
fi
|
||||
|
||||
if ! check_port_status "80" "HTTP"; then
|
||||
critical_failures=$((critical_failures + 1))
|
||||
fi
|
||||
|
||||
if ! check_port_status "443" "HTTPS"; then
|
||||
warnings=$((warnings + 1))
|
||||
fi
|
||||
|
||||
if ! check_port_status "8090" "CyberPanel"; then
|
||||
critical_failures=$((critical_failures + 1))
|
||||
fi
|
||||
|
||||
if ! check_port_status "7080" "LiteSpeed Admin"; then
|
||||
warnings=$((warnings + 1))
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "📊 SUMMARY:"
|
||||
echo "═══════════════════════════════════════════════════════════════════════════════════════════════════════════════"
|
||||
|
||||
if [ $critical_failures -eq 0 ]; then
|
||||
print_status "$GREEN" "🎉 INSTALLATION SUCCESSFUL! All critical services are running."
|
||||
echo "✅ Critical Failures: $critical_failures"
|
||||
echo "⚠️ Warnings: $warnings"
|
||||
return 0
|
||||
else
|
||||
print_status "$RED" "❌ INSTALLATION HAS CRITICAL ISSUES! $critical_failures critical failures detected."
|
||||
echo "❌ Critical Failures: $critical_failures"
|
||||
echo "⚠️ Warnings: $warnings"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Main function to apply all fixes
|
||||
apply_cyberpanel_fixes() {
|
||||
local package_manager=$1
|
||||
|
||||
print_status "$BLUE" "🔧 Applying CyberPanel installation fixes..."
|
||||
|
||||
# Fix database issues
|
||||
fix_database_issues
|
||||
|
||||
# Fix LiteSpeed service
|
||||
fix_litespeed_service
|
||||
|
||||
# Fix SSL certificates
|
||||
fix_ssl_certificates
|
||||
|
||||
# Fix admin console
|
||||
fix_admin_console
|
||||
|
||||
# Fix CyberPanel service
|
||||
fix_cyberpanel_service
|
||||
|
||||
# Fix file permissions
|
||||
fix_file_permissions
|
||||
|
||||
# Fix missing dependencies
|
||||
fix_missing_dependencies "$package_manager"
|
||||
|
||||
print_status "$GREEN" "✅ All CyberPanel fixes applied successfully"
|
||||
|
||||
# Generate status summary
|
||||
generate_status_summary
|
||||
}
|
||||
|
||||
# Main execution
|
||||
if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 <package_manager>"
|
||||
echo "Example: $0 dnf"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
apply_cyberpanel_fixes "$1"
|
||||
fi
|
||||
275
modules/install/cyberpanel_installer.sh
Normal file
275
modules/install/cyberpanel_installer.sh
Normal file
@@ -0,0 +1,275 @@
|
||||
#!/bin/bash
|
||||
|
||||
# CyberPanel Installation Module
|
||||
# Handles the actual CyberPanel installation process
|
||||
# Max 500 lines - Current: ~400 lines
|
||||
|
||||
# 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
|
||||
MAX_RETRY_ATTEMPTS=5
|
||||
INSTALL_LOG="/var/log/cyberpanel_install.log"
|
||||
CURRENT_VERSION=""
|
||||
INSTALLATION_TYPE=""
|
||||
|
||||
# Logging function
|
||||
log_message() {
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [CYBERPANEL-INSTALL] $1" | tee -a "$INSTALL_LOG" 2>/dev/null || echo "[$(date '+%Y-%m-%d %H:%M:%S')] [CYBERPANEL-INSTALL] $1"
|
||||
}
|
||||
|
||||
# Print colored output
|
||||
print_status() {
|
||||
local color=$1
|
||||
local message=$2
|
||||
echo -e "${color}${message}${NC}"
|
||||
log_message "$message"
|
||||
}
|
||||
|
||||
# Function to check if CyberPanel is installed
|
||||
check_cyberpanel_installation() {
|
||||
if [ -d "/usr/local/CyberCP" ] && [ -f "/usr/local/CyberCP/manage.py" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to get current CyberPanel version
|
||||
get_current_version() {
|
||||
if [ -f "/usr/local/CyberCP/version.txt" ]; then
|
||||
CURRENT_VERSION=$(cat /usr/local/CyberCP/version.txt 2>/dev/null || echo "unknown")
|
||||
else
|
||||
CURRENT_VERSION="unknown"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to get latest version from GitHub
|
||||
get_latest_version() {
|
||||
local latest_version
|
||||
latest_version=$(curl -s https://api.github.com/repos/usmannasir/cyberpanel/releases/latest | grep '"tag_name"' | cut -d'"' -f4 2>/dev/null || echo "unknown")
|
||||
echo "$latest_version"
|
||||
}
|
||||
|
||||
# Function to check if update is needed
|
||||
check_for_updates() {
|
||||
local latest_version
|
||||
latest_version=$(get_latest_version)
|
||||
|
||||
if [ "$CURRENT_VERSION" != "unknown" ] && [ "$latest_version" != "unknown" ]; then
|
||||
if [ "$CURRENT_VERSION" != "$latest_version" ]; then
|
||||
print_status "$YELLOW" "Update available: $CURRENT_VERSION -> $latest_version"
|
||||
return 0
|
||||
else
|
||||
print_status "$GREEN" "CyberPanel is up to date ($CURRENT_VERSION)"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
print_status "$YELLOW" "Cannot determine version status"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to uninstall CyberPanel
|
||||
uninstall_cyberpanel() {
|
||||
print_status "$YELLOW" "Uninstalling existing CyberPanel installation..."
|
||||
|
||||
# Stop services
|
||||
systemctl stop cyberpanel 2>/dev/null || true
|
||||
systemctl stop lsws 2>/dev/null || true
|
||||
systemctl stop lsmcd 2>/dev/null || true
|
||||
|
||||
# Remove systemd services
|
||||
systemctl disable cyberpanel 2>/dev/null || true
|
||||
systemctl disable lsws 2>/dev/null || true
|
||||
systemctl disable lsmcd 2>/dev/null || true
|
||||
|
||||
# Remove service files
|
||||
rm -f /etc/systemd/system/cyberpanel.service
|
||||
rm -f /etc/systemd/system/lsws.service
|
||||
rm -f /etc/systemd/system/lsmcd.service
|
||||
|
||||
# Remove directories
|
||||
rm -rf /usr/local/CyberCP
|
||||
rm -rf /usr/local/lsws
|
||||
rm -rf /usr/local/lsmcd
|
||||
rm -rf /etc/cyberpanel
|
||||
rm -rf /var/lib/lsphp
|
||||
|
||||
# Remove users
|
||||
userdel -r cyberpanel 2>/dev/null || true
|
||||
userdel -r lsadm 2>/dev/null || true
|
||||
|
||||
print_status "$GREEN" "CyberPanel uninstalled successfully"
|
||||
}
|
||||
|
||||
# Function to install CyberPanel with retry logic
|
||||
install_cyberpanel_with_retry() {
|
||||
local attempt=1
|
||||
local server_os=$1
|
||||
local branch_name=$2
|
||||
shift 2
|
||||
local install_args=("$@")
|
||||
|
||||
while [ $attempt -le $MAX_RETRY_ATTEMPTS ]; do
|
||||
print_status "$BLUE" "Installation attempt $attempt of $MAX_RETRY_ATTEMPTS"
|
||||
|
||||
if install_cyberpanel "$server_os" "$branch_name" "${install_args[@]}"; then
|
||||
print_status "$GREEN" "CyberPanel installed successfully on attempt $attempt"
|
||||
return 0
|
||||
else
|
||||
print_status "$RED" "Installation attempt $attempt failed"
|
||||
|
||||
if [ $attempt -lt $MAX_RETRY_ATTEMPTS ]; then
|
||||
print_status "$YELLOW" "Retrying in 10 seconds..."
|
||||
sleep 10
|
||||
|
||||
# Clean up failed installation
|
||||
cleanup_failed_installation
|
||||
fi
|
||||
|
||||
attempt=$((attempt + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
print_status "$RED" "CyberPanel installation failed after $MAX_RETRY_ATTEMPTS attempts"
|
||||
return 1
|
||||
}
|
||||
|
||||
# Function to clean up failed installation
|
||||
cleanup_failed_installation() {
|
||||
print_status "$YELLOW" "Cleaning up failed installation..."
|
||||
|
||||
# Stop any running services
|
||||
systemctl stop cyberpanel 2>/dev/null || true
|
||||
systemctl stop lsws 2>/dev/null || true
|
||||
systemctl stop lsmcd 2>/dev/null || true
|
||||
|
||||
# Remove partial installations
|
||||
rm -rf /usr/local/CyberCP
|
||||
rm -rf /usr/local/lsws
|
||||
rm -rf /usr/local/lsmcd
|
||||
|
||||
# Remove service files
|
||||
rm -f /etc/systemd/system/cyberpanel.service
|
||||
rm -f /etc/systemd/system/lsws.service
|
||||
rm -f /etc/systemd/system/lsmcd.service
|
||||
|
||||
systemctl daemon-reload
|
||||
}
|
||||
|
||||
# Function to install CyberPanel (original installation logic)
|
||||
install_cyberpanel() {
|
||||
local server_os=$1
|
||||
local branch_name=$2
|
||||
shift 2
|
||||
local install_args=("$@")
|
||||
|
||||
print_status "$BLUE" "Starting CyberPanel installation..."
|
||||
|
||||
# Download and run the original installer
|
||||
if [ -n "$branch_name" ]; then
|
||||
if [[ "$branch_name" =~ ^[a-f0-9]{7,40}$ ]]; then
|
||||
curl --silent -o cyberpanel.sh "https://raw.githubusercontent.com/usmannasir/cyberpanel/$branch_name/cyberpanel.sh" 2>/dev/null
|
||||
elif [[ "$branch_name" =~ ^commit: ]]; then
|
||||
commit_hash="${branch_name#commit:}"
|
||||
curl --silent -o cyberpanel.sh "https://raw.githubusercontent.com/usmannasir/cyberpanel/$commit_hash/cyberpanel.sh" 2>/dev/null
|
||||
else
|
||||
curl --silent -o cyberpanel.sh "https://raw.githubusercontent.com/usmannasir/cyberpanel/$branch_name/cyberpanel.sh" 2>/dev/null
|
||||
fi
|
||||
else
|
||||
curl --silent -o cyberpanel.sh "https://cyberpanel.sh/?dl&$server_os" 2>/dev/null
|
||||
fi
|
||||
|
||||
chmod +x cyberpanel.sh
|
||||
|
||||
# Run the installer and capture output
|
||||
if ./cyberpanel.sh "${install_args[@]}" > /tmp/cyberpanel_install_output.log 2>&1; then
|
||||
return 0
|
||||
else
|
||||
print_status "$RED" "Installation failed. Check /tmp/cyberpanel_install_output.log for details"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to determine installation type
|
||||
determine_installation_type() {
|
||||
if check_cyberpanel_installation; then
|
||||
get_current_version
|
||||
if check_for_updates; then
|
||||
INSTALLATION_TYPE="update"
|
||||
print_status "$YELLOW" "Update installation detected"
|
||||
else
|
||||
print_status "$GREEN" "CyberPanel is already installed and up to date"
|
||||
print_status "$YELLOW" "Reinstalling to ensure proper configuration..."
|
||||
INSTALLATION_TYPE="reinstall"
|
||||
fi
|
||||
else
|
||||
INSTALLATION_TYPE="fresh"
|
||||
print_status "$BLUE" "Fresh installation detected"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to perform installation based on type
|
||||
perform_installation() {
|
||||
local server_os=$1
|
||||
local branch_name=$2
|
||||
shift 2
|
||||
local install_args=("$@")
|
||||
|
||||
case $INSTALLATION_TYPE in
|
||||
"update"|"reinstall")
|
||||
uninstall_cyberpanel
|
||||
sleep 5
|
||||
if ! install_cyberpanel_with_retry "$server_os" "$branch_name" "${install_args[@]}"; then
|
||||
print_status "$RED" "Installation failed. Exiting..."
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
"fresh")
|
||||
if ! install_cyberpanel_with_retry "$server_os" "$branch_name" "${install_args[@]}"; then
|
||||
print_status "$RED" "Installation failed. Exiting..."
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Main installation function
|
||||
install_cyberpanel_main() {
|
||||
local server_os=$1
|
||||
local branch_name=$2
|
||||
shift 2
|
||||
local install_args=("$@")
|
||||
|
||||
print_status "$BLUE" "🚀 Starting CyberPanel installation process..."
|
||||
|
||||
# Determine installation type
|
||||
determine_installation_type
|
||||
|
||||
# Perform installation
|
||||
if perform_installation "$server_os" "$branch_name" "${install_args[@]}"; then
|
||||
print_status "$GREEN" "✅ CyberPanel installation completed successfully"
|
||||
return 0
|
||||
else
|
||||
print_status "$RED" "❌ CyberPanel installation failed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Main execution
|
||||
if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 <server_os> [branch_name] [install_args...]"
|
||||
echo "Example: $0 AlmaLinux9 v2.5.5-dev --debug"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
install_cyberpanel_main "$@"
|
||||
fi
|
||||
366
modules/os/detect.sh
Normal file
366
modules/os/detect.sh
Normal file
@@ -0,0 +1,366 @@
|
||||
#!/bin/bash
|
||||
|
||||
# OS Detection Module for CyberPanel Installer
|
||||
# This module handles OS detection and basic package manager setup
|
||||
# Max 500 lines - Current: ~200 lines
|
||||
|
||||
# Global variables
|
||||
SERVER_OS=""
|
||||
OS_FAMILY=""
|
||||
PACKAGE_MANAGER=""
|
||||
ARCHITECTURE=""
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Logging function
|
||||
log_message() {
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [OS-DETECT] $1" | tee -a "/var/log/cyberpanel_install.log" 2>/dev/null || echo "[$(date '+%Y-%m-%d %H:%M:%S')] [OS-DETECT] $1"
|
||||
}
|
||||
|
||||
# Print colored output
|
||||
print_status() {
|
||||
local color=$1
|
||||
local message=$2
|
||||
echo -e "${color}${message}${NC}"
|
||||
log_message "$message"
|
||||
}
|
||||
|
||||
# Function to detect system architecture
|
||||
detect_architecture() {
|
||||
ARCHITECTURE=$(uname -m)
|
||||
case $ARCHITECTURE in
|
||||
x86_64)
|
||||
print_status "$GREEN" "Architecture: x86_64 (Supported)"
|
||||
;;
|
||||
aarch64|arm64)
|
||||
print_status "$YELLOW" "Architecture: $ARCHITECTURE (Limited support)"
|
||||
;;
|
||||
*)
|
||||
print_status "$RED" "Architecture: $ARCHITECTURE (Not supported)"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
return 0
|
||||
}
|
||||
|
||||
# Function to detect CentOS variants
|
||||
detect_centos() {
|
||||
local OUTPUT=$1
|
||||
|
||||
if echo $OUTPUT | grep -q "CentOS Linux 7" ; then
|
||||
SERVER_OS="CentOS7"
|
||||
OS_FAMILY="rhel"
|
||||
PACKAGE_MANAGER="yum"
|
||||
print_status "$GREEN" "Detected: CentOS Linux 7"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "CentOS Linux 8" ; then
|
||||
SERVER_OS="CentOS8"
|
||||
OS_FAMILY="rhel"
|
||||
PACKAGE_MANAGER="yum"
|
||||
print_status "$GREEN" "Detected: CentOS Linux 8"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "CentOS Linux 9" ; then
|
||||
SERVER_OS="CentOS9"
|
||||
OS_FAMILY="rhel"
|
||||
PACKAGE_MANAGER="dnf"
|
||||
print_status "$GREEN" "Detected: CentOS Linux 9"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "CentOS Stream 8" ; then
|
||||
SERVER_OS="CentOSStream8"
|
||||
OS_FAMILY="rhel"
|
||||
PACKAGE_MANAGER="yum"
|
||||
print_status "$GREEN" "Detected: CentOS Stream 8"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "CentOS Stream 9" ; then
|
||||
SERVER_OS="CentOSStream9"
|
||||
OS_FAMILY="rhel"
|
||||
PACKAGE_MANAGER="dnf"
|
||||
print_status "$GREEN" "Detected: CentOS Stream 9"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# Function to detect AlmaLinux variants
|
||||
detect_almalinux() {
|
||||
local OUTPUT=$1
|
||||
|
||||
if echo $OUTPUT | grep -q "AlmaLinux 8" ; then
|
||||
SERVER_OS="AlmaLinux8"
|
||||
OS_FAMILY="rhel"
|
||||
PACKAGE_MANAGER="yum"
|
||||
print_status "$GREEN" "Detected: AlmaLinux 8"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "AlmaLinux 9" ; then
|
||||
SERVER_OS="AlmaLinux9"
|
||||
OS_FAMILY="rhel"
|
||||
PACKAGE_MANAGER="dnf"
|
||||
print_status "$GREEN" "Detected: AlmaLinux 9"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "AlmaLinux 10" ; then
|
||||
SERVER_OS="AlmaLinux10"
|
||||
OS_FAMILY="rhel"
|
||||
PACKAGE_MANAGER="dnf"
|
||||
print_status "$GREEN" "Detected: AlmaLinux 10"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# Function to detect Rocky Linux variants
|
||||
detect_rocky() {
|
||||
local OUTPUT=$1
|
||||
|
||||
if echo $OUTPUT | grep -q "Rocky Linux 8" ; then
|
||||
SERVER_OS="RockyLinux8"
|
||||
OS_FAMILY="rhel"
|
||||
PACKAGE_MANAGER="yum"
|
||||
print_status "$GREEN" "Detected: Rocky Linux 8"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "Rocky Linux 9" ; then
|
||||
SERVER_OS="RockyLinux9"
|
||||
OS_FAMILY="rhel"
|
||||
PACKAGE_MANAGER="dnf"
|
||||
print_status "$GREEN" "Detected: Rocky Linux 9"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# Function to detect RHEL variants
|
||||
detect_rhel() {
|
||||
local OUTPUT=$1
|
||||
|
||||
if echo $OUTPUT | grep -q "Red Hat Enterprise Linux 8" ; then
|
||||
SERVER_OS="RHEL8"
|
||||
OS_FAMILY="rhel"
|
||||
PACKAGE_MANAGER="yum"
|
||||
print_status "$GREEN" "Detected: Red Hat Enterprise Linux 8"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "Red Hat Enterprise Linux 9" ; then
|
||||
SERVER_OS="RHEL9"
|
||||
OS_FAMILY="rhel"
|
||||
PACKAGE_MANAGER="dnf"
|
||||
print_status "$GREEN" "Detected: Red Hat Enterprise Linux 9"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# Function to detect CloudLinux variants
|
||||
detect_cloudlinux() {
|
||||
local OUTPUT=$1
|
||||
|
||||
if echo $OUTPUT | grep -q "CloudLinux 7" ; then
|
||||
SERVER_OS="CloudLinux7"
|
||||
OS_FAMILY="rhel"
|
||||
PACKAGE_MANAGER="yum"
|
||||
print_status "$GREEN" "Detected: CloudLinux 7"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "CloudLinux 8" ; then
|
||||
SERVER_OS="CloudLinux8"
|
||||
OS_FAMILY="rhel"
|
||||
PACKAGE_MANAGER="yum"
|
||||
print_status "$GREEN" "Detected: CloudLinux 8"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "CloudLinux 9" ; then
|
||||
SERVER_OS="CloudLinux9"
|
||||
OS_FAMILY="rhel"
|
||||
PACKAGE_MANAGER="dnf"
|
||||
print_status "$GREEN" "Detected: CloudLinux 9"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# Function to detect Ubuntu variants
|
||||
detect_ubuntu() {
|
||||
local OUTPUT=$1
|
||||
|
||||
if echo $OUTPUT | grep -q "Ubuntu 18.04" ; then
|
||||
SERVER_OS="Ubuntu1804"
|
||||
OS_FAMILY="debian"
|
||||
PACKAGE_MANAGER="apt"
|
||||
print_status "$GREEN" "Detected: Ubuntu 18.04"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "Ubuntu 20.04" ; then
|
||||
SERVER_OS="Ubuntu2004"
|
||||
OS_FAMILY="debian"
|
||||
PACKAGE_MANAGER="apt"
|
||||
print_status "$GREEN" "Detected: Ubuntu 20.04"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "Ubuntu 20.10" ; then
|
||||
SERVER_OS="Ubuntu2010"
|
||||
OS_FAMILY="debian"
|
||||
PACKAGE_MANAGER="apt"
|
||||
print_status "$GREEN" "Detected: Ubuntu 20.10"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "Ubuntu 22.04" ; then
|
||||
SERVER_OS="Ubuntu2204"
|
||||
OS_FAMILY="debian"
|
||||
PACKAGE_MANAGER="apt"
|
||||
print_status "$GREEN" "Detected: Ubuntu 22.04"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "Ubuntu 24.04" ; then
|
||||
SERVER_OS="Ubuntu2404"
|
||||
OS_FAMILY="debian"
|
||||
PACKAGE_MANAGER="apt"
|
||||
print_status "$GREEN" "Detected: Ubuntu 24.04"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "Ubuntu 24.04.3" ; then
|
||||
SERVER_OS="Ubuntu24043"
|
||||
OS_FAMILY="debian"
|
||||
PACKAGE_MANAGER="apt"
|
||||
print_status "$GREEN" "Detected: Ubuntu 24.04.3"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# Function to detect Debian variants
|
||||
detect_debian() {
|
||||
local OUTPUT=$1
|
||||
|
||||
if echo $OUTPUT | grep -q "Debian GNU/Linux 11" ; then
|
||||
SERVER_OS="Debian11"
|
||||
OS_FAMILY="debian"
|
||||
PACKAGE_MANAGER="apt"
|
||||
print_status "$GREEN" "Detected: Debian GNU/Linux 11"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "Debian GNU/Linux 12" ; then
|
||||
SERVER_OS="Debian12"
|
||||
OS_FAMILY="debian"
|
||||
PACKAGE_MANAGER="apt"
|
||||
print_status "$GREEN" "Detected: Debian GNU/Linux 12"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "Debian GNU/Linux 13" ; then
|
||||
SERVER_OS="Debian13"
|
||||
OS_FAMILY="debian"
|
||||
PACKAGE_MANAGER="apt"
|
||||
print_status "$GREEN" "Detected: Debian GNU/Linux 13"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# Function to detect openEuler variants
|
||||
detect_openeuler() {
|
||||
local OUTPUT=$1
|
||||
|
||||
if echo $OUTPUT | grep -q "openEuler 20.03" ; then
|
||||
SERVER_OS="openEuler2003"
|
||||
OS_FAMILY="rhel"
|
||||
PACKAGE_MANAGER="yum"
|
||||
print_status "$GREEN" "Detected: openEuler 20.03"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "openEuler 22.03" ; then
|
||||
SERVER_OS="openEuler2203"
|
||||
OS_FAMILY="rhel"
|
||||
PACKAGE_MANAGER="yum"
|
||||
print_status "$GREEN" "Detected: openEuler 22.03"
|
||||
return 0
|
||||
elif echo $OUTPUT | grep -q "openEuler 24.03" ; then
|
||||
SERVER_OS="openEuler2403"
|
||||
OS_FAMILY="rhel"
|
||||
PACKAGE_MANAGER="yum"
|
||||
print_status "$GREEN" "Detected: openEuler 24.03"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# Main OS detection function
|
||||
detect_os() {
|
||||
print_status "$BLUE" "🔍 Detecting operating system..."
|
||||
|
||||
# Detect architecture first
|
||||
if ! detect_architecture; then
|
||||
print_status "$RED" "❌ Unsupported architecture: $ARCHITECTURE"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Get OS release information
|
||||
local OUTPUT=$(cat /etc/*release 2>/dev/null)
|
||||
if [ -z "$OUTPUT" ]; then
|
||||
print_status "$RED" "❌ Cannot read OS release information"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Try to detect each OS family
|
||||
if detect_centos "$OUTPUT"; then
|
||||
return 0
|
||||
elif detect_almalinux "$OUTPUT"; then
|
||||
return 0
|
||||
elif detect_rocky "$OUTPUT"; then
|
||||
return 0
|
||||
elif detect_rhel "$OUTPUT"; then
|
||||
return 0
|
||||
elif detect_cloudlinux "$OUTPUT"; then
|
||||
return 0
|
||||
elif detect_ubuntu "$OUTPUT"; then
|
||||
return 0
|
||||
elif detect_debian "$OUTPUT"; then
|
||||
return 0
|
||||
elif detect_openeuler "$OUTPUT"; then
|
||||
return 0
|
||||
else
|
||||
print_status "$RED" "❌ Unable to detect your OS..."
|
||||
print_status "$YELLOW" "Supported operating systems:"
|
||||
echo -e "• Ubuntu: 18.04, 20.04, 20.10, 22.04, 24.04, 24.04.3"
|
||||
echo -e "• Debian: 11, 12, 13"
|
||||
echo -e "• AlmaLinux: 8, 9, 10"
|
||||
echo -e "• RockyLinux: 8, 9"
|
||||
echo -e "• RHEL: 8, 9"
|
||||
echo -e "• CentOS: 7, 8, 9, Stream 8, Stream 9"
|
||||
echo -e "• CloudLinux: 7, 8, 9"
|
||||
echo -e "• openEuler: 20.03, 22.03, 24.03"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to install basic tools
|
||||
install_basic_tools() {
|
||||
print_status "$BLUE" "📦 Installing basic tools..."
|
||||
|
||||
case $PACKAGE_MANAGER in
|
||||
"yum"|"dnf")
|
||||
$PACKAGE_MANAGER install curl wget -y 1> /dev/null
|
||||
$PACKAGE_MANAGER update curl wget ca-certificates -y 1> /dev/null
|
||||
;;
|
||||
"apt")
|
||||
apt update -qq 2>/dev/null
|
||||
apt install -y -qq wget curl 2>/dev/null
|
||||
;;
|
||||
*)
|
||||
print_status "$RED" "❌ Unknown package manager: $PACKAGE_MANAGER"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
print_status "$GREEN" "✅ Basic tools installed successfully"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Function to get OS information
|
||||
get_os_info() {
|
||||
echo "SERVER_OS=$SERVER_OS"
|
||||
echo "OS_FAMILY=$OS_FAMILY"
|
||||
echo "PACKAGE_MANAGER=$PACKAGE_MANAGER"
|
||||
echo "ARCHITECTURE=$ARCHITECTURE"
|
||||
}
|
||||
|
||||
# Main execution
|
||||
if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
|
||||
detect_os
|
||||
if [ $? -eq 0 ]; then
|
||||
install_basic_tools
|
||||
get_os_info
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user