mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-10-26 00:36:34 +02:00
improve docs, fix links, and add container console support
This update improves documentation clarity, fixes broken documentation links, and introduces a new feature that allows you to access and use the console directly inside containers from CyberPanel.
This commit is contained in:
171
README.md
171
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)
|
||||
|
||||
---
|
||||
### 📖 **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 |
|
||||
|
||||
@@ -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)
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -756,6 +756,11 @@
|
||||
<i class="fas fa-terminal action-icon" style="color: #ec4899;"></i>
|
||||
<div class="action-text">{% trans "Processes" %}</div>
|
||||
</div>
|
||||
|
||||
<div class="action-btn" ng-click="showCommandModal()" ng-disabled="status!='running'">
|
||||
<i class="fas fa-code action-icon" style="color: #10b981;"></i>
|
||||
<div class="action-text">{% trans "Run Command" %}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -957,6 +962,94 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Command Execution Modal -->
|
||||
<div id="commandModal" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">
|
||||
<i class="fas fa-code" style="margin-right: 0.5rem;"></i>
|
||||
{% trans "Execute Command" %}
|
||||
</h4>
|
||||
<button type="button" class="close" data-dismiss="modal"
|
||||
style="font-size: 1.5rem; background: transparent; border: none;">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="commandInput" class="control-label">
|
||||
<i class="fas fa-terminal" style="margin-right: 0.5rem;"></i>
|
||||
{% trans "Command to execute" %}
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<input type="text"
|
||||
id="commandInput"
|
||||
class="form-control"
|
||||
ng-model="commandToExecute"
|
||||
placeholder="Enter command (e.g., ls -la, ps aux, whoami, env)"
|
||||
ng-keyup="$event.keyCode === 13 && executeCommand()"
|
||||
style="font-family: 'Courier New', monospace;">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-outline-secondary" type="button" ng-click="executeCommand()" ng-disabled="!commandToExecute || executingCommand">
|
||||
<i class="fas fa-play" ng-hide="executingCommand"></i>
|
||||
<i class="fas fa-spinner fa-spin" ng-show="executingCommand"></i>
|
||||
{% trans "Execute" %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<small class="form-text text-muted">
|
||||
{% trans "Commands will be executed inside the running container. Use proper shell syntax." %}
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<!-- Command History -->
|
||||
<div class="form-group" ng-show="commandHistory.length > 0">
|
||||
<label class="control-label">
|
||||
<i class="fas fa-history" style="margin-right: 0.5rem;"></i>
|
||||
{% trans "Command History" %}
|
||||
</label>
|
||||
<div class="command-history">
|
||||
<div class="history-item"
|
||||
ng-repeat="cmd in commandHistory track by $index"
|
||||
ng-click="selectCommand(cmd.command)"
|
||||
style="cursor: pointer; padding: 0.25rem 0.5rem; margin: 0.125rem 0; background: #f8f9fa; border-radius: 4px; border-left: 3px solid #007bff;">
|
||||
<code style="font-size: 0.875rem;">{{ cmd.command }}</code>
|
||||
<small class="text-muted" style="float: right;">{{ cmd.timestamp | date:'short' }}</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Output Display -->
|
||||
<div class="form-group" ng-show="commandOutput">
|
||||
<label class="control-label">
|
||||
<i class="fas fa-terminal" style="margin-right: 0.5rem;"></i>
|
||||
{% trans "Command Output" %}
|
||||
</label>
|
||||
<div class="terminal-output" style="background: #1a202c; color: #e2e8f0; padding: 1rem; border-radius: 8px; font-family: 'Courier New', monospace; font-size: 0.875rem; max-height: 300px; overflow-y: auto; white-space: pre-wrap;">
|
||||
<div ng-show="commandOutput.exit_code !== undefined" style="margin-bottom: 0.5rem;">
|
||||
<span style="color: #68d391;">$</span> <span style="color: #fbb6ce;">{{ commandOutput.command }}</span>
|
||||
<span style="color: #a0aec0; margin-left: 1rem;">(exit code: {{ commandOutput.exit_code }})</span>
|
||||
</div>
|
||||
<div ng-bind="commandOutput.output"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" ng-click="executeCommand()" ng-disabled="!commandToExecute || executingCommand">
|
||||
<i class="fas fa-play" ng-hide="executingCommand"></i>
|
||||
<i class="fas fa-spinner fa-spin" ng-show="executingCommand"></i>
|
||||
{% trans "Execute Command" %}
|
||||
</button>
|
||||
<button type="button" class="btn btn-secondary" ng-click="clearOutput()" ng-disabled="!commandOutput">
|
||||
<i class="fas fa-trash"></i> {% trans "Clear Output" %}
|
||||
</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">
|
||||
<i class="fas fa-times"></i> {% trans "Close" %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -36,6 +36,7 @@ urlpatterns = [
|
||||
path('recreateappcontainer', views.recreateappcontainer, name='recreateappcontainer'),
|
||||
path('RestartContainerAPP', views.RestartContainerAPP, name='RestartContainerAPP'),
|
||||
path('StopContainerAPP', views.StopContainerAPP, name='StopContainerAPP'),
|
||||
path('executeContainerCommand', views.executeContainerCommand, name='executeContainerCommand'),
|
||||
|
||||
# Docker Container Actions
|
||||
path('startContainer', startContainer, name='startContainer'),
|
||||
|
||||
@@ -537,6 +537,24 @@ def StopContainerAPP(request):
|
||||
cm = ContainerManager()
|
||||
coreResult = cm.StopContainerAPP(userID, json.loads(request.body))
|
||||
|
||||
return coreResult
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
@preDockerRun
|
||||
def executeContainerCommand(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
cm = ContainerManager()
|
||||
coreResult = cm.executeContainerCommand(userID, json.loads(request.body))
|
||||
|
||||
return coreResult
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
146
guides/Docker_Command_Execution_Guide.md
Normal file
146
guides/Docker_Command_Execution_Guide.md
Normal file
@@ -0,0 +1,146 @@
|
||||
# Docker Command Execution Feature for CyberPanel
|
||||
|
||||
## Overview
|
||||
This feature adds the ability to execute commands inside running Docker containers directly from the CyberPanel web interface. This is particularly useful for applications like Honeygain that require specific command-line arguments to function properly.
|
||||
|
||||
## Features Added
|
||||
|
||||
### 1. Backend Components
|
||||
- **New View Function**: `executeContainerCommand` in `dockerManager/views.py`
|
||||
- **New Container Method**: `executeContainerCommand` in `dockerManager/container.py`
|
||||
- **New URL Pattern**: `/docker/executeContainerCommand` in `dockerManager/urls.py`
|
||||
|
||||
### 2. Frontend Components
|
||||
- **New Action Button**: "Run Command" button in Container Actions section
|
||||
- **Command Execution Modal**: Interactive modal for executing commands
|
||||
- **Command History**: Tracks last 10 executed commands
|
||||
- **Real-time Output**: Displays command output with proper formatting
|
||||
|
||||
### 3. Security Features
|
||||
- **Permission Checks**: Only admin users can execute commands
|
||||
- **Container Ownership**: Users can only execute commands on containers they own
|
||||
- **Input Validation**: Commands are properly sanitized using `shlex.split()`
|
||||
- **Error Handling**: Comprehensive error handling for various failure scenarios
|
||||
|
||||
## How to Use
|
||||
|
||||
### 1. Access the Feature
|
||||
1. Navigate to your Docker container in CyberPanel
|
||||
2. Ensure the container is running (the "Run Command" button is disabled for stopped containers)
|
||||
3. Click the "Run Command" button in the Container Actions section
|
||||
|
||||
### 2. Execute Commands
|
||||
1. Enter your command in the input field (e.g., `-tou-accept`, `ls -la`, `ps aux`)
|
||||
2. Press Enter or click the "Execute" button
|
||||
3. View the output in the terminal-style output area
|
||||
4. Use command history to quickly re-run previous commands
|
||||
|
||||
### 3. Common Use Cases
|
||||
**For applications requiring command-line arguments:**
|
||||
1. Start your container
|
||||
2. Click "Run Command"
|
||||
3. Enter the required command (e.g., `-tou-accept`, `--help`, `--version`)
|
||||
4. Click "Execute"
|
||||
5. View the output to confirm successful execution
|
||||
|
||||
**For debugging and maintenance:**
|
||||
- `ls -la` - List files and directories
|
||||
- `ps aux` - Show running processes
|
||||
- `whoami` - Display current user
|
||||
- `env` - Show environment variables
|
||||
- `df -h` - Display disk usage
|
||||
|
||||
## Technical Details
|
||||
|
||||
### Command Execution Process
|
||||
1. **Validation**: Check if container exists and user has permissions
|
||||
2. **Status Check**: Ensure container is running
|
||||
3. **Command Parsing**: Use `shlex.split()` to properly parse command arguments
|
||||
4. **Execution**: Use Docker's `exec_run()` method to execute command
|
||||
5. **Response**: Return output, exit code, and any errors
|
||||
|
||||
### Error Handling
|
||||
- Container not found
|
||||
- Container not running
|
||||
- Permission denied
|
||||
- Command execution failures
|
||||
- Network connectivity issues
|
||||
|
||||
### Security Considerations
|
||||
- Commands are executed with the same user as the container's default user
|
||||
- No privileged execution (unless container is privileged)
|
||||
- Input is sanitized to prevent injection attacks
|
||||
- Only admin users can execute commands
|
||||
|
||||
## Files Modified
|
||||
|
||||
### Backend Files
|
||||
- `dockerManager/container.py` - Added `executeContainerCommand` method
|
||||
- `dockerManager/views.py` - Added `executeContainerCommand` view function
|
||||
- `dockerManager/urls.py` - Added URL pattern for command execution
|
||||
|
||||
### Frontend Files
|
||||
- `dockerManager/templates/dockerManager/viewContainer.html` - Added UI components
|
||||
- `dockerManager/static/dockerManager/dockerManager.js` - Added JavaScript functionality
|
||||
|
||||
## API Endpoint
|
||||
|
||||
**POST** `/docker/executeContainerCommand`
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"name": "container_name",
|
||||
"command": "command_to_execute"
|
||||
}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"commandStatus": 1,
|
||||
"error_message": "None",
|
||||
"output": "command_output",
|
||||
"exit_code": 0,
|
||||
"command": "executed_command"
|
||||
}
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
1. **"Container must be running"** - Start the container first
|
||||
2. **"Permission denied"** - Ensure you have admin access
|
||||
3. **"Command not found"** - Check if the command exists in the container
|
||||
4. **Empty output** - Some commands may not produce visible output
|
||||
|
||||
### Debugging
|
||||
- Check container logs for additional information
|
||||
- Verify the container's base image supports the command
|
||||
- Ensure proper command syntax for the container's shell
|
||||
|
||||
## Future Enhancements
|
||||
- Interactive terminal mode
|
||||
- Command templates for common tasks
|
||||
- Output filtering and search
|
||||
- Command scheduling
|
||||
- Multi-container command execution
|
||||
|
||||
## Security Notes
|
||||
- This feature should only be used by trusted administrators
|
||||
- Commands are executed with the container's user permissions
|
||||
- Consider implementing additional logging for audit purposes
|
||||
- Monitor command execution for security compliance
|
||||
|
||||
## Testing with Various Applications
|
||||
1. Pull any Docker image (e.g., `ubuntu:latest`, `alpine:latest`, `nginx:latest`)
|
||||
2. Create a container with the image
|
||||
3. Start the container
|
||||
4. Use the "Run Command" feature to execute various commands:
|
||||
- `ls -la` - List files
|
||||
- `ps aux` - Show processes
|
||||
- `whoami` - Check user
|
||||
- `env` - View environment
|
||||
5. Verify commands execute properly and output is displayed correctly
|
||||
|
||||
This feature provides a secure and user-friendly way to execute commands in Docker containers directly from the CyberPanel interface, making it easy to manage applications like Honeygain that require specific command-line arguments.
|
||||
57
guides/INDEX.md
Normal file
57
guides/INDEX.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# 📚 CyberPanel Guides & Documentation
|
||||
|
||||
Welcome to the CyberPanel documentation hub! This folder contains all guides, tutorials, and documentation for CyberPanel features and integrations.
|
||||
|
||||
## 📋 Available Guides
|
||||
|
||||
### 🐳 Docker Management
|
||||
- **[Docker Command Execution Guide](Docker_Command_Execution_Guide.md)** - Learn how to execute commands inside Docker containers directly from the CyberPanel interface
|
||||
- **[Docker Testing Guide](Test_Honeygain_Integration.md)** - Comprehensive testing guide for Docker command execution with various applications
|
||||
|
||||
### 🤖 AI & Security
|
||||
- **[AI Scanner Documentation](AIScannerDocs.md)** - Complete guide for CyberPanel's AI-powered security scanner
|
||||
|
||||
### 📧 Email & Marketing
|
||||
- **[Mautic Installation Guide](MAUTIC_INSTALLATION_GUIDE.md)** - Step-by-step guide for installing and configuring Mautic email marketing platform
|
||||
|
||||
### 📖 General Documentation
|
||||
- **[README](../README.md)** - Main CyberPanel documentation with installation instructions and feature overview
|
||||
- **[Contributing Guide](CONTRIBUTING.md)** - Guidelines for contributing to the CyberPanel project
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
1. **New to CyberPanel?** Start with the [README](../README.md) for installation and basic setup
|
||||
2. **Need Docker help?** Check the [Docker Command Execution Guide](Docker_Command_Execution_Guide.md)
|
||||
3. **Setting up email marketing?** Follow the [Mautic Installation Guide](MAUTIC_INSTALLATION_GUIDE.md)
|
||||
4. **Want to contribute?** Read the [Contributing Guide](CONTRIBUTING.md)
|
||||
|
||||
## 🔍 Finding What You Need
|
||||
|
||||
- **Installation & Setup**: [README](../README.md)
|
||||
- **Docker Features**: [Docker Command Execution Guide](Docker_Command_Execution_Guide.md)
|
||||
- **Security Features**: [AI Scanner Documentation](AIScannerDocs.md)
|
||||
- **Email Marketing**: [Mautic Installation Guide](MAUTIC_INSTALLATION_GUIDE.md)
|
||||
- **Development**: [Contributing Guide](CONTRIBUTING.md)
|
||||
|
||||
## 📝 Guide Categories
|
||||
|
||||
### 🛠️ **Core Features**
|
||||
- Docker container management
|
||||
- Command execution
|
||||
- Security scanning
|
||||
|
||||
### 🔧 **Integrations**
|
||||
- Mautic email marketing
|
||||
- Third-party applications
|
||||
- Custom configurations
|
||||
|
||||
### 📖 **Documentation**
|
||||
- Installation guides
|
||||
- Configuration tutorials
|
||||
- Troubleshooting tips
|
||||
|
||||
---
|
||||
|
||||
*Last updated: September 2025*
|
||||
|
||||
*For the latest updates and community support, visit [community.cyberpanel.net](https://community.cyberpanel.net)*
|
||||
Reference in New Issue
Block a user