mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-12-16 21:39:42 +01:00
Remove obsolete documentation and testing scripts related to branch prefix fixes and installation validation. Update MariaDB version to 12.1 in relevant scripts, enhancing compatibility and error handling for AlmaLinux 9. Improve user prompts in installation scripts for clarity and default options. Ensure MySQL password file handling is robust and properly logged.
This commit is contained in:
@@ -1,96 +0,0 @@
|
||||
# Branch Prefix Fix - v2.5.5-dev Issue Resolved
|
||||
|
||||
## Problem Identified
|
||||
|
||||
The user discovered that when trying to install `2.5.5-dev`, the installer was incorrectly trying to access:
|
||||
```
|
||||
https://raw.githubusercontent.com/usmannasir/cyberpanel/2.5.5-dev/requirments.txt
|
||||
```
|
||||
|
||||
But the actual branch exists as `v2.5.5-dev` (with the `v` prefix):
|
||||
```
|
||||
https://github.com/usmannasir/cyberpanel/blob/v2.5.5-dev/requirments.txt
|
||||
```
|
||||
|
||||
## Root Cause
|
||||
|
||||
The `Branch_Check()` function in `cyberpanel.sh` was not properly handling development version branch names. When a user entered `2.5.5-dev`, the code was setting `Branch_Name="2.5.5-dev"` instead of adding the required `v` prefix to make it `v2.5.5-dev`.
|
||||
|
||||
## Solution Applied
|
||||
|
||||
### 1. Enhanced Branch Name Logic
|
||||
Updated the `Branch_Check()` function to automatically add the `v` prefix for development branches:
|
||||
|
||||
```bash
|
||||
# Handle both stable and development versions
|
||||
if [[ "$1" =~ -dev$ ]]; then
|
||||
# Add 'v' prefix for development branches if not already present
|
||||
if [[ "$1" =~ ^v.*-dev$ ]]; then
|
||||
Branch_Name="${1//[[:space:]]/}"
|
||||
else
|
||||
Branch_Name="v${1//[[:space:]]/}"
|
||||
fi
|
||||
echo -e "\nSet branch name to $Branch_Name (development version)..."
|
||||
```
|
||||
|
||||
### 2. Updated User Guidance
|
||||
Modified the version prompt to clarify that the `v` prefix will be automatically added:
|
||||
|
||||
```
|
||||
2.5.5-dev (development version - will auto-add 'v' prefix)
|
||||
v2.3.5-dev (development version with 'v' prefix)
|
||||
```
|
||||
|
||||
## Verification
|
||||
|
||||
✅ **Confirmed**: The `v2.5.5-dev` branch exists and is accessible via [GitHub](https://github.com/usmannasir/cyberpanel/tree/v2.5.5-dev)
|
||||
✅ **Confirmed**: The requirements file is available at the correct URL
|
||||
✅ **Confirmed**: The fix handles both formats (`2.5.5-dev` and `v2.5.5-dev`)
|
||||
✅ **Confirmed**: GitHub API verification works correctly
|
||||
|
||||
## Impact
|
||||
|
||||
- Users can now enter `2.5.5-dev` and it will automatically work as `v2.5.5-dev`
|
||||
- Existing users who were already using `v2.5.5-dev` format continue to work
|
||||
- No breaking changes to existing functionality
|
||||
- Clearer user guidance about branch naming
|
||||
|
||||
## Files Modified
|
||||
|
||||
- `cyberpanel/cyberpanel.sh` - Enhanced `Branch_Check()` function
|
||||
- `cyberpanel/tools/test_fixes.sh` - Updated test cases
|
||||
- `cyberpanel/BRANCH_PREFIX_FIX.md` - This documentation
|
||||
|
||||
## Test Results
|
||||
|
||||
```bash
|
||||
# Test 1: Non-existent branch (should fail)
|
||||
curl -I https://raw.githubusercontent.com/usmannasir/cyberpanel/2.5.5-dev/requirments.txt
|
||||
# Result: 404 Not Found ✅
|
||||
|
||||
# Test 2: Correct branch name (should work)
|
||||
curl -I https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.5.5-dev/requirments.txt
|
||||
# Result: 200 OK ✅
|
||||
```
|
||||
|
||||
## Installation Examples
|
||||
|
||||
### Now Works:
|
||||
```bash
|
||||
sh <(curl https://cyberpanel.net/install.sh || wget -O - https://cyberpanel.net/install.sh)
|
||||
# When prompted, enter: 2.5.5-dev
|
||||
# Will automatically use: v2.5.5-dev
|
||||
```
|
||||
|
||||
### Still Works:
|
||||
```bash
|
||||
sh <(curl https://cyberpanel.net/install.sh || wget -O - https://cyberpanel.net/install.sh)
|
||||
# When prompted, enter: v2.5.5-dev
|
||||
# Will use: v2.5.5-dev (no change)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Fix Applied**: September 24, 2025
|
||||
**Issue**: Branch prefix missing for development versions
|
||||
**Status**: ✅ Resolved
|
||||
132
cyberpanel.sh
132
cyberpanel.sh
@@ -1266,8 +1266,11 @@ else
|
||||
fi
|
||||
|
||||
echo -e "\nPlease choose to use default admin password \e[31m1234567\e[39m, randomly generate one \e[31m(recommended)\e[39m or specify the admin password?"
|
||||
printf "%s" "Choose [d]fault, [r]andom or [s]et password: [d/r/s] "
|
||||
Tmp_Input="r"
|
||||
printf "%s" "Choose [d]fault, [r]andom or [s]et password (default: random): [d/r/s] "
|
||||
read -r Tmp_Input
|
||||
if [[ -z $Tmp_Input ]]; then
|
||||
Tmp_Input="r"
|
||||
fi
|
||||
|
||||
if [[ $Tmp_Input =~ ^(d|D| ) ]] || [[ -z $Tmp_Input ]]; then
|
||||
Admin_Pass="1234567"
|
||||
@@ -1309,7 +1312,7 @@ else
|
||||
fi
|
||||
|
||||
echo -e "\nDo you wish to install Memcached process and its PHP extension?"
|
||||
printf "%s" "Please select [Y/n]: "
|
||||
printf "%s" "Please select [Y/n] (default: Yes): "
|
||||
read -r Tmp_Input
|
||||
if [[ $Tmp_Input =~ ^(no|n|N) ]]; then
|
||||
Memcached="Off"
|
||||
@@ -1319,7 +1322,7 @@ else
|
||||
fi
|
||||
|
||||
echo -e "\nDo you wish to install Redis process and its PHP extension?"
|
||||
printf "%s" "Please select [Y/n]: "
|
||||
printf "%s" "Please select [Y/n] (default: Yes): "
|
||||
read -r Tmp_Input
|
||||
if [[ $Tmp_Input =~ ^(no|n|N) ]]; then
|
||||
Redis="Off"
|
||||
@@ -1331,13 +1334,14 @@ fi
|
||||
echo -e "\nWould you like to set up a WatchDog \e[31m(beta)\e[39m for Web service and Database service ?"
|
||||
echo -e "The watchdog script will be automatically started up after installation and server reboot"
|
||||
echo -e "If you want to kill the watchdog , run \e[31mwatchdog kill\e[39m"
|
||||
echo -e "Please type Yes or no (with capital \e[31mY\e[39m, default Yes): "
|
||||
echo -e "Please select [Y/n] (default: Yes): "
|
||||
read -r Tmp_Input
|
||||
if [[ $Tmp_Input = "Yes" ]] || [[ $Tmp_Input = "" ]]; then
|
||||
if [[ $Tmp_Input =~ ^(no|n|N) ]]; then
|
||||
Watchdog="Off"
|
||||
echo -e "\nInstall Watchdog set to No...\n"
|
||||
else
|
||||
Watchdog="On"
|
||||
echo -e "\nInstall Watchdog set to Yes...\n"
|
||||
else
|
||||
Watchdog="Off"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1636,23 +1640,41 @@ if [[ "$Server_OS" =~ ^(CentOS|RHEL|AlmaLinux|RockyLinux|CloudLinux|openEuler) ]
|
||||
|
||||
# STEP 4: Setup MariaDB repository for RHEL 9+ based systems (AlmaLinux 9/10, RockyLinux 9, RHEL 9)
|
||||
if [[ "$Server_OS" =~ ^(AlmaLinux9|AlmaLinux10|RockyLinux9|RHEL9|RHEL10) ]] ; then
|
||||
# Use the official MariaDB repository setup script for better compatibility
|
||||
log_info "Setting up MariaDB repository for $Server_OS..."
|
||||
curl -sS "https://downloads.mariadb.com/MariaDB/mariadb_repo_setup" | bash -s -- --mariadb-server-version="12.1" --skip-maxscale --skip-tools
|
||||
Check_Return "MariaDB repository setup" "no_exit"
|
||||
|
||||
# Verify MariaDB repository was added successfully
|
||||
if dnf repolist | grep -q "mariadb"; then
|
||||
log_info "MariaDB repository added successfully"
|
||||
# First, try to use the official MariaDB repository setup script
|
||||
log_info "Attempting official MariaDB repository setup script..."
|
||||
curl -sS "https://downloads.mariadb.com/MariaDB/mariadb_repo_setup" | bash -s -- --mariadb-server-version="12.1" --skip-maxscale --skip-tools 2>/dev/null
|
||||
|
||||
# Check if the official script worked
|
||||
if dnf repolist | grep -q "mariadb" 2>/dev/null; then
|
||||
log_info "MariaDB repository added successfully via official script"
|
||||
else
|
||||
log_warning "MariaDB repository setup may have failed, continuing with installation"
|
||||
fi
|
||||
log_warning "Official MariaDB repository setup failed, using fallback method"
|
||||
|
||||
# Fallback manual repository setup if the script fails
|
||||
if [ ! -f /etc/yum.repos.d/mariadb.repo ]; then
|
||||
# Enhanced fallback: Try multiple repository configurations
|
||||
log_info "Setting up MariaDB repository using fallback method..."
|
||||
|
||||
# Method 1: Use the redirected mirror URL
|
||||
cat <<EOF >/etc/yum.repos.d/MariaDB.repo
|
||||
# MariaDB 10.11 RHEL9+ repository list
|
||||
# http://downloads.mariadb.org/mariadb/repositories/
|
||||
# MariaDB 12.1 RHEL9+ repository list
|
||||
# https://downloads.mariadb.org/mariadb/repositories/
|
||||
[mariadb]
|
||||
name = MariaDB
|
||||
baseurl = https://mirror.mariadb.org/yum/12.1/rhel9-amd64/
|
||||
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
|
||||
enabled=1
|
||||
gpgcheck=1
|
||||
module_hotfixes=1
|
||||
gpgkey=https://downloads.mariadb.com/MariaDB/MariaDB-Server-GPG-KEY
|
||||
gpgkey=https://downloads.mariadb.com/MariaDB/MariaDB-ColumnStore-GPG-KEY
|
||||
EOF
|
||||
|
||||
# Method 2: Alternative repository configuration if first fails
|
||||
if ! dnf repolist | grep -q "mariadb" 2>/dev/null; then
|
||||
log_info "Trying alternative MariaDB repository configuration..."
|
||||
cat <<EOF >/etc/yum.repos.d/MariaDB.repo
|
||||
# MariaDB 12.1 Alternative repository configuration
|
||||
[mariadb]
|
||||
name = MariaDB
|
||||
baseurl = https://yum.mariadb.org/12.1/rhel9-amd64/
|
||||
@@ -1661,7 +1683,14 @@ enabled=1
|
||||
gpgcheck=1
|
||||
module_hotfixes=1
|
||||
EOF
|
||||
Check_Return "MariaDB repository fallback setup" "no_exit"
|
||||
fi
|
||||
|
||||
# Method 3: If still no repository, try using AppStream (AlmaLinux 9.6 default)
|
||||
if ! dnf repolist | grep -q "mariadb" 2>/dev/null; then
|
||||
log_info "MariaDB repository setup failed, will use AlmaLinux AppStream repository"
|
||||
# Enable AppStream if not already enabled
|
||||
dnf config-manager --enable appstream 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
|
||||
# STEP 5: Clean caches after MariaDB repo setup
|
||||
@@ -1693,18 +1722,59 @@ EOF
|
||||
dnf install -y libnsl zip wget strace net-tools curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel curl-devel git platform-python-devel tar socat python3 zip unzip bind-utils openssl-devel boost-devel boost-program-options
|
||||
Check_Return "Base system packages" "no_exit"
|
||||
|
||||
# Second: Install MariaDB packages (with proper dependency resolution)
|
||||
dnf install -y mariadb-server mariadb-devel mariadb-client-utils --skip-broken --nobest
|
||||
Check_Return "MariaDB packages" "no_exit"
|
||||
# Second: Install MariaDB packages (with comprehensive fallback logic for AlmaLinux 9.6)
|
||||
log_info "Installing MariaDB packages for AlmaLinux 9.6..."
|
||||
|
||||
# STEP 7.1: Check for package conflicts and resolve them
|
||||
echo "Checking for package conflicts..."
|
||||
if dnf list installed | grep -q "mariadb-server"; then
|
||||
echo "MariaDB server installed successfully"
|
||||
# Try multiple installation methods for maximum compatibility
|
||||
mariadb_installed=false
|
||||
|
||||
# Method 1: Try from MariaDB repository (if available)
|
||||
if dnf repolist | grep -q "mariadb" 2>/dev/null; then
|
||||
log_info "Installing MariaDB from official MariaDB repository..."
|
||||
dnf install -y mariadb-server mariadb-devel mariadb-client-utils --skip-broken --nobest 2>/dev/null
|
||||
if dnf list installed | grep -q "mariadb-server" 2>/dev/null; then
|
||||
mariadb_installed=true
|
||||
log_info "MariaDB installed successfully from official repository"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Method 2: Try from AppStream repository (AlmaLinux 9.6 default)
|
||||
if [ "$mariadb_installed" = false ]; then
|
||||
log_info "Installing MariaDB from AlmaLinux AppStream repository..."
|
||||
dnf install -y mariadb-server mariadb-devel mariadb-client-utils --skip-broken --nobest --allowerasing 2>/dev/null
|
||||
if dnf list installed | grep -q "mariadb-server" 2>/dev/null; then
|
||||
mariadb_installed=true
|
||||
log_info "MariaDB installed successfully from AppStream repository"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Method 3: Try with minimal dependencies if still failing
|
||||
if [ "$mariadb_installed" = false ]; then
|
||||
log_info "Installing MariaDB with minimal dependencies..."
|
||||
dnf install -y mariadb-server --skip-broken --nobest --allowerasing 2>/dev/null || true
|
||||
dnf install -y mariadb-devel --skip-broken --nobest --allowerasing 2>/dev/null || true
|
||||
if dnf list installed | grep -q "mariadb-server" 2>/dev/null; then
|
||||
mariadb_installed=true
|
||||
log_info "MariaDB installed successfully with minimal dependencies"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Method 4: Final fallback - try MySQL as alternative
|
||||
if [ "$mariadb_installed" = false ]; then
|
||||
log_warning "MariaDB installation failed, trying MySQL as fallback..."
|
||||
dnf install -y mysql-server mysql-devel --skip-broken --nobest --allowerasing 2>/dev/null || true
|
||||
if dnf list installed | grep -q "mysql-server" 2>/dev/null; then
|
||||
log_info "MySQL installed as fallback for MariaDB"
|
||||
mariadb_installed=true
|
||||
fi
|
||||
fi
|
||||
|
||||
# Final verification
|
||||
if [ "$mariadb_installed" = false ]; then
|
||||
log_error "Failed to install MariaDB or MySQL. Manual intervention may be required."
|
||||
Check_Return "MariaDB packages" "no_exit"
|
||||
else
|
||||
echo "Warning: MariaDB server not found, attempting to resolve..."
|
||||
# Try installing from different sources
|
||||
dnf install -y mariadb-server --skip-broken --nobest --allowerasing
|
||||
log_info "Database server installed successfully"
|
||||
fi
|
||||
|
||||
# STEP 8: Install development tools group
|
||||
|
||||
@@ -415,11 +415,11 @@ if [[ "$Server_OS" = "CentOS" ]] || [[ "$Server_OS" = "AlmaLinux9" ]] ; then
|
||||
Check_Return "yum repo" "no_exit"
|
||||
|
||||
cat << EOF > /etc/yum.repos.d/MariaDB.repo
|
||||
# MariaDB 10.4 CentOS repository list - created 2021-08-06 02:01 UTC
|
||||
# MariaDB 12.1 CentOS repository list - updated 2025-09-25
|
||||
# http://downloads.mariadb.org/mariadb/repositories/
|
||||
[mariadb]
|
||||
name = MariaDB
|
||||
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
|
||||
baseurl = http://yum.mariadb.org/12.1/centos7-amd64
|
||||
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
|
||||
gpgcheck=1
|
||||
EOF
|
||||
|
||||
@@ -228,16 +228,29 @@ class preFlightsChecks:
|
||||
command = "dnf install -y epel-release"
|
||||
self.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
# Install PHP dependencies that are missing
|
||||
# Install AlmaLinux 9 compatibility packages
|
||||
self.stdOut("Installing AlmaLinux 9 compatibility packages...", 1)
|
||||
compat_packages = [
|
||||
"libxcrypt-compat",
|
||||
"libnsl",
|
||||
"compat-openssl11",
|
||||
"compat-openssl11-devel"
|
||||
]
|
||||
|
||||
for package in compat_packages:
|
||||
command = f"dnf install -y {package}"
|
||||
self.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
# Install PHP dependencies that are missing (with AlmaLinux 9 compatibility)
|
||||
self.stdOut("Installing PHP dependencies...", 1)
|
||||
php_deps = [
|
||||
|
||||
# Base packages that should work on all systems
|
||||
base_deps = [
|
||||
"ImageMagick", "ImageMagick-devel",
|
||||
"gd", "gd-devel",
|
||||
"libicu", "libicu-devel",
|
||||
"oniguruma", "oniguruma-devel",
|
||||
"aspell", "aspell-devel",
|
||||
"libc-client", "libc-client-devel",
|
||||
"libmemcached", "libmemcached-devel",
|
||||
"freetype-devel",
|
||||
"libjpeg-turbo-devel",
|
||||
"libpng-devel",
|
||||
@@ -256,14 +269,77 @@ class preFlightsChecks:
|
||||
"gcc-c++"
|
||||
]
|
||||
|
||||
for dep in php_deps:
|
||||
# Install base packages
|
||||
for dep in base_deps:
|
||||
command = f"dnf install -y {dep}"
|
||||
self.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
# Install MariaDB
|
||||
self.stdOut("Installing MariaDB...", 1)
|
||||
command = "dnf install -y mariadb-server mariadb-devel mariadb-client"
|
||||
# Install AlmaLinux 9 specific packages with fallbacks
|
||||
alma9_specific = [
|
||||
("libc-client", "libc-client-devel"),
|
||||
("libmemcached", "libmemcached-devel")
|
||||
]
|
||||
|
||||
for package, dev_package in alma9_specific:
|
||||
# Try to install the main package first
|
||||
command = f"dnf install -y {package}"
|
||||
result = self.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
if result == 1:
|
||||
self.stdOut(f"Successfully installed {package}", 1)
|
||||
# Try to install the development package
|
||||
dev_command = f"dnf install -y {dev_package}"
|
||||
self.call(dev_command, self.distro, dev_command, dev_command, 1, 0, os.EX_OSERR)
|
||||
else:
|
||||
self.stdOut(f"Package {package} not available, trying alternatives...", 1)
|
||||
# Try alternative package names for AlmaLinux 9
|
||||
alternatives = {
|
||||
"libc-client": ["libc-client-devel", "uw-imap-devel"],
|
||||
"libmemcached": ["libmemcached-devel", "memcached-devel"]
|
||||
}
|
||||
|
||||
if package in alternatives:
|
||||
for alt_package in alternatives[package]:
|
||||
alt_command = f"dnf install -y {alt_package}"
|
||||
result = self.call(alt_command, self.distro, alt_command, alt_command, 1, 0, os.EX_OSERR)
|
||||
if result == 1:
|
||||
self.stdOut(f"Successfully installed alternative: {alt_package}", 1)
|
||||
break
|
||||
|
||||
# Install MariaDB with enhanced AlmaLinux 9.6 support
|
||||
self.stdOut("Installing MariaDB for AlmaLinux 9.6...", 1)
|
||||
|
||||
# Try multiple installation methods for maximum compatibility
|
||||
mariadb_commands = [
|
||||
"dnf install -y mariadb-server mariadb-devel mariadb-client --skip-broken --nobest",
|
||||
"dnf install -y mariadb-server mariadb-devel mariadb-client --allowerasing",
|
||||
"dnf install -y mariadb-server mariadb-devel --skip-broken --nobest --allowerasing",
|
||||
"dnf install -y mariadb-server --skip-broken --nobest --allowerasing"
|
||||
]
|
||||
|
||||
mariadb_installed = False
|
||||
for cmd in mariadb_commands:
|
||||
try:
|
||||
result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=300)
|
||||
if result.returncode == 0:
|
||||
mariadb_installed = True
|
||||
self.stdOut(f"MariaDB installed successfully with command: {cmd}", 1)
|
||||
break
|
||||
except subprocess.TimeoutExpired:
|
||||
self.stdOut(f"Timeout installing MariaDB with command: {cmd}", 0)
|
||||
continue
|
||||
except Exception as e:
|
||||
self.stdOut(f"Error installing MariaDB with command: {cmd} - {str(e)}", 0)
|
||||
continue
|
||||
|
||||
if not mariadb_installed:
|
||||
self.stdOut("MariaDB installation failed, trying MySQL as fallback...", 0)
|
||||
try:
|
||||
command = "dnf install -y mysql-server mysql-devel --skip-broken --nobest --allowerasing"
|
||||
self.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
self.stdOut("MySQL installed as fallback for MariaDB", 1)
|
||||
except:
|
||||
self.stdOut("Both MariaDB and MySQL installation failed", 0)
|
||||
|
||||
# Install additional required packages
|
||||
self.stdOut("Installing additional required packages...", 1)
|
||||
@@ -677,18 +753,42 @@ class preFlightsChecks:
|
||||
self.call(command, self.distro, command, command, 0, 0, os.EX_OSERR)
|
||||
|
||||
# Save MySQL password to file for later use
|
||||
try:
|
||||
os.makedirs('/etc/cyberpanel', exist_ok=True)
|
||||
with open('/etc/cyberpanel/mysqlPassword', 'w') as f:
|
||||
f.write(self.mysql_Root_password)
|
||||
os.chmod('/etc/cyberpanel/mysqlPassword', 0o600)
|
||||
self.stdOut("MySQL password saved to /etc/cyberpanel/mysqlPassword", 1)
|
||||
except Exception as e:
|
||||
self.stdOut(f"Warning: Could not save MySQL password to file: {str(e)}", 0)
|
||||
self.ensure_mysql_password_file()
|
||||
|
||||
except Exception as e:
|
||||
self.stdOut(f"Error changing MySQL root password: {str(e)}", 0)
|
||||
|
||||
def ensure_mysql_password_file(self):
|
||||
"""Ensure MySQL password file exists and is properly configured"""
|
||||
try:
|
||||
os.makedirs('/etc/cyberpanel', exist_ok=True)
|
||||
|
||||
# Check if password file already exists
|
||||
passFile = '/etc/cyberpanel/mysqlPassword'
|
||||
if os.path.exists(passFile):
|
||||
# Verify the file has content
|
||||
with open(passFile, 'r') as f:
|
||||
content = f.read().strip()
|
||||
if content:
|
||||
self.stdOut("MySQL password file already exists and has content", 1)
|
||||
return
|
||||
|
||||
# Create or update the password file
|
||||
if hasattr(self, 'mysql_Root_password') and self.mysql_Root_password:
|
||||
with open(passFile, 'w') as f:
|
||||
f.write(self.mysql_Root_password)
|
||||
os.chmod(passFile, 0o600)
|
||||
self.stdOut("MySQL password saved to /etc/cyberpanel/mysqlPassword", 1)
|
||||
logging.InstallLog.writeToFile("MySQL password file created successfully")
|
||||
else:
|
||||
raise Exception("No MySQL root password available to save")
|
||||
|
||||
except Exception as e:
|
||||
error_msg = f"Critical: Could not save MySQL password to file: {str(e)}"
|
||||
self.stdOut(error_msg, 0)
|
||||
logging.InstallLog.writeToFile(error_msg)
|
||||
raise Exception(error_msg)
|
||||
|
||||
def command_exists(self, command):
|
||||
"""Check if a command exists in PATH"""
|
||||
try:
|
||||
@@ -813,9 +913,31 @@ class preFlightsChecks:
|
||||
try:
|
||||
self.stdOut("Fixing OpenLiteSpeed configurations...", 1)
|
||||
|
||||
# Check if OpenLiteSpeed configuration file exists
|
||||
config_file = self.server_root_path + "conf/httpd_config.conf"
|
||||
if not os.path.exists(config_file):
|
||||
self.stdOut("OpenLiteSpeed configuration file not found, creating default configuration...", 1)
|
||||
# Create the configuration directory if it doesn't exist
|
||||
os.makedirs(os.path.dirname(config_file), exist_ok=True)
|
||||
# Create a basic configuration file
|
||||
with open(config_file, 'w') as f:
|
||||
f.write("# OpenLiteSpeed Configuration\n")
|
||||
f.write("serverName localhost\n")
|
||||
f.write("listener *:8088 {\n")
|
||||
f.write(" address *:8088\n")
|
||||
f.write(" secure 0\n")
|
||||
f.write(" map *:8088 *\n")
|
||||
f.write("}\n")
|
||||
f.write("listener *:80 {\n")
|
||||
f.write(" address *:80\n")
|
||||
f.write(" secure 0\n")
|
||||
f.write(" map *:80 *\n")
|
||||
f.write("}\n")
|
||||
self.stdOut("Default OpenLiteSpeed configuration created", 1)
|
||||
|
||||
# Remove example virtual host
|
||||
data = open(self.server_root_path + "conf/httpd_config.conf", 'r').readlines()
|
||||
writeDataToFile = open(self.server_root_path + "conf/httpd_config.conf", 'w')
|
||||
data = open(config_file, 'r').readlines()
|
||||
writeDataToFile = open(config_file, 'w')
|
||||
|
||||
for items in data:
|
||||
if items.find("map") > -1 and items.find("Example") > -1:
|
||||
@@ -838,12 +960,16 @@ class preFlightsChecks:
|
||||
self.stdOut("Changing OpenLiteSpeed port to 80...", 1)
|
||||
|
||||
file_path = self.server_root_path + "conf/httpd_config.conf"
|
||||
if os.path.exists(file_path):
|
||||
if self.modify_file_content(file_path, {"*:8088": "*:80"}):
|
||||
self.stdOut("OpenLiteSpeed port changed to 80", 1)
|
||||
self.reStartLiteSpeed()
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
self.stdOut("OpenLiteSpeed configuration file not found, skipping port change", 1)
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
self.stdOut(f"Error changing port to 80: {str(e)}", 0)
|
||||
@@ -1322,6 +1448,11 @@ class preFlightsChecks:
|
||||
command = 'rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.2-1.el7.noarch.rpm'
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
elif self.distro == cent8:
|
||||
# Use compatible repository version for RHEL-based systems
|
||||
# AlmaLinux 9 is compatible with el8 repositories
|
||||
if os_info['name'] in ['almalinux', 'rocky', 'rhel'] and os_info['major_version'] in ['8', '9']:
|
||||
command = 'rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm'
|
||||
else:
|
||||
command = 'rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm'
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
@@ -1544,9 +1675,38 @@ class preFlightsChecks:
|
||||
if self.remotemysql == 'OFF':
|
||||
passFile = "/etc/cyberpanel/mysqlPassword"
|
||||
|
||||
f = open(passFile)
|
||||
# Check if MySQL password file exists, create it if missing
|
||||
if not os.path.exists(passFile):
|
||||
logging.InstallLog.writeToFile("MySQL password file not found, creating it...")
|
||||
try:
|
||||
# Ensure directory exists
|
||||
os.makedirs('/etc/cyberpanel', exist_ok=True)
|
||||
|
||||
# Use the stored MySQL root password
|
||||
if hasattr(self, 'mysql_Root_password') and self.mysql_Root_password:
|
||||
password = self.mysql_Root_password
|
||||
# Create the password file
|
||||
with open(passFile, 'w') as f:
|
||||
f.write(password)
|
||||
os.chmod(passFile, 0o600)
|
||||
logging.InstallLog.writeToFile("MySQL password file created successfully")
|
||||
else:
|
||||
logging.InstallLog.writeToFile("ERROR: No MySQL root password available")
|
||||
raise Exception("MySQL root password not available")
|
||||
except Exception as e:
|
||||
logging.InstallLog.writeToFile(f"ERROR: Failed to create MySQL password file: {str(e)}")
|
||||
raise Exception(f"Failed to create MySQL password file: {str(e)}")
|
||||
else:
|
||||
# Read existing password file
|
||||
try:
|
||||
with open(passFile, 'r') as f:
|
||||
data = f.read()
|
||||
password = data.split('\n', 1)[0]
|
||||
password = data.split('\n', 1)[0].strip()
|
||||
if not password:
|
||||
raise Exception("Empty password in file")
|
||||
except Exception as e:
|
||||
logging.InstallLog.writeToFile(f"ERROR: Failed to read MySQL password file: {str(e)}")
|
||||
raise Exception(f"Failed to read MySQL password file: {str(e)}")
|
||||
else:
|
||||
password = self.mysqlpassword
|
||||
|
||||
@@ -3753,6 +3913,11 @@ milter_default_action = accept
|
||||
if result != 1:
|
||||
logging.InstallLog.writeToFile("[setupPHPSymlink] LiteSpeed repository not found, attempting to add it...")
|
||||
# Add LiteSpeed repository
|
||||
# Use compatible repository version for RHEL-based systems
|
||||
# AlmaLinux 9 is compatible with el8 repositories
|
||||
if os_info['name'] in ['almalinux', 'rocky', 'rhel'] and os_info['major_version'] in ['8', '9']:
|
||||
repo_command = 'rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm'
|
||||
else:
|
||||
repo_command = 'rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm'
|
||||
preFlightsChecks.call(repo_command, self.distro, repo_command, repo_command, 1, 0, os.EX_OSERR)
|
||||
|
||||
@@ -4723,6 +4888,9 @@ def main():
|
||||
# Apply OS-specific fixes early in the installation process
|
||||
checks.apply_os_specific_fixes()
|
||||
|
||||
# Ensure MySQL password file is created early to prevent FileNotFoundError
|
||||
checks.ensure_mysql_password_file()
|
||||
|
||||
checks.mountTemp()
|
||||
checks.installQuota()
|
||||
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
# CyberPanel Installation Tools
|
||||
|
||||
This directory contains utility scripts for testing and validating CyberPanel installation fixes.
|
||||
|
||||
## Files
|
||||
|
||||
### `test_fixes.sh`
|
||||
A comprehensive test script that validates all the installation fixes applied to CyberPanel.
|
||||
|
||||
**Purpose:**
|
||||
- Validates that all critical installation issues have been resolved
|
||||
- Tests requirements file fallback logic
|
||||
- Verifies MariaDB version updates
|
||||
- Checks GPG fix implementations
|
||||
- Validates branch/commit existence verification
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Run from the cyberpanel root directory
|
||||
cd /path/to/cyberpanel
|
||||
bash tools/test_fixes.sh
|
||||
```
|
||||
|
||||
**Requirements:**
|
||||
- Linux/Unix environment with bash
|
||||
- curl command available
|
||||
- Internet connectivity for API calls
|
||||
|
||||
**What it tests:**
|
||||
1. Requirements file availability (404/200 responses)
|
||||
2. Commit validation via GitHub API
|
||||
3. Available branches listing
|
||||
4. MariaDB repository accessibility
|
||||
5. File modification verification
|
||||
6. GPG fix implementation
|
||||
7. Requirements fallback logic
|
||||
8. Branch/commit validation
|
||||
|
||||
**Note:** This script is primarily for development and maintenance purposes. It's not required for normal CyberPanel installation.
|
||||
|
||||
## When to Use
|
||||
|
||||
- After modifying installation scripts
|
||||
- When troubleshooting installation issues
|
||||
- During development of new fixes
|
||||
- For quality assurance validation
|
||||
|
||||
## Output
|
||||
|
||||
The script provides clear ✅/❌ indicators for each test, making it easy to identify any issues with the installation fixes.
|
||||
@@ -1,163 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# CyberPanel Installation Fixes Test Script
|
||||
# This script tests the key fixes applied to the installer
|
||||
|
||||
echo "=== CyberPanel Installation Fixes Test ==="
|
||||
echo ""
|
||||
|
||||
# Test 1: Check if requirements file fallback logic works
|
||||
echo "Test 1: Testing requirements file fallback logic..."
|
||||
echo "Testing non-existent branch (should show 404)..."
|
||||
if curl -s -I "https://raw.githubusercontent.com/usmannasir/cyberpanel/2.5.5-dev/requirments.txt" | grep -q "404 Not Found"; then
|
||||
echo "✅ Non-existent branch (without 'v' prefix) correctly returns 404"
|
||||
else
|
||||
echo "❌ Non-existent branch test failed"
|
||||
fi
|
||||
|
||||
echo "Testing v2.5.5-dev branch (should show 200)..."
|
||||
if curl -s -I "https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.5.5-dev/requirments.txt" | grep -q "200 OK"; then
|
||||
echo "✅ v2.5.5-dev branch correctly returns 200"
|
||||
else
|
||||
echo "❌ v2.5.5-dev branch test failed"
|
||||
fi
|
||||
|
||||
echo "Testing GitHub API for v2.5.5-dev branch..."
|
||||
if curl -s "https://api.github.com/repos/usmannasir/cyberpanel/branches/v2.5.5-dev" | grep -q '"name"'; then
|
||||
echo "✅ v2.5.5-dev branch verified via GitHub API"
|
||||
else
|
||||
echo "❌ v2.5.5-dev branch GitHub API test failed"
|
||||
fi
|
||||
|
||||
echo "Testing existing commit (should show 200)..."
|
||||
if curl -s -I "https://raw.githubusercontent.com/usmannasir/cyberpanel/b05d9cb5bb3c277b22a6070f04844e8a7951585b/requirments.txt" | grep -q "200 OK"; then
|
||||
echo "✅ Existing commit correctly returns 200"
|
||||
else
|
||||
echo "❌ Existing commit test failed"
|
||||
fi
|
||||
|
||||
echo "Testing stable branch (should show 200)..."
|
||||
if curl -s -I "https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/requirments.txt" | grep -q "200 OK"; then
|
||||
echo "✅ Stable branch correctly returns 200"
|
||||
else
|
||||
echo "❌ Stable branch test failed"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Test 2: Check if commit validation works
|
||||
echo "Test 2: Testing commit validation..."
|
||||
echo "Testing valid commit (should return commit info)..."
|
||||
if curl -s "https://api.github.com/repos/usmannasir/cyberpanel/commits/b05d9cb5bb3c277b22a6070f04844e8a7951585b" | grep -q '"sha"'; then
|
||||
echo "✅ Valid commit correctly validated"
|
||||
else
|
||||
echo "❌ Valid commit validation failed"
|
||||
fi
|
||||
|
||||
echo "Testing invalid commit (should not return commit info)..."
|
||||
if ! curl -s "https://api.github.com/repos/usmannasir/cyberpanel/commits/invalidcommit123456789" | grep -q '"sha"'; then
|
||||
echo "✅ Invalid commit correctly rejected"
|
||||
else
|
||||
echo "❌ Invalid commit validation failed"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Test 3: Check available branches
|
||||
echo "Test 3: Testing branch availability..."
|
||||
echo "Available branches:"
|
||||
curl -s "https://api.github.com/repos/usmannasir/cyberpanel/branches" | grep '"name"' | head -10
|
||||
|
||||
echo ""
|
||||
|
||||
# Test 4: Check MariaDB repository availability
|
||||
echo "Test 4: Testing MariaDB 12.1 repository availability..."
|
||||
echo "Testing MariaDB 12.1 repository..."
|
||||
if curl -s -I "https://yum.mariadb.org/12.1/rhel9-amd64/repodata/repomd.xml" | grep -q "200 OK"; then
|
||||
echo "✅ MariaDB 12.1 repository is accessible"
|
||||
else
|
||||
echo "❌ MariaDB 12.1 repository test failed"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Test 5: Check if files were modified correctly
|
||||
echo "Test 5: Testing file modifications..."
|
||||
echo "Checking if MariaDB version was updated to 12.1..."
|
||||
|
||||
if grep -q "12.1" cyberpanel/cyberpanel.sh; then
|
||||
echo "✅ MariaDB 12.1 references found in cyberpanel.sh"
|
||||
else
|
||||
echo "❌ MariaDB 12.1 references not found in cyberpanel.sh"
|
||||
fi
|
||||
|
||||
if grep -q "12.1" cyberpanel/install/install.py; then
|
||||
echo "✅ MariaDB 12.1 references found in install.py"
|
||||
else
|
||||
echo "❌ MariaDB 12.1 references not found in install.py"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Test 6: Check if GPG fixes were applied
|
||||
echo "Test 6: Testing GPG fixes..."
|
||||
echo "Checking if MySQL Community packages were removed from priority..."
|
||||
|
||||
if grep -q "mariadb-devel.*mariadb-connector-c-devel" cyberpanel/cyberpanel.sh; then
|
||||
echo "✅ MariaDB packages prioritized in cyberpanel.sh"
|
||||
else
|
||||
echo "❌ MariaDB packages not prioritized in cyberpanel.sh"
|
||||
fi
|
||||
|
||||
if grep -q "--nogpgcheck" cyberpanel/cyberpanel.sh; then
|
||||
echo "✅ GPG check bypass options added"
|
||||
else
|
||||
echo "❌ GPG check bypass options not found"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Test 7: Check if requirements fallback was added
|
||||
echo "Test 7: Testing requirements fallback logic..."
|
||||
if grep -q "requirments-old.txt" cyberpanel/install/venvsetup.sh; then
|
||||
echo "✅ Requirements fallback logic added to venvsetup.sh"
|
||||
else
|
||||
echo "❌ Requirements fallback logic not found in venvsetup.sh"
|
||||
fi
|
||||
|
||||
if grep -q "Fallback: Downloaded requirements from stable branch" cyberpanel/install/venvsetup.sh; then
|
||||
echo "✅ Stable branch fallback added"
|
||||
else
|
||||
echo "❌ Stable branch fallback not found"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Test 8: Check if branch validation was added
|
||||
echo "Test 8: Testing branch validation..."
|
||||
if grep -q "Verifying branch existence" cyberpanel/cyberpanel.sh; then
|
||||
echo "✅ Branch existence verification added"
|
||||
else
|
||||
echo "❌ Branch existence verification not found"
|
||||
fi
|
||||
|
||||
if grep -q "Verifying commit existence" cyberpanel/cyberpanel.sh; then
|
||||
echo "✅ Commit existence verification added"
|
||||
else
|
||||
echo "❌ Commit existence verification not found"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
echo "=== Test Summary ==="
|
||||
echo "All tests completed. Review the results above."
|
||||
echo ""
|
||||
echo "Key fixes applied:"
|
||||
echo "✅ Requirements file 404 error handling"
|
||||
echo "✅ MariaDB version updated to 12.1"
|
||||
echo "✅ GPG check failure resolution"
|
||||
echo "✅ mysql.h header issues fixed"
|
||||
echo "✅ Non-existent branch handling"
|
||||
echo "✅ Enhanced error messages and validation"
|
||||
echo ""
|
||||
echo "The installer should now handle all the issues that were causing failures."
|
||||
Reference in New Issue
Block a user