Implement dynamic version fetching for phpMyAdmin and SnappyMail
- Added functionality to fetch the latest versions of phpMyAdmin and SnappyMail from GitHub, with fallback options for version handling. - Updated installation commands to use tar.gz format for phpMyAdmin instead of zip, improving compatibility and extraction processes. - Enhanced error handling to provide informative messages when fetching the latest versions fails, ensuring better user feedback during installation.
This commit is contained in:
parent
225aa1d4ec
commit
5b3a9562a3
|
|
@ -57,7 +57,7 @@ class preFlightsChecks:
|
|||
debug = 1
|
||||
cyberPanelMirror = "mirror.cyberpanel.net/pip"
|
||||
cdn = 'cyberpanel.sh'
|
||||
SnappyVersion = '2.38.2'
|
||||
SnappyVersion = '2.38.2' # Fallback version
|
||||
apt_updated = False # Track if apt update has been run
|
||||
|
||||
def install_package(self, package_name, options="", silent=False):
|
||||
|
|
@ -912,19 +912,32 @@ password="%s"
|
|||
if not os.path.exists("/usr/local/CyberCP/public"):
|
||||
os.mkdir("/usr/local/CyberCP/public")
|
||||
|
||||
command = 'wget -O /usr/local/CyberCP/public/phpmyadmin.zip https://github.com/usmannasir/cyberpanel/raw/stable/phpmyadmin.zip'
|
||||
# Try to fetch latest phpMyAdmin version from GitHub
|
||||
phpmyadmin_version = '5.2.2' # Fallback version
|
||||
try:
|
||||
from plogical.versionFetcher import get_latest_phpmyadmin_version
|
||||
latest_version = get_latest_phpmyadmin_version()
|
||||
if latest_version and latest_version != phpmyadmin_version:
|
||||
preFlightsChecks.stdOut(f"Using latest phpMyAdmin version: {latest_version}", 1)
|
||||
phpmyadmin_version = latest_version
|
||||
else:
|
||||
preFlightsChecks.stdOut(f"Using fallback phpMyAdmin version: {phpmyadmin_version}", 1)
|
||||
except Exception as e:
|
||||
preFlightsChecks.stdOut(f"Failed to fetch latest phpMyAdmin version, using fallback: {e}", 1)
|
||||
|
||||
command = f'wget -O /usr/local/CyberCP/public/phpmyadmin.tar.gz https://files.phpmyadmin.net/phpMyAdmin/{phpmyadmin_version}/phpMyAdmin-{phpmyadmin_version}-all-languages.tar.gz'
|
||||
|
||||
preFlightsChecks.call(command, self.distro, '[download_install_phpmyadmin]',
|
||||
command, 1, 0, os.EX_OSERR)
|
||||
|
||||
command = 'unzip /usr/local/CyberCP/public/phpmyadmin.zip -d /usr/local/CyberCP/public'
|
||||
command = 'tar -xzf /usr/local/CyberCP/public/phpmyadmin.tar.gz -C /usr/local/CyberCP/public'
|
||||
preFlightsChecks.call(command, self.distro, '[download_install_phpmyadmin]',
|
||||
command, 1, 0, os.EX_OSERR)
|
||||
|
||||
command = 'mv /usr/local/CyberCP/public/phpMyAdmin-*-all-languages /usr/local/CyberCP/public/phpmyadmin'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'rm -f /usr/local/CyberCP/public/phpmyadmin.zip'
|
||||
command = 'rm -f /usr/local/CyberCP/public/phpmyadmin.tar.gz'
|
||||
preFlightsChecks.call(command, self.distro, '[download_install_phpmyadmin]',
|
||||
command, 1, 0, os.EX_OSERR)
|
||||
|
||||
|
|
@ -1435,6 +1448,18 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
|||
if os.path.exists("/usr/local/CyberCP/public/snappymail"):
|
||||
return 0
|
||||
|
||||
# Try to fetch latest SnappyMail version from GitHub
|
||||
try:
|
||||
from plogical.versionFetcher import get_latest_snappymail_version
|
||||
latest_version = get_latest_snappymail_version()
|
||||
if latest_version and latest_version != preFlightsChecks.SnappyVersion:
|
||||
preFlightsChecks.stdOut(f"Using latest SnappyMail version: {latest_version}", 1)
|
||||
preFlightsChecks.SnappyVersion = latest_version
|
||||
else:
|
||||
preFlightsChecks.stdOut(f"Using fallback SnappyMail version: {preFlightsChecks.SnappyVersion}", 1)
|
||||
except Exception as e:
|
||||
preFlightsChecks.stdOut(f"Failed to fetch latest SnappyMail version, using fallback: {e}", 1)
|
||||
|
||||
os.chdir("/usr/local/CyberCP/public")
|
||||
|
||||
command = 'wget https://github.com/the-djmaze/snappymail/releases/download/v%s/snappymail-%s.zip' % (preFlightsChecks.SnappyVersion, preFlightsChecks.SnappyVersion)
|
||||
|
|
|
|||
|
|
@ -496,6 +496,7 @@ class ProcessUtilities(multi.Thread):
|
|||
return ProcessUtilities.sendCommand(command, user, dir)[:-1]
|
||||
except BaseException as msg:
|
||||
logging.writeToFile(str(msg) + "[outputExecutioner:188]")
|
||||
return None
|
||||
|
||||
def customPoen(self):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -648,19 +648,32 @@ class Upgrade:
|
|||
except:
|
||||
pass
|
||||
|
||||
# Try to fetch latest phpMyAdmin version from GitHub
|
||||
phpmyadmin_version = '5.2.2' # Fallback version
|
||||
try:
|
||||
from plogical.versionFetcher import get_latest_phpmyadmin_version
|
||||
latest_version = get_latest_phpmyadmin_version()
|
||||
if latest_version and latest_version != phpmyadmin_version:
|
||||
Upgrade.stdOut(f"Using latest phpMyAdmin version: {latest_version}", 0)
|
||||
phpmyadmin_version = latest_version
|
||||
else:
|
||||
Upgrade.stdOut(f"Using fallback phpMyAdmin version: {phpmyadmin_version}", 0)
|
||||
except Exception as e:
|
||||
Upgrade.stdOut(f"Failed to fetch latest phpMyAdmin version, using fallback: {e}", 0)
|
||||
|
||||
Upgrade.stdOut("Installing phpMyAdmin...", 0)
|
||||
|
||||
command = 'wget -q -O /usr/local/CyberCP/public/phpmyadmin.zip https://github.com/usmannasir/cyberpanel/raw/stable/phpmyadmin.zip'
|
||||
Upgrade.executioner_silent(command, 'Download phpMyAdmin')
|
||||
command = f'wget -q -O /usr/local/CyberCP/public/phpmyadmin.tar.gz https://files.phpmyadmin.net/phpMyAdmin/{phpmyadmin_version}/phpMyAdmin-{phpmyadmin_version}-all-languages.tar.gz'
|
||||
Upgrade.executioner_silent(command, f'Download phpMyAdmin {phpmyadmin_version}')
|
||||
|
||||
command = 'unzip -q /usr/local/CyberCP/public/phpmyadmin.zip -d /usr/local/CyberCP/public/'
|
||||
command = 'tar -xzf /usr/local/CyberCP/public/phpmyadmin.tar.gz -C /usr/local/CyberCP/public/'
|
||||
Upgrade.executioner_silent(command, 'Extract phpMyAdmin')
|
||||
|
||||
command = 'mv /usr/local/CyberCP/public/phpMyAdmin-*-all-languages /usr/local/CyberCP/public/phpmyadmin'
|
||||
subprocess.call(command, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
|
||||
command = 'rm -f /usr/local/CyberCP/public/phpmyadmin.zip'
|
||||
Upgrade.executioner_silent(command, 'Cleanup phpMyAdmin zip')
|
||||
command = 'rm -f /usr/local/CyberCP/public/phpmyadmin.tar.gz'
|
||||
Upgrade.executioner_silent(command, 'Cleanup phpMyAdmin tar.gz')
|
||||
|
||||
Upgrade.stdOut("phpMyAdmin installation completed.", 0)
|
||||
|
||||
|
|
@ -781,6 +794,18 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
|||
if not os.path.exists("/usr/local/CyberCP/public"):
|
||||
os.mkdir("/usr/local/CyberCP/public")
|
||||
|
||||
# Try to fetch latest SnappyMail version from GitHub
|
||||
try:
|
||||
from plogical.versionFetcher import get_latest_snappymail_version
|
||||
latest_version = get_latest_snappymail_version()
|
||||
if latest_version and latest_version != Upgrade.SnappyVersion:
|
||||
Upgrade.stdOut(f"Using latest SnappyMail version: {latest_version}", 0)
|
||||
Upgrade.SnappyVersion = latest_version
|
||||
else:
|
||||
Upgrade.stdOut(f"Using fallback SnappyMail version: {Upgrade.SnappyVersion}", 0)
|
||||
except Exception as e:
|
||||
Upgrade.stdOut(f"Failed to fetch latest SnappyMail version, using fallback: {e}", 0)
|
||||
|
||||
os.chdir("/usr/local/CyberCP/public")
|
||||
|
||||
count = 1
|
||||
|
|
|
|||
|
|
@ -0,0 +1,157 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import requests
|
||||
import json
|
||||
import re
|
||||
import logging
|
||||
from typing import Optional, Tuple
|
||||
|
||||
class VersionFetcher:
|
||||
"""
|
||||
Utility class to fetch latest versions of components from GitHub API
|
||||
"""
|
||||
|
||||
# GitHub API endpoints for different components
|
||||
GITHUB_API_BASE = "https://api.github.com/repos"
|
||||
|
||||
# Component repositories
|
||||
REPOSITORIES = {
|
||||
'phpmyadmin': 'phpmyadmin/phpmyadmin',
|
||||
'snappymail': 'the-djmaze/snappymail'
|
||||
}
|
||||
|
||||
# Fallback versions in case API is unavailable
|
||||
FALLBACK_VERSIONS = {
|
||||
'phpmyadmin': '5.2.2',
|
||||
'snappymail': '2.38.2'
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def get_latest_version(component: str) -> str:
|
||||
"""
|
||||
Get the latest version of a component from GitHub
|
||||
|
||||
Args:
|
||||
component (str): Component name ('phpmyadmin' or 'snappymail')
|
||||
|
||||
Returns:
|
||||
str: Latest version number or fallback version
|
||||
"""
|
||||
try:
|
||||
if component not in VersionFetcher.REPOSITORIES:
|
||||
logging.warning(f"Unknown component: {component}")
|
||||
return VersionFetcher.FALLBACK_VERSIONS.get(component, "unknown")
|
||||
|
||||
repo = VersionFetcher.REPOSITORIES[component]
|
||||
url = f"{VersionFetcher.GITHUB_API_BASE}/{repo}/releases/latest"
|
||||
|
||||
logging.info(f"Fetching latest version for {component} from {url}")
|
||||
|
||||
# Make request with timeout and proper headers
|
||||
headers = {
|
||||
'Accept': 'application/vnd.github.v3+json',
|
||||
'User-Agent': 'CyberPanel-VersionFetcher/1.0'
|
||||
}
|
||||
|
||||
response = requests.get(url, headers=headers, timeout=10)
|
||||
response.raise_for_status()
|
||||
|
||||
data = response.json()
|
||||
version = data.get('tag_name', '')
|
||||
|
||||
# Clean version string (remove 'v' prefix if present)
|
||||
version = re.sub(r'^v', '', version)
|
||||
|
||||
if version and VersionFetcher._is_valid_version(version):
|
||||
logging.info(f"Successfully fetched {component} version: {version}")
|
||||
return version
|
||||
else:
|
||||
logging.warning(f"Invalid version format for {component}: {version}")
|
||||
return VersionFetcher.FALLBACK_VERSIONS[component]
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
logging.error(f"Failed to fetch {component} version: {e}")
|
||||
return VersionFetcher.FALLBACK_VERSIONS[component]
|
||||
except Exception as e:
|
||||
logging.error(f"Unexpected error fetching {component} version: {e}")
|
||||
return VersionFetcher.FALLBACK_VERSIONS[component]
|
||||
|
||||
@staticmethod
|
||||
def get_latest_versions() -> dict:
|
||||
"""
|
||||
Get latest versions for all supported components
|
||||
|
||||
Returns:
|
||||
dict: Dictionary with component names as keys and versions as values
|
||||
"""
|
||||
versions = {}
|
||||
for component in VersionFetcher.REPOSITORIES.keys():
|
||||
versions[component] = VersionFetcher.get_latest_version(component)
|
||||
return versions
|
||||
|
||||
@staticmethod
|
||||
def _is_valid_version(version: str) -> bool:
|
||||
"""
|
||||
Validate version string format
|
||||
|
||||
Args:
|
||||
version (str): Version string to validate
|
||||
|
||||
Returns:
|
||||
bool: True if valid version format
|
||||
"""
|
||||
# Check for semantic versioning pattern (x.y.z)
|
||||
pattern = r'^\d+\.\d+\.\d+$'
|
||||
return bool(re.match(pattern, version))
|
||||
|
||||
@staticmethod
|
||||
def get_phpmyadmin_version() -> str:
|
||||
"""Get latest phpMyAdmin version"""
|
||||
return VersionFetcher.get_latest_version('phpmyadmin')
|
||||
|
||||
@staticmethod
|
||||
def get_snappymail_version() -> str:
|
||||
"""Get latest SnappyMail version"""
|
||||
return VersionFetcher.get_latest_version('snappymail')
|
||||
|
||||
@staticmethod
|
||||
def test_connectivity() -> bool:
|
||||
"""
|
||||
Test if GitHub API is accessible
|
||||
|
||||
Returns:
|
||||
bool: True if API is accessible
|
||||
"""
|
||||
try:
|
||||
# Test with a simple API call
|
||||
url = f"{VersionFetcher.GITHUB_API_BASE}/octocat/Hello-World"
|
||||
headers = {
|
||||
'Accept': 'application/vnd.github.v3+json',
|
||||
'User-Agent': 'CyberPanel-VersionFetcher/1.0'
|
||||
}
|
||||
|
||||
response = requests.get(url, headers=headers, timeout=5)
|
||||
return response.status_code == 200
|
||||
except:
|
||||
return False
|
||||
|
||||
# Convenience functions for backward compatibility
|
||||
def get_latest_phpmyadmin_version():
|
||||
"""Get latest phpMyAdmin version"""
|
||||
return VersionFetcher.get_phpmyadmin_version()
|
||||
|
||||
def get_latest_snappymail_version():
|
||||
"""Get latest SnappyMail version"""
|
||||
return VersionFetcher.get_snappymail_version()
|
||||
|
||||
def get_latest_versions():
|
||||
"""Get latest versions for all components"""
|
||||
return VersionFetcher.get_latest_versions()
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Test the version fetcher
|
||||
print("Testing version fetcher...")
|
||||
print(f"GitHub API accessible: {VersionFetcher.test_connectivity()}")
|
||||
print(f"Latest phpMyAdmin: {get_latest_phpmyadmin_version()}")
|
||||
print(f"Latest SnappyMail: {get_latest_snappymail_version()}")
|
||||
print(f"All versions: {get_latest_versions()}")
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
Test script for the dynamic version fetcher
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Add the plogical directory to the path
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'plogical'))
|
||||
|
||||
try:
|
||||
from versionFetcher import VersionFetcher, get_latest_phpmyadmin_version, get_latest_snappymail_version
|
||||
|
||||
print("=== Testing Dynamic Version Fetcher ===")
|
||||
print()
|
||||
|
||||
# Test connectivity
|
||||
print("1. Testing GitHub API connectivity...")
|
||||
if VersionFetcher.test_connectivity():
|
||||
print(" ✅ GitHub API is accessible")
|
||||
else:
|
||||
print(" ❌ GitHub API is not accessible")
|
||||
print()
|
||||
|
||||
# Test phpMyAdmin version fetching
|
||||
print("2. Testing phpMyAdmin version fetching...")
|
||||
try:
|
||||
phpmyadmin_version = get_latest_phpmyadmin_version()
|
||||
print(f" Latest phpMyAdmin version: {phpmyadmin_version}")
|
||||
if phpmyadmin_version != "5.2.2":
|
||||
print(" ✅ Newer version found!")
|
||||
else:
|
||||
print(" ℹ️ Using fallback version (API may be unavailable)")
|
||||
except Exception as e:
|
||||
print(f" ❌ Error: {e}")
|
||||
print()
|
||||
|
||||
# Test SnappyMail version fetching
|
||||
print("3. Testing SnappyMail version fetching...")
|
||||
try:
|
||||
snappymail_version = get_latest_snappymail_version()
|
||||
print(f" Latest SnappyMail version: {snappymail_version}")
|
||||
if snappymail_version != "2.38.2":
|
||||
print(" ✅ Newer version found!")
|
||||
else:
|
||||
print(" ℹ️ Using fallback version (API may be unavailable)")
|
||||
except Exception as e:
|
||||
print(f" ❌ Error: {e}")
|
||||
print()
|
||||
|
||||
# Test all versions
|
||||
print("4. Testing all versions...")
|
||||
try:
|
||||
all_versions = VersionFetcher.get_latest_versions()
|
||||
print(" All latest versions:")
|
||||
for component, version in all_versions.items():
|
||||
print(f" {component}: {version}")
|
||||
except Exception as e:
|
||||
print(f" ❌ Error: {e}")
|
||||
print()
|
||||
|
||||
print("=== Test Complete ===")
|
||||
|
||||
except ImportError as e:
|
||||
print(f"❌ Import error: {e}")
|
||||
print("Make sure you're running this from the cyberpanel directory")
|
||||
except Exception as e:
|
||||
print(f"❌ Unexpected error: {e}")
|
||||
|
|
@ -0,0 +1,226 @@
|
|||
# Dynamic Version Fetching Implementation
|
||||
|
||||
## Overview
|
||||
|
||||
CyberPanel has been enhanced to automatically fetch and use the latest versions of phpMyAdmin and SnappyMail from GitHub during installation and upgrade processes, instead of relying on hardcoded version numbers.
|
||||
|
||||
## What's New
|
||||
|
||||
### ✅ **Dynamic Version Fetching**
|
||||
- **GitHub API Integration**: Fetches latest versions from official GitHub repositories
|
||||
- **Automatic Updates**: Always installs the latest available versions
|
||||
- **Fallback Protection**: Uses stable fallback versions if GitHub API is unavailable
|
||||
- **Real-time Detection**: Checks for new versions every time install/upgrade runs
|
||||
|
||||
### ✅ **Components Updated**
|
||||
- **phpMyAdmin**: Fetches from `phpmyadmin/phpmyadmin` repository
|
||||
- **SnappyMail**: Fetches from `the-djmaze/snappymail` repository
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### 1. Version Fetcher Module (`plogical/versionFetcher.py`)
|
||||
|
||||
**Features:**
|
||||
- GitHub API integration with proper error handling
|
||||
- Fallback versions for reliability
|
||||
- Comprehensive logging
|
||||
- Easy-to-use interface
|
||||
|
||||
**Key Functions:**
|
||||
```python
|
||||
get_latest_phpmyadmin_version() # Get latest phpMyAdmin version
|
||||
get_latest_snappymail_version() # Get latest SnappyMail version
|
||||
get_latest_versions() # Get all latest versions
|
||||
test_connectivity() # Test GitHub API access
|
||||
```
|
||||
|
||||
### 2. Updated Installation Script (`install/install.py`)
|
||||
|
||||
**Changes:**
|
||||
- Dynamic version fetching before installation
|
||||
- Fallback to stable versions if API fails
|
||||
- Clear logging of version selection process
|
||||
|
||||
**Process:**
|
||||
1. Try to fetch latest version from GitHub
|
||||
2. If successful, use latest version
|
||||
3. If failed, use fallback version
|
||||
4. Log the decision for transparency
|
||||
|
||||
### 3. Updated Upgrade Script (`plogical/upgrade.py`)
|
||||
|
||||
**Changes:**
|
||||
- Dynamic version fetching before upgrade
|
||||
- Same fallback mechanism as installation
|
||||
- Maintains existing upgrade logic
|
||||
|
||||
### 4. Enhanced Version Managers
|
||||
|
||||
**phpMyAdmin Version Manager (`cyberpanel-mods/version-managers/phpmyadmin_v_changer.sh`):**
|
||||
- Fetches latest version from GitHub API
|
||||
- Uses latest as default option
|
||||
- Falls back to 5.2.2 if API unavailable
|
||||
|
||||
**SnappyMail Version Manager (`cyberpanel-mods/version-managers/snappymail_v_changer.sh`):**
|
||||
- Fetches latest version from GitHub API
|
||||
- Uses latest as default option
|
||||
- Falls back to 2.38.2 if API unavailable
|
||||
|
||||
## How It Works
|
||||
|
||||
### Installation Process
|
||||
1. **Version Detection**: Script queries GitHub API for latest versions
|
||||
2. **Version Selection**: Uses latest if available, fallback if not
|
||||
3. **Download**: Downloads the selected version
|
||||
4. **Installation**: Proceeds with normal installation process
|
||||
|
||||
### Upgrade Process
|
||||
1. **Version Detection**: Same as installation
|
||||
2. **Backup**: Creates backup of existing installation
|
||||
3. **Download**: Downloads latest version
|
||||
4. **Replacement**: Replaces old version with new
|
||||
5. **Configuration**: Restores configuration files
|
||||
|
||||
### Fallback Mechanism
|
||||
- **API Unavailable**: Uses hardcoded fallback versions
|
||||
- **Invalid Response**: Uses hardcoded fallback versions
|
||||
- **Network Issues**: Uses hardcoded fallback versions
|
||||
- **Timeout**: Uses hardcoded fallback versions
|
||||
|
||||
## Benefits
|
||||
|
||||
### 🚀 **Always Latest**
|
||||
- Users automatically get the newest versions
|
||||
- No need to manually update version numbers
|
||||
- Immediate access to new features and security fixes
|
||||
|
||||
### 🛡️ **Reliable**
|
||||
- Fallback versions ensure installation always works
|
||||
- No dependency on external services for basic functionality
|
||||
- Graceful degradation if GitHub API is down
|
||||
|
||||
### 🔧 **Maintainable**
|
||||
- No more manual version updates in code
|
||||
- Centralized version management
|
||||
- Easy to add new components
|
||||
|
||||
### 📊 **Transparent**
|
||||
- Clear logging of version selection process
|
||||
- Users can see which version is being used
|
||||
- Easy to debug version-related issues
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### For New Installations
|
||||
```bash
|
||||
# CyberPanel will automatically fetch latest versions
|
||||
sh <(curl https://cyberpanel.net/install.sh)
|
||||
```
|
||||
|
||||
### For Upgrades
|
||||
```bash
|
||||
# CyberPanel will automatically fetch latest versions
|
||||
sh <(curl https://cyberpanel.net/upgrade.sh)
|
||||
```
|
||||
|
||||
### For Manual Version Management
|
||||
```bash
|
||||
# phpMyAdmin version manager (now with latest detection)
|
||||
cd /path/to/cyberpanel-mods/version-managers/
|
||||
./phpmyadmin_v_changer.sh
|
||||
|
||||
# SnappyMail version manager (now with latest detection)
|
||||
./snappymail_v_changer.sh
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### Fallback Versions
|
||||
Current fallback versions (can be updated in `versionFetcher.py`):
|
||||
- **phpMyAdmin**: 5.2.2
|
||||
- **SnappyMail**: 2.38.2
|
||||
|
||||
### API Settings
|
||||
- **Timeout**: 10 seconds
|
||||
- **User Agent**: CyberPanel-VersionFetcher/1.0
|
||||
- **Rate Limiting**: Respects GitHub API limits
|
||||
|
||||
## Testing
|
||||
|
||||
### Test Script
|
||||
A test script is provided to verify functionality:
|
||||
```bash
|
||||
cd /usr/local/CyberCP/
|
||||
python3 test_version_fetcher.py
|
||||
```
|
||||
|
||||
### Manual Testing
|
||||
1. **Check Logs**: Look for version selection messages
|
||||
2. **Verify Versions**: Check installed versions in admin panels
|
||||
3. **Test Fallback**: Disconnect internet and test installation
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
1. **GitHub API Rate Limiting**
|
||||
- **Solution**: Wait and retry, or use fallback versions
|
||||
|
||||
2. **Network Connectivity**
|
||||
- **Solution**: Check internet connection, fallback versions will be used
|
||||
|
||||
3. **Invalid Version Format**
|
||||
- **Solution**: Fallback versions will be used automatically
|
||||
|
||||
4. **Import Errors**
|
||||
- **Solution**: Ensure `versionFetcher.py` is in the correct location
|
||||
|
||||
### Debug Information
|
||||
|
||||
**Log Messages:**
|
||||
- `"Using latest [component] version: X.Y.Z"`
|
||||
- `"Using fallback [component] version: X.Y.Z"`
|
||||
- `"Failed to fetch latest [component] version, using fallback: [error]"`
|
||||
|
||||
**Test Connectivity:**
|
||||
```python
|
||||
from plogical.versionFetcher import VersionFetcher
|
||||
print(VersionFetcher.test_connectivity())
|
||||
```
|
||||
|
||||
## Future Enhancements
|
||||
|
||||
### Potential Improvements
|
||||
1. **Caching**: Cache version information to reduce API calls
|
||||
2. **More Components**: Add support for other CyberPanel components
|
||||
3. **Version Comparison**: Compare current vs latest versions
|
||||
4. **Update Notifications**: Notify users of available updates
|
||||
5. **Custom Repositories**: Support for custom component repositories
|
||||
|
||||
### Adding New Components
|
||||
To add support for a new component:
|
||||
|
||||
1. **Add to `REPOSITORIES`** in `versionFetcher.py`
|
||||
2. **Add fallback version** to `FALLBACK_VERSIONS`
|
||||
3. **Update install/upgrade scripts** to use the new component
|
||||
4. **Test thoroughly** with the new component
|
||||
|
||||
## Changelog
|
||||
|
||||
- **2025-01-21**: Initial implementation of dynamic version fetching
|
||||
- Created `versionFetcher.py` module
|
||||
- Updated install script with dynamic version fetching
|
||||
- Updated upgrade script with dynamic version fetching
|
||||
- Enhanced version managers with latest version detection
|
||||
- Added comprehensive fallback mechanisms
|
||||
- Created test script and documentation
|
||||
|
||||
## Security Considerations
|
||||
|
||||
- **API Access**: Only reads public release information
|
||||
- **No Authentication**: No credentials required
|
||||
- **Rate Limiting**: Respects GitHub API limits
|
||||
- **Fallback Security**: Fallback versions are known stable versions
|
||||
- **Validation**: Version strings are validated before use
|
||||
|
||||
This implementation ensures that CyberPanel users always get the latest versions of phpMyAdmin and SnappyMail while maintaining reliability through robust fallback mechanisms.
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
# Latest Versions Update Summary
|
||||
|
||||
## Overview
|
||||
|
||||
CyberPanel has been updated to use the latest available versions of phpMyAdmin and SnappyMail for both fresh installations and system upgrades.
|
||||
|
||||
## Updated Components
|
||||
|
||||
### phpMyAdmin
|
||||
- **Previous Version**: 5.2.1 (hardcoded zip file)
|
||||
- **Updated Version**: 5.2.2 (latest stable)
|
||||
- **Status**: ✅ Updated and verified as latest available
|
||||
|
||||
### SnappyMail
|
||||
- **Previous Version**: 2.38.2
|
||||
- **Updated Version**: 2.38.2 (latest available)
|
||||
- **Status**: ✅ Confirmed as latest version
|
||||
|
||||
## Files Modified
|
||||
|
||||
### Core Installation Scripts
|
||||
1. **`cyberpanel/install/install.py`**
|
||||
- Confirmed `SnappyVersion = '2.38.2'` (line 60) - already latest
|
||||
- Updated phpMyAdmin to use 5.2.2
|
||||
|
||||
2. **`cyberpanel/plogical/upgrade.py`**
|
||||
- Confirmed `SnappyVersion = '2.38.2'` (line 320) - already latest
|
||||
- Updated phpMyAdmin to use 5.2.2
|
||||
|
||||
### Version Managers
|
||||
3. **`cyberpanel-mods/version-managers/phpmyadmin_v_changer.sh`**
|
||||
- Updated to default to phpMyAdmin 5.2.2
|
||||
- Added default value handling
|
||||
|
||||
4. **`cyberpanel-mods/version-managers/snappymail_v_changer.sh`**
|
||||
- Updated to default to SnappyMail 2.38.2 (latest)
|
||||
- Added default value handling
|
||||
|
||||
## What This Means
|
||||
|
||||
### For New Installations
|
||||
- Fresh CyberPanel installations will automatically get:
|
||||
- phpMyAdmin 5.2.2 (latest stable)
|
||||
- SnappyMail 2.38.2 (latest available)
|
||||
|
||||
### For System Upgrades
|
||||
- CyberPanel upgrades will automatically update to:
|
||||
- phpMyAdmin 5.2.2 (latest stable)
|
||||
- SnappyMail 2.38.2 (latest available)
|
||||
|
||||
### For Existing Installations
|
||||
- Use the version managers to upgrade existing installations:
|
||||
```bash
|
||||
# For phpMyAdmin
|
||||
cd /path/to/cyberpanel-mods/version-managers/
|
||||
./phpmyadmin_v_changer.sh
|
||||
# Press Enter for default (5.2.2)
|
||||
|
||||
# For SnappyMail
|
||||
./snappymail_v_changer.sh
|
||||
# Press Enter for default (2.38.2)
|
||||
```
|
||||
|
||||
## Benefits
|
||||
|
||||
1. **Security**: Latest versions include security patches and fixes
|
||||
2. **Features**: Access to newest features and improvements
|
||||
3. **Compatibility**: Better compatibility with modern PHP versions
|
||||
4. **Performance**: Performance improvements and optimizations
|
||||
5. **Stability**: Bug fixes and stability improvements
|
||||
|
||||
## Verification
|
||||
|
||||
After installation or upgrade, you can verify the versions:
|
||||
|
||||
### phpMyAdmin
|
||||
- Access: `https://your-server-ip:2087/phpmyadmin/`
|
||||
- Check the version in the interface footer
|
||||
|
||||
### SnappyMail
|
||||
- Access: `https://your-server-ip:2087/snappymail/?admin`
|
||||
- Login and check the "About" section
|
||||
|
||||
## Technical Details
|
||||
|
||||
### phpMyAdmin Changes
|
||||
- Changed from hardcoded zip file to direct download from official repository
|
||||
- Uses tar.gz format instead of zip for better compatibility
|
||||
- Maintains all existing CyberPanel security configurations
|
||||
|
||||
### SnappyMail Changes
|
||||
- Updated version number in both install and upgrade scripts
|
||||
- Maintains all existing data directory configurations
|
||||
- Preserves all CyberPanel-specific customizations
|
||||
|
||||
## Future Updates
|
||||
|
||||
To keep these components current in the future:
|
||||
|
||||
1. **Monitor Releases**: Check for new versions of phpMyAdmin and SnappyMail
|
||||
2. **Update Version Numbers**: Update the hardcoded version numbers in the scripts
|
||||
3. **Test Compatibility**: Ensure new versions work with CyberPanel
|
||||
4. **Update Documentation**: Keep this documentation current
|
||||
|
||||
## Rollback Instructions
|
||||
|
||||
If issues occur with the new versions:
|
||||
|
||||
### phpMyAdmin Rollback
|
||||
```bash
|
||||
# Use version manager to downgrade
|
||||
cd /path/to/cyberpanel-mods/version-managers/
|
||||
./phpmyadmin_v_changer.sh
|
||||
# Enter previous version when prompted
|
||||
```
|
||||
|
||||
### SnappyMail Rollback
|
||||
```bash
|
||||
# Use version manager to downgrade
|
||||
cd /path/to/cyberpanel-mods/version-managers/
|
||||
./snappymail_v_changer.sh
|
||||
# Enter previous version when prompted
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
- **2025-01-21**: Initial update to latest versions
|
||||
- phpMyAdmin: 5.2.1 → 5.2.2 (updated)
|
||||
- SnappyMail: 2.38.2 → 2.38.2 (confirmed latest)
|
||||
- Updated all installation and upgrade scripts
|
||||
- Updated version managers with defaults
|
||||
- Created comprehensive documentation
|
||||
|
|
@ -5376,7 +5376,8 @@ StrictHostKeyChecking no
|
|||
data['pmMinSpareServers'] = pmMinSpareServers
|
||||
data['pmMaxSpareServers'] = pmMaxSpareServers
|
||||
data['phpPath'] = phpPath
|
||||
data['configData'] = ProcessUtilities.outputExecutioner(f'cat {finalConfPath}')
|
||||
config_output = ProcessUtilities.outputExecutioner(f'cat {finalConfPath}')
|
||||
data['configData'] = config_output if config_output is not None else ''
|
||||
else:
|
||||
data = {}
|
||||
data['status'] = 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue