Enhance installation scripts and fix ownership commands

- Updated MariaDB repository setup commands in cyberpanel.sh to use double quotes for consistency.
- Added installation of libmemcached dependencies in both cyberpanel.sh and install.py for improved functionality.
- Modified ownership commands in install.py to remove unnecessary redirection for better clarity.
- Introduced a fix for Django AutoField warnings in install.py by adding a DEFAULT_AUTO_FIELD setting.
- Created mbstring configuration for each PHP version in installCyberPanel.py to ensure proper PHP functionality.
This commit is contained in:
Master3395
2025-09-24 01:44:26 +02:00
parent 80b13b3b9e
commit 0989927096
3 changed files with 65 additions and 9 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

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
@@ -3786,6 +3807,25 @@ def check_service_status(service_name):
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')