Commit Graph

55 Commits

Author SHA1 Message Date
usmannasir
888a7e0552 Add I/O limit support to resource limits
- Pass --io parameter to lscgctl with bytes/sec value
- Convert ioLimitMBPS from MB/s to bytes/s for lscgctl
- Update log message to include I/O limit information
- Add note about systemd io controller delegation requirement
2025-11-12 23:43:59 +05:00
usmannasir
94969f4e97 Improve lssetup auto-detection for LiteSpeed Containers
- Add test to verify LiteSpeed Containers is actually configured
- Check for 'You must configure LiteSpeed' error in lscgctl output
- Run lssetup with proper flags when configuration is needed
- Fixes issue where lscgctl exists but LiteSpeed Containers not configured
2025-11-11 22:36:15 +05:00
usmannasir
6d66e5739a Add RHEL 8 family cgroups v2 detection and enablement instructions
Detect RHEL 8, AlmaLinux 8, Rocky Linux 8, and CloudLinux 8 systems and provide
clear instructions when cgroups v2 needs manual enablement.

These systems have cgroups v2 backported to kernel 4.18 but it's disabled by
default. When detected without cgroups v2 enabled, the system now:

1. Detects RHEL 8 family by checking /etc/redhat-release
2. Verifies if cgroups v2 is mounted (checks 'mount' output for 'cgroup2')
3. If not enabled, logs detailed instructions:
   - grubby command to add kernel parameter
   - Reboot instruction
   - Verification command
   - Clear step-by-step guide

Changes:
- _check_rhel8_cgroups_v2(): New method for RHEL 8 family detection
- _ensure_cgroups_enabled(): Calls RHEL 8 check before general checks
- check_cgroup_support(): Returns RHEL 8 status in support dict
  - rhel8_family: bool (detected RHEL 8 family)
  - rhel8_needs_enablement: bool (cgroups v2 not mounted)
  - os_name: str (full OS name from release file)

OS Support Status:
 Ubuntu 20.04+ - Native cgroups v2 (kernel 5.4+)
 RHEL/Alma/Rocky 9+ - Native cgroups v2 (kernel 5.14+)
⚠️ RHEL/Alma/Rocky/CloudLinux 8 - Needs manual enable (kernel 4.18 backported)
2025-11-11 17:27:11 +05:00
usmannasir
e61236c8a2 Add resource limits columns to upgrade script
Add database migrations for 7 new resource limit fields in packages_package table
to support users upgrading from older CyberPanel versions:
- memoryLimitMB (default: 1024)
- cpuCores (default: 1)
- ioLimitMBPS (default: 10)
- inodeLimit (default: 400000)
- maxConnections (default: 10)
- procSoftLimit (default: 400)
- procHardLimit (default: 500)

These columns are automatically added during upgrade via CLMigrations() function.
Uses try/except to safely handle cases where columns already exist.
2025-11-11 17:23:05 +05:00
usmannasir
c679d6ab10 Add comprehensive resource limits with automatic OpenLiteSpeed cgroups setup
This commit implements per-package resource limits for CyberPanel shared hosting
using OpenLiteSpeed's native cgroups v2 integration with automatic server configuration.

Features:
- 7 new package fields: memoryLimitMB, cpuCores, ioLimitMBPS, inodeLimit,
  maxConnections, procSoftLimit, procHardLimit
- Automatic OLS cgroups setup (no manual server configuration required)
- Multi-layer enforcement: OLS config + kernel cgroups v2 + filesystem quotas
- Per-user enforcement (subdomains/addon domains share parent's limits)
- Graceful degradation if cgroups unavailable
- Automatic backup of OLS config before modification

Backend Changes:
- packages/models.py: Added 7 resource limit fields with defaults
- packages/packagesManager.py: CRUD operations for resource limits
- plogical/resourceLimits.py: NEW - Resource manager with auto-setup
  * _ensure_cgroups_enabled(): Automatic OLS cgroups configuration
  * set_user_limits(): Apply limits via lscgctl
  * remove_user_limits(): Cleanup on deletion
  * set_inode_limit(): Filesystem quota management
- plogical/vhostConfs.py: Parameterized hardcoded resource limits
- plogical/vhost.py: Updated signatures to accept resource limits
- plogical/virtualHostUtilities.py: Extract and apply package limits


Frontend Changes:
- packages/templates/packages/createPackage.html: Resource limits UI
- packages/templates/packages/modifyPackage.html: Resource limits UI
- packages/static/packages/packages.js: AngularJS controller updates

Automatic Setup Flow:
When creating a website with enforceDiskLimits=True:
1. Check kernel cgroups v2 support
2. Run lssetup if lscgctl missing
3. Enable cgroups in OLS config if needed
4. Backup and modify /usr/local/lsws/conf/httpd_config.conf
5. Graceful restart of OpenLiteSpeed
6. Apply per-user limits via lscgctl
7. Set inode quotas via setquota

Requirements:
- Linux kernel 5.2+ (cgroups v2)
- OpenLiteSpeed 1.8+ (with lsns support)
- quota tools (optional, for inode limits)

Backward Compatibility:
- Existing packages receive default values via migration
- No manual setup required for new installations
- Graceful fallback if cgroups unavailable
2025-11-11 17:14:39 +05:00
usmannasir
ea0ee3f771 Add custom OLS binary installation to upgrade process
- Port custom binary installation methods from install to upgrade.py
- Automatically install/upgrade custom OLS binaries during CyberPanel upgrades
- Add architecture detection, download, installation, and module configuration
- Create automatic backups before upgrading binaries
- Enable .htaccess PHP config support for existing OpenLiteSpeed installations
- Make upgrade.py fully independent from installCyberPanel.py
2025-11-06 20:40:07 +05:00
usmannasir
0100d3ea5b add aiscanner file patcher 2025-10-26 01:56:36 +05:00
usmannasir
369f6d539b Fix acme.sh not creating domain configurations in /root/.acme.sh/
Separate acme.sh certificate issuance and installation steps to ensure
domain configurations are properly stored. Previously, combining --issue
with --cert-file/--key-file/--fullchain-file in a single command caused
acme.sh to skip storing domain configs, breaking automatic renewals and
requiring manual certificate recreation for domain aliases.
2025-10-22 12:53:05 +05:00
usmannasir
4983decba5 bug fix: ssl timeout issues 2025-10-19 23:51:55 +05:00
usmannasir
9d0d5fbd35 Fix backup restore permission error and improve SFTP fallback
- Ensure /home/cyberpanel directory exists with proper permissions before download
- Set directory permissions to 755 to allow application write access
- Refactor SCP/SFTP fallback logic to work regardless of debug mode
- Add better status messages during download process
2025-10-15 04:30:43 +05:00
usmannasir
32db00d1ae Fix backup file moving to handle compressed database backups
- Check for .sql.gz files first, then fallback to .sql
- Also move .backup.json metadata files alongside compressed backups
- Maintains backward compatibility with legacy .sql backups
2025-10-15 00:56:45 +05:00
usmannasir
7864ef63c1 Remove strict exit code checking in database restore functions
- MySQL restore may return warnings that don't indicate actual failure
- Database restoration verification is handled by subsequent password operations
- Improves reliability of compressed backup restoration
2025-10-15 00:53:31 +05:00
usmannasir
10edef5d87 Fix compressed database backup verification logic
- Changed from checking exit code to verifying file existence and size
- Resolves issue where successful mysqldump was incorrectly reported as failed
- Ensures backup file is created and not empty before marking as successful
2025-10-15 00:50:55 +05:00
usmannasir
cac2e09fce Enhance database backup with compression support and backward compatibility
- Added configurable compression for database backups using gzip streaming
- Implemented auto-detection in restore function for compressed and uncompressed formats
- Added performance optimizations including --single-transaction and --extended-insert
- Created configuration file for gradual feature rollout with safe defaults
- Added helper functions for checking system capabilities and configuration
- Included comprehensive test suite to verify backward compatibility
- Maintained 100% backward compatibility with existing backup infrastructure
2025-10-14 19:54:11 +05:00
usmannasir
fb02243245 Improve One-Click Backup verification with multi-method approach
- Implement timestamp-based filename verification (Method 1)
- Add file size validation with 1KB minimum requirement (Method 2)
- Filter to only check today's backup directory for accuracy (Method 3)
- Add optional SHA256 checksum verification for integrity (Method 5)
- Use find command with size filter for efficient SSH verification
- Fallback to SFTP with comprehensive file validation
- Enhanced logging for all verification steps and failures
- Remove unused 'Yesterday' variable that was never used
- Prevents false positives from old backup files
- Detects corrupted/incomplete backups via size check
2025-10-14 18:49:41 +05:00
usmannasir
c9b711d5bd Fix critical bug in One-Click Backup failure notification logic
- Fix inverted .find() logic that sent notifications when backups SUCCEEDED
- Add 'status': 'failed' field required by platform API
- Change HTTP to HTTPS for BackupFailedNotify endpoint
- Add comprehensive error handling and logging
- Add 30-second timeout on API requests
- Properly handle actualDomain vs site.domain.domain cases
2025-10-14 16:23:41 +05:00
usmannasir
fb16f4cf56 bug fix: staging site issue 2025-09-22 13:31:20 +05:00
Master3395
583680ff90 Fix monthly bandwidth for websites
Fix monthly bandwidth for websites:
https://github.com/usmannasir/cyberpanel/issues/1496
2025-09-12 10:41:11 +02:00
Master3395
41ead838ef Add sieve by default.
Add sieve by default.
2025-09-10 20:01:52 +02:00
Master3395
0c8ee38c2b Add Almalinux 10 and php 84+85
Add Almalinux 10 and php 84+85
2025-09-07 22:57:53 +02:00
usmannasir
2a9ad35d06 bug fix: php manager turning off uploads 2025-09-03 13:27:00 +05:00
usmannasir
c1f742425c bug fix: imuinfy restore after upgrade 2025-09-03 12:59:55 +05:00
usmannasir
07d86ac549 bug fix: imuinfy restore after upgrade 2025-09-03 02:04:36 +05:00
usmannasir
af2ff95739 bug fix: imuinfy restore after upgrade 2025-09-03 01:41:32 +05:00
usmannasir
195dac046f bug fix: imuinfy restore after upgrade 2025-09-03 01:32:06 +05:00
usmannasir
f13a1b8c20 bug fix: imuinfy restore after upgrade 2025-09-03 01:19:09 +05:00
usmannasir
6d7a86fb58 bug fix: imuinfy restore after upgrade 2025-09-03 01:11:11 +05:00
usmannasir
7fbb5f9123 bug fix: imuinfy restore after upgrade 2025-09-03 01:03:37 +05:00
usmannasir
4aff5fbd3a bug fix: imuinfy restore after upgrade 2025-09-02 23:34:16 +05:00
usmannasir
9a38b98ca9 v2.4.4 release 2025-09-01 13:11:42 +05:00
usmannasir
06653ab77c ubuntu 24 ftp fix 2025-08-29 22:30:06 +05:00
usmannasir
d799449849 ubuntu 24 support inside cyberpanel 2025-08-29 22:24:13 +05:00
usmannasir
cd9792c941 feat: Add comprehensive recovery mechanism for damaged CyberPanel installations during upgrade
- Implement directory integrity checks to detect missing CyberPanel components
- Add automatic recovery by cloning fresh repository when essential directories are lost
- Create database credential recovery with automatic password reset capability
- Update all service configurations (FTP, PowerDNS, Postfix, Dovecot) when password is reset
- Add service restart functionality to apply new configurations
- Preserve existing configuration files during recovery process
- Handle both Ubuntu (root password) and CentOS (separate password) database configurations

This ensures upgrades can complete successfully even when /usr/local/CyberCP is completely lost.
2025-08-23 16:02:19 +05:00
usmannasir
be3c66128c bug fix: postfix/dovecot on alma9 2025-08-19 18:36:48 +05:00
usmannasir
00f2565745 bug fix: https://github.com/usmannasir/cyberpanel/issues/1479#issuecomment-3185937407 2025-08-14 20:54:38 +05:00
usmannasir
e6541df356 bug fix: https://github.com/usmannasir/cyberpanel/issues/1479#issuecomment-3185937407 2025-08-14 20:50:05 +05:00
usmannasir
94bd6f7b5d bug fix: upgrade missing acl file 2025-08-13 23:35:40 +05:00
usmannasir
a4791035d0 Remove CSF support as it's being discontinued on August 31, 2025
- Remove CSF menu item from sidebar navigation
- Disable CSF-related URL endpoints in firewall module
- Update upgrade process to automatically remove CSF and restore firewalld
- Archive CSF template and configuration files
- Clean up CSF references in settings and upgrade scripts

CSF (ConfigServer Security & Firewall) is shutting down on August 31, 2025.
This commit removes CSF integration and ensures firewalld is restored as the
default firewall solution during upgrades.

Fixes #1473
2025-08-11 15:49:31 +05:00
usmannasir
d64ccc381e bug fix: https://github.com/usmannasir/cyberpanel/issues/773 2025-08-11 00:33:25 +05:00
usmannasir
753f4f0606 Fix: Preserve new INSTALLED_APPS during upgrade by not overwriting settings.py
The issue was that restoreCriticalFiles was restoring the OLD settings.py from backup
which didn't have new apps like 'aiScanner' in INSTALLED_APPS.

Solution:
- Modified restoreCriticalFiles to skip settings.py restoration
- Keep the NEW settings.py from the fresh clone (which has aiScanner in INSTALLED_APPS)
- Only update the DATABASES section with saved credentials from backup
- This preserves all new app registrations while maintaining database connectivity

This properly fixes the RuntimeError about aiScanner.status_models.ScanStatusUpdate
not being in INSTALLED_APPS after upgrades.
2025-08-08 22:54:44 +05:00
usmannasir
63371be011 Fix settings.py preservation during upgrade to maintain INSTALLED_APPS
During the upgrade process, settings.py was being overwritten with only the DATABASES
section preserved, causing loss of INSTALLED_APPS and other configurations. This resulted
in the 'aiScanner' app not being recognized after upgrade.

Fixed by:
- Improving the regex pattern to more accurately match only the DATABASES dictionary
- Adding re.DOTALL flag to handle multi-line DATABASES configuration
- Ensuring all other settings including INSTALLED_APPS are preserved during upgrade

This resolves the RuntimeError about aiScanner.status_models.ScanStatusUpdate not having
an explicit app_label.
2025-08-08 22:44:42 +05:00
usmannasir
00885d24a8 bug fix: https://github.com/usmannasir/cyberpanel/issues/1470 2025-08-08 04:03:18 +05:00
usmannasir
651324b464 bug fix: https://github.com/usmannasir/cyberpanel/issues/1471 2025-08-08 00:56:41 +05:00
usmannasir
8fcf18279b bug fix: https://github.com/usmannasir/cyberpanel/issues/1471 2025-08-08 00:25:18 +05:00
usmannasir
0704e97ff8 bug fixes to wp installation 2025-08-07 06:58:48 +05:00
usmannasir
10ff04bae6 bug fix: https://github.com/usmannasir/cyberpanel/issues/1468 2025-08-06 14:56:58 +05:00
usmannasir
440c084672 bug fix: setup wizard 2025-08-04 00:44:51 +05:00
usmannasir
a7126d6150 potential bug fix in upgrade 2025-08-03 22:37:39 +05:00
usmannasir
aeef20d89c potential bug fix in upgrade 2025-08-03 15:06:16 +05:00
usmannasir
c22c3c5f76 potential bug fix in upgrade 2025-08-03 14:55:00 +05:00