diff --git a/README.md b/README.md index 94789d5c0..821334b65 100755 --- a/README.md +++ b/README.md @@ -14,132 +14,87 @@ Web Hosting Control Panel powered by OpenLiteSpeed, designed to simplify hosting - ๐ง **Email Support** (SnappyMail). - ๐ **File Manager** for quick file access. - ๐ **PHP Management** made easy. -- ๐ **Firewall** (โ FirewallD & ConfigServer Firewall Integration). +- ๐ **Firewall** (รขลโฆ FirewallD & ConfigServer Firewall Integration). - ๐ **One-click Backups and Restores**. +- ๐ณ **Docker Management** with command execution capabilities. +- ๐ค **AI-Powered Security Scanner** for enhanced protection. + +--- + +## ๐ **Documentation & Guides** + +CyberPanel comes with comprehensive documentation and step-by-step guides: + +- ๐ **[Complete Guides Index](guides/INDEX.md)** - All available documentation in one place +- ๐ณ **[Docker Command Execution](guides/Docker_Command_Execution_Guide.md)** - Execute commands in Docker containers +- ๐ค **[AI Scanner Setup](guides/AIScannerDocs.md)** - Configure AI-powered security scanning +- ๐ง **[Mautic Installation](guides/MAUTIC_INSTALLATION_GUIDE.md)** - Email marketing platform setup --- ## ๐ข Supported PHP Versions -CyberPanel supports PHP versions based on your operating system: +CyberPanel supports a wide range of PHP versions across different operating systems: -### โ๏ธ **PHP 8.0 and Above** -- Fully supported on modern systems such as Ubuntu 22.04 and AlmaLinux 9.x and higher. +### โ๏ธ **Currently Supported PHP Versions** -### โ๏ธ **PHP 7.4 and Below** -- Compatible with AlmaLinux 8, Ubuntu 18.04, and similar environments. +- **PHP 8.5** - Latest stable version (EOL: Dec 2028) +- **PHP 8.4** - Stable version (EOL: Dec 2027) +- **PHP 8.3** - Stable version (EOL: Dec 2027) +- **PHP 8.2** - Stable version (EOL: Dec 2026) +- **PHP 8.1** - Stable version (EOL: Dec 2025) +- **PHP 8.0** - Legacy support (EOL: Nov 2023) +- **PHP 7.4** - Legacy support (EOL: Nov 2022) -### Adding PHP Versions as Third-Party Add-ons +### ๐ง **Third-Party PHP Add-ons** -Some PHP versions can be added to operating systems as third-party packages using external repositories or tools. Here's an overview by OS: +For additional PHP versions or specific requirements, you can install third-party packages: -#### **Ubuntu**: -- **Ubuntu 22.04**: - - Highest: PHP 8.5 (default repository or Ondrej's PPA). - - Lowest: PHP 7.4 (via Ondrej's PPA). -- **Ubuntu 20.04**: - - Highest: PHP 8.5 (default repository or Ondrej's PPA). - - Lowest: PHP 7.0 (via Ondrej's PPA). -- **Ubuntu 18.04**: - - Highest: PHP 8.4 (via Ondrej's PPA). - - Lowest: PHP 5.6 (via Ondrej's PPA). +#### **Ubuntu/Debian** -#### **AlmaLinux**: -- **AlmaLinux 9**: - - Highest: PHP 8.5 (default repository or Remi repository). - - Lowest: PHP 7.4 (via Remi repository). -- **AlmaLinux 8**: - - Highest: PHP 8.4 (default repository or Remi repository). - - Lowest: PHP 5.6 (via Remi repository). +- **Ondrej's PPA**: Provides PHP 5.6 to 8.5 +- **Sury's PPA**: Alternative repository with latest PHP versions -#### **CentOS**: -- **CentOS 9**: - - Highest: PHP 8.4 (via Remi repository). - - Lowest: PHP 7.4 (via Remi repository). -- **CentOS 8**: - - Highest: PHP 8.4 (via Remi repository). - - Lowest: PHP 5.6 (via Remi repository). -- **CentOS 7**: - - Highest: PHP 8.0 (via Remi repository). - - Lowest: PHP 5.4 (via Remi repository). +#### **RHEL-based Systems** (AlmaLinux, RockyLinux, CentOS, RHEL) -#### **RHEL**: -- **RHEL 9**: - - Highest: PHP 8.4 (via Remi repository). - - Lowest: PHP 7.4 (via Remi repository). -- **RHEL 8**: - - Highest: PHP 8.4 (via Remi repository). - - Lowest: PHP 5.6 (via Remi repository). +- **Remi Repository**: Comprehensive PHP package collection +- **EPEL Repository**: Additional packages for enterprise Linux -#### **RockyLinux**: -- **RockyLinux 8**: - - Highest: PHP 8.5 (via Remi repository). - - Lowest: PHP 5.6 (via Remi repository). +#### **CloudLinux** -#### **CloudLinux**: -- **CloudLinux 8**: - - Highest: PHP 8.5 (via Remi repository). - - Lowest: PHP 5.6 (via Remi repository). -- **CloudLinux 7**: - - Highest: PHP 8.0 (via Remi repository). - - Lowest: PHP 5.4 (via Remi repository). +- **CloudLinux PHP Selector**: Built-in tool for managing multiple PHP versions +- **Remi Repository**: Additional PHP versions and extensions -#### **openEuler**: -- **openEuler 22.03**: - - Highest: PHP 8.4 (default repository). - - Lowest: PHP 7.4 (default repository). -- **openEuler 20.03**: - - Highest: PHP 7.3 (default repository). - - Lowest: PHP 7.0 (default repository). - -### Full List of PHP Versions and End of Life (EOL) Dates: -- โจ **PHP 8.5** - EOL: 31 Dec 2028. -- โจ **PHP 8.4** - EOL: 31 Dec 2027. -- โจ **PHP 8.3** - EOL: 31 Dec 2027. -- โจ **PHP 8.2** - EOL: 31 Dec 2026. -- โจ **PHP 8.1** - EOL: 31 Dec 2025. -- ๐ **PHP 8.0** - EOL: 26 Nov 2023. -- ๐ **PHP 7.4** - EOL: 28 Nov 2022. -- ๐ **PHP 7.3** - EOL: 6 Dec 2021. -- ๐ **PHP 7.2** - EOL: 30 Nov 2020. -- ๐ **PHP 7.1** - EOL: 1 Dec 2019. -- ๐ **PHP 7.0** - EOL: 10 Jan 2019. -- ๐ **PHP 5.6** - EOL: 31 Dec 2018. -- ๐ **PHP 5.5** - EOL: 21 Jul 2016. -- ๐ **PHP 5.4** - EOL: 3 Sep 2015. -- ๐ **PHP 5.3** - EOL: 14 Aug 2014. +> **Note**: Third-party repositories may provide additional PHP versions beyond what's available in default repositories. Always verify compatibility with your specific use case. --- -## ๐ Supported OS Versions +## ๐ Supported Operating Systems CyberPanel runs on x86_64 architecture and supports the following operating systems: -### **Ubuntu**: -- Ubuntu 22.04 โ Supported until April 2027. -- Ubuntu 20.04 โ Supported until April 2025. -- Ubuntu 18.04 ๐ EOL: 31 May 2023. +### **โ Currently Supported** -### **CentOS**: -- CentOS 9 โ EOL: 31 May 2027. -- CentOS 8 ๐ EOL: 31 Dec 2021. -- CentOS 7 ๐ EOL: 30 June 2024. +- **Ubuntu 22.04** - Supported until April 2027 +- **Ubuntu 20.04** - Supported until April 2025 +- **AlmaLinux 9** - Supported until May 2032 +- **AlmaLinux 8** - Supported until May 2029 +- **RockyLinux 9** - Supported until May 2032 +- **RockyLinux 8** - Supported until May 2029 +- **RHEL 9** - Supported until May 2032 +- **RHEL 8** - Supported until May 2029 +- **CloudLinux 8** - Supported until May 2029 +- **CentOS 9** - Supported until May 2027 -### **RHEL**: -- RHEL 9 โ EOL: 31 May 2032. -- RHEL 8 โ EOL: 31 May 2029. +### **๐ง Third-Party OS Support** -### **AlmaLinux**: -- AlmaLinux 9 โ EOL: 31 May 2032. -- AlmaLinux 8 โ EOL: 31 May 2029. +Additional operating systems may be supported through third-party repositories or community efforts: -### **Other OS**: -- RockyLinux 9 โ EOL: 31 May 2032. -- RockyLinux 8 โ EOL: 31 May 2029. -- CloudLinux 8 โ EOL: 31 May 2029. -- CloudLinux 7 ๐ EOL: 1 Jul 2024. -- openEuler 22.03 ๐ EOL: March 2024. -- openEuler 20.03 ๐ EOL: April 2022. +- **Debian** - May work with Ubuntu-compatible packages +- **openEuler** - Community-supported with limited testing +- **Other RHEL derivatives** - May work with AlmaLinux/RockyLinux packages + +> **Note**: For unsupported operating systems, compatibility is not guaranteed. Always test in a non-production environment first. --- @@ -168,10 +123,26 @@ sh <(curl https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgr - ๐ [Official Site](https://cyberpanel.net) - โ๏ธ [Docs (Old)](https://docs.cyberpanel.net) - ๐ [Docs (New)](https://community.cyberpanel.net/docs) +- ๐ [Additional Guides](guides/INDEX.md) - Detailed guides for Docker, AI Scanner, Mautic, and more +- ๐ [Local Documentation](guides/) - All guides available in this repository - โ [Changelog](https://community.cyberpanel.net/t/change-logs/161) - ๐ฌ [Forums](https://community.cyberpanel.net) - ๐ข [Discord](https://discord.gg/g8k8Db3) - ๐ต [Facebook Group](https://www.facebook.com/groups/cyberpanel) - ๐ฅ [YouTube Channel](https://www.youtube.com/@Cyber-Panel) ---- \ No newline at end of file +### ๐ **Quick Start Guides** + +- ๐ณ [Docker Command Execution](guides/Docker_Command_Execution_Guide.md) - Execute commands in Docker containers +- ๐ค [AI Scanner Setup](guides/AIScannerDocs.md) - Configure AI-powered security scanning +- ๐ง [Mautic Installation](guides/MAUTIC_INSTALLATION_GUIDE.md) - Email marketing platform setup +- ๐ [All Guides Index](guides/INDEX.md) - Complete documentation hub + +### ๐ **Direct Guide Links** + +| Feature | Guide | Description | +| ----------- | ---------------------------------------------------------- | ------------------------------ | +| ๐ณ Docker | [Command Execution](guides/Docker_Command_Execution_Guide.md) | Execute commands in containers | +| ๐ค Security | [AI Scanner](guides/AIScannerDocs.md) | AI-powered security scanning | +| ๐ง Email | [Mautic Setup](guides/MAUTIC_INSTALLATION_GUIDE.md) | Email marketing platform | +| ๐ All | [Complete Index](guides/INDEX.md) | Browse all available guides | diff --git a/dockerManager/container.py b/dockerManager/container.py index 746fecd3c..292372b75 100644 --- a/dockerManager/container.py +++ b/dockerManager/container.py @@ -1319,4 +1319,97 @@ class ContainerManager(multi.Thread): except BaseException as msg: data_ret = {'removeImageStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + def executeContainerCommand(self, userID=None, data=None): + """ + Execute a command inside a running Docker container + """ + try: + name = data['name'] + command = data['command'] + + # Check if container is registered in database or unlisted + if Containers.objects.filter(name=name).exists(): + if ACLManager.checkContainerOwnership(name, userID) != 1: + return ACLManager.loadErrorJson('commandStatus', 0) + + client = docker.from_env() + dockerAPI = docker.APIClient() + + try: + container = client.containers.get(name) + except docker.errors.NotFound as err: + data_ret = {'commandStatus': 0, 'error_message': 'Container does not exist'} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + except: + data_ret = {'commandStatus': 0, 'error_message': 'Unknown error'} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + # Check if container is running + if container.status != 'running': + data_ret = {'commandStatus': 0, 'error_message': 'Container must be running to execute commands'} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + try: + # Execute command in container + # Split command into parts for proper execution + import shlex + command_parts = shlex.split(command) + + # Execute command with proper shell + exec_result = container.exec_run( + command_parts, + stdout=True, + stderr=True, + stdin=False, + tty=False, + privileged=False, + user='', + detach=False, + demux=False, + workdir=None, + environment=None + ) + + # Get output and exit code + output = exec_result.output.decode('utf-8') if exec_result.output else '' + exit_code = exec_result.exit_code + + # Format the response + if exit_code == 0: + data_ret = { + 'commandStatus': 1, + 'error_message': 'None', + 'output': output, + 'exit_code': exit_code, + 'command': command + } + else: + data_ret = { + 'commandStatus': 1, + 'error_message': 'Command executed with non-zero exit code', + 'output': output, + 'exit_code': exit_code, + 'command': command + } + + json_data = json.dumps(data_ret, ensure_ascii=False) + return HttpResponse(json_data) + + except docker.errors.APIError as err: + data_ret = {'commandStatus': 0, 'error_message': f'Docker API error: {str(err)}'} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + except Exception as err: + data_ret = {'commandStatus': 0, 'error_message': f'Execution error: {str(err)}'} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + except BaseException as msg: + data_ret = {'commandStatus': 0, 'error_message': str(msg)} + json_data = json.dumps(data_ret) return HttpResponse(json_data) \ No newline at end of file diff --git a/dockerManager/static/dockerManager/dockerManager.js b/dockerManager/static/dockerManager/dockerManager.js index 5ecb7cbf3..3f7131450 100644 --- a/dockerManager/static/dockerManager/dockerManager.js +++ b/dockerManager/static/dockerManager/dockerManager.js @@ -976,6 +976,101 @@ app.controller('viewContainer', function ($scope, $http, $interval, $timeout) { } }; + // Command execution functionality + $scope.commandToExecute = ''; + $scope.executingCommand = false; + $scope.commandOutput = null; + $scope.commandHistory = []; + + $scope.showCommandModal = function() { + $scope.commandToExecute = ''; + $scope.commandOutput = null; + $("#commandModal").modal("show"); + }; + + $scope.executeCommand = function() { + if (!$scope.commandToExecute.trim()) { + new PNotify({ + title: 'Error', + text: 'Please enter a command to execute', + type: 'error' + }); + return; + } + + $scope.executingCommand = true; + $scope.commandOutput = null; + + url = "/docker/executeContainerCommand"; + var data = { + name: $scope.cName, + command: $scope.commandToExecute.trim() + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + console.log(response); + $scope.executingCommand = false; + + if (response.data.commandStatus === 1) { + $scope.commandOutput = { + command: response.data.command, + output: response.data.output, + exit_code: response.data.exit_code + }; + + // Add to command history + $scope.commandHistory.unshift({ + command: response.data.command, + timestamp: new Date() + }); + + // Keep only last 10 commands + if ($scope.commandHistory.length > 10) { + $scope.commandHistory = $scope.commandHistory.slice(0, 10); + } + + // Show success notification + new PNotify({ + title: 'Command Executed', + text: 'Command completed with exit code: ' + response.data.exit_code, + type: response.data.exit_code === 0 ? 'success' : 'warning' + }); + } + else { + new PNotify({ + title: 'Command Execution Failed', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialData(response) { + $scope.executingCommand = false; + new PNotify({ + title: 'Command Execution Failed', + text: 'Could not connect to server', + type: 'error' + }); + } + }; + + $scope.selectCommand = function(command) { + $scope.commandToExecute = command; + }; + + $scope.clearOutput = function() { + $scope.commandOutput = null; + }; + }); diff --git a/dockerManager/templates/dockerManager/viewContainer.html b/dockerManager/templates/dockerManager/viewContainer.html index 5b020744c..2a80be27b 100644 --- a/dockerManager/templates/dockerManager/viewContainer.html +++ b/dockerManager/templates/dockerManager/viewContainer.html @@ -756,6 +756,11 @@