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

V2.5.5 dev
This commit is contained in:
Master3395
2025-09-24 01:46:21 +02:00
committed by GitHub
3 changed files with 178 additions and 17 deletions

View File

@@ -454,7 +454,7 @@ gpgcheck=1
EOF
elif [[ "$Server_OS_Version" = "9" ]] && uname -m | grep -q 'x86_64'; then
# Use official MariaDB repository setup script for RHEL 9+ systems
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- --mariadb-server-version='10.11' --skip-maxscale --skip-tools
curl -sS "https://downloads.mariadb.com/MariaDB/mariadb_repo_setup" | bash -s -- --mariadb-server-version="10.11" --skip-maxscale --skip-tools
if [ $? -ne 0 ]; then
# Fallback to manual setup
cat <<EOF >/etc/yum.repos.d/MariaDB.repo
@@ -471,7 +471,7 @@ EOF
fi
elif [[ "$Server_OS_Version" = "10" ]] && uname -m | grep -q 'x86_64'; then
# Use official MariaDB repository setup script for RHEL 10+ systems
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- --mariadb-server-version='10.11' --skip-maxscale --skip-tools
curl -sS "https://downloads.mariadb.com/MariaDB/mariadb_repo_setup" | bash -s -- --mariadb-server-version="10.11" --skip-maxscale --skip-tools
if [ $? -ne 0 ]; then
# Fallback to manual setup
cat <<EOF >/etc/yum.repos.d/MariaDB.repo
@@ -1567,7 +1567,7 @@ if [[ "$Server_OS" =~ ^(CentOS|RHEL|AlmaLinux|RockyLinux|CloudLinux|openEuler) ]
# Setup MariaDB repository for RHEL 9+ based systems (AlmaLinux 9/10, RockyLinux 9, RHEL 9)
if [[ "$Server_OS" =~ ^(AlmaLinux9|AlmaLinux10|RockyLinux9|RHEL9) ]] ; then
# Use the official MariaDB repository setup script for better compatibility
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- --mariadb-server-version='10.11' --skip-maxscale --skip-tools
curl -sS "https://downloads.mariadb.com/MariaDB/mariadb_repo_setup" | bash -s -- --mariadb-server-version="10.11" --skip-maxscale --skip-tools
Check_Return "MariaDB repository setup" "no_exit"
# Fallback manual repository setup if the script fails
@@ -2276,11 +2276,17 @@ fi
Post_Install_Addon_Mecached_LSMCD() {
install_dev_tools
# Install SASL development headers for LSMCD compilation
# Install development headers for LSMCD compilation
if [[ "$Server_OS" =~ ^(CentOS|RHEL|AlmaLinux|RockyLinux|CloudLinux|openEuler) ]] ; then
dnf install -y cyrus-sasl-devel cyrus-sasl-lib cyrus-sasl-gssapi cyrus-sasl-plain || yum install -y cyrus-sasl-devel cyrus-sasl-lib cyrus-sasl-gssapi cyrus-sasl-plain
# Install libmemcached dependencies
dnf install -y libmemcached libmemcached-devel libmemcached-libs || yum install -y libmemcached libmemcached-devel libmemcached-libs
# Install expat development headers
dnf install -y expat-devel || yum install -y expat-devel
elif [[ "$Server_OS" = "Ubuntu" ]] ; then
apt-get install -y libsasl2-dev libsasl2-modules
apt-get install -y libmemcached-dev libmemcached11
apt-get install -y libexpat1-dev
fi
wget -O lsmcd-master.zip https://cyberpanel.sh/codeload.github.com/litespeedtech/lsmcd/zip/master
@@ -2289,13 +2295,59 @@ Post_Install_Addon_Mecached_LSMCD() {
cd "$Current_Dir/lsmcd-master" || exit
./fixtimestamp.sh
./configure CFLAGS=" -O3" CXXFLAGS=" -O3"
make
make install
# Compile LSMCD
if make; then
echo "LSMCD compilation successful"
if make install; then
echo "LSMCD installation successful"
# Create systemd service file for LSMCD
cat > /etc/systemd/system/lsmcd.service << 'EOF'
[Unit]
Description=LiteSpeed Memcached (LSMCD)
After=network.target
[Service]
Type=forking
PIDFile=/var/run/lsmcd.pid
ExecStart=/usr/local/bin/lsmcd -d
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
# Reload systemd and enable LSMCD service
systemctl daemon-reload
systemctl enable lsmcd
systemctl start lsmcd
if systemctl is-active --quiet lsmcd; then
echo "LSMCD service started successfully"
touch /home/cyberpanel/lsmcd
else
echo "Warning: LSMCD service failed to start"
fi
else
echo "Error: LSMCD installation failed"
fi
else
echo "Error: LSMCD compilation failed"
fi
cd "$Current_Dir" || exit
manage_service "lsmcd" "enable"
manage_service "lsmcd" "start"
log_info "LSMCD installation completed"
# Only manage service if it was successfully installed
if systemctl list-unit-files | grep -q "lsmcd.service"; then
manage_service "lsmcd" "enable"
manage_service "lsmcd" "start"
log_info "LSMCD installation completed successfully"
else
log_warning "LSMCD installation failed - service not registered"
fi
log_function_end "Post_Install_Addon_Mecached_LSMCD"
}

View File

@@ -1063,7 +1063,7 @@ class Migration(migrations.Migration):
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
# Fix SnappyMail public directory ownership early
command = "chown -R lscpd:lscpd /usr/local/CyberCP/public/snappymail/data 2>/dev/null || true"
command = "chown -R lscpd:lscpd /usr/local/CyberCP/public/snappymail/data || true"
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
snappymailinipath = '/usr/local/lscp/cyberpanel/snappymail/data/_data_/_default_/configs/application.ini'
@@ -1711,7 +1711,7 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
# Fix SnappyMail public directory ownership immediately after creation
command = "chown -R lscpd:lscpd /usr/local/CyberCP/public/snappymail/data 2>/dev/null || true"
command = "chown -R lscpd:lscpd /usr/local/CyberCP/public/snappymail/data || true"
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
command = "mkdir -p /usr/local/lscp/cyberpanel/rainloop/data"
@@ -2541,10 +2541,28 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
def installOpenDKIM(self):
try:
if self.distro == cent8 or self.distro == openeuler or self.distro == ubuntu:
# Install dependencies first
if self.distro == ubuntu:
deps = ['libmilter-dev', 'libmemcached-dev']
for dep in deps:
try:
self.install_package(dep)
except:
pass
self.install_package('opendkim opendkim-tools')
else:
self.install_package('opendkim')
# Install dependencies for RHEL-based systems
deps = ['sendmail-milter', 'sendmail-milter-devel', 'libmemcached', 'libmemcached-devel']
for dep in deps:
try:
self.install_package(dep, '--skip-broken')
except:
pass
if self.distro == cent8 or self.distro == openeuler:
self.install_package('opendkim opendkim-tools', '--skip-broken')
else:
self.install_package('opendkim', '--skip-broken')
command = 'mkdir -p /etc/opendkim/keys/'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
@@ -3605,6 +3623,9 @@ def main():
checks.setup_cron()
checks.installRestic()
checks.installAcme()
# Fix Django AutoField warnings
checks.fix_django_autofield_warnings()
## Install and Configure OpenDKIM.
@@ -3690,7 +3711,7 @@ echo $oConfig->Save() ? 'Done' : 'Error';
subprocess.call(shlex.split(command))
# Fix SnappyMail public directory ownership (critical fix)
command = "chown -R lscpd:lscpd /usr/local/CyberCP/public/snappymail/data 2>/dev/null || true"
command = "chown -R lscpd:lscpd /usr/local/CyberCP/public/snappymail/data || true"
subprocess.call(shlex.split(command))
except:
pass
@@ -3721,12 +3742,13 @@ def show_installation_summary():
# Check component status
components = {
"CyberPanel Core": check_service_status("lscpd"),
"OpenLiteSpeed": check_service_status("lsws"),
"OpenLiteSpeed": check_openlitespeed_status(),
"MariaDB/MySQL": check_service_status("mysql") or check_service_status("mariadb"),
"PowerDNS": check_service_status("pdns") or check_service_status("pdns-server"),
"Pure-FTPd": check_service_status("pure-ftpd"),
"PowerDNS": check_powerdns_status(),
"Pure-FTPd": check_pureftpd_status(),
"Postfix": check_service_status("postfix"),
"Dovecot": check_service_status("dovecot"),
"LSMCD": check_service_status("lsmcd"),
"SnappyMail": check_file_exists("/usr/local/CyberCP/public/snappymail"),
"phpMyAdmin": check_file_exists("/usr/local/CyberCP/public/phpmyadmin")
}
@@ -3786,6 +3808,83 @@ def check_service_status(service_name):
except:
return False
def check_openlitespeed_status():
"""Check if OpenLiteSpeed is running (special case)"""
try:
# Check if lsws process is running
result = subprocess.run(['pgrep', '-f', 'litespeed'], capture_output=True, text=True)
if result.returncode == 0:
return True
# Check if lsws service is active
result = subprocess.run(['systemctl', 'is-active', 'lsws'], capture_output=True, text=True)
if result.returncode == 0:
return True
# Check if openlitespeed service is active
result = subprocess.run(['systemctl', 'is-active', 'openlitespeed'], capture_output=True, text=True)
if result.returncode == 0:
return True
return False
except:
return False
def check_powerdns_status():
"""Check if PowerDNS is running (special case)"""
try:
# Check if pdns process is running
result = subprocess.run(['pgrep', '-f', 'pdns'], capture_output=True, text=True)
if result.returncode == 0:
return True
# Check various PowerDNS service names
for service in ['pdns', 'pdns-server', 'powerdns']:
result = subprocess.run(['systemctl', 'is-active', service], capture_output=True, text=True)
if result.returncode == 0:
return True
return False
except:
return False
def check_pureftpd_status():
"""Check if Pure-FTPd is running (special case)"""
try:
# Check if pure-ftpd process is running
result = subprocess.run(['pgrep', '-f', 'pure-ftpd'], capture_output=True, text=True)
if result.returncode == 0:
return True
# Check various Pure-FTPd service names
for service in ['pure-ftpd', 'pureftpd']:
result = subprocess.run(['systemctl', 'is-active', service], capture_output=True, text=True)
if result.returncode == 0:
return True
return False
except:
return False
def fix_django_autofield_warnings():
"""Fix Django AutoField warnings by setting DEFAULT_AUTO_FIELD"""
try:
settings_file = '/usr/local/CyberCP/cyberpanel/settings.py'
if os.path.exists(settings_file):
with open(settings_file, 'r') as f:
content = f.read()
# Add DEFAULT_AUTO_FIELD setting if not present
if 'DEFAULT_AUTO_FIELD' not in content:
with open(settings_file, 'a') as f:
f.write('\n# Fix Django AutoField warnings\n')
f.write('DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"\n')
logging.InstallLog.writeToFile("[fix_django_autofield_warnings] Added DEFAULT_AUTO_FIELD setting")
except Exception as e:
logging.InstallLog.writeToFile(f"[ERROR] {str(e)} [fix_django_autofield_warnings]")
def check_file_exists(file_path):
"""Check if a file or directory exists"""

View File

@@ -460,6 +460,16 @@ class InstallCyberPanel:
except:
pass
# Create mbstring configuration for each PHP version
try:
mbstring_config = f'/usr/local/lsws/lsphp{version}/etc/php.d/20-mbstring.ini'
if not os.path.exists(mbstring_config):
os.makedirs(os.path.dirname(mbstring_config), exist_ok=True)
with open(mbstring_config, 'w') as f:
f.write('extension=mbstring\n')
except:
pass
elif self.distro == centos:
# Install PHP 7.4 only (legacy support)
self.install_package('lsphp74*', '--skip-broken')