mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-12 08:16:11 +01:00
Added docker to service management
This commit is contained in:
@@ -24,7 +24,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|||||||
SECRET_KEY = 'xr%j*p!*$0d%(-(e%@-*hyoz4$f%y77coq0u)6pwmjg4)q&19f'
|
SECRET_KEY = 'xr%j*p!*$0d%(-(e%@-*hyoz4$f%y77coq0u)6pwmjg4)q&19f'
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = False
|
DEBUG = True
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['*']
|
ALLOWED_HOSTS = ['*']
|
||||||
|
|
||||||
@@ -110,15 +110,15 @@ DATABASES = {
|
|||||||
'ENGINE': 'django.db.backends.mysql',
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
'NAME': 'cyberpanel',
|
'NAME': 'cyberpanel',
|
||||||
'USER': 'cyberpanel',
|
'USER': 'cyberpanel',
|
||||||
'PASSWORD': 'Bz9gF7Hr7X4RtD',
|
'PASSWORD': 'a9AwLb7zY7ZwCd',
|
||||||
'HOST': '127.0.0.1',
|
'HOST': '127.0.0.1',
|
||||||
'PORT':'3307'
|
'PORT':''
|
||||||
},
|
},
|
||||||
'rootdb': {
|
'rootdb': {
|
||||||
'ENGINE': 'django.db.backends.mysql',
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
'NAME': 'mysql',
|
'NAME': 'mysql',
|
||||||
'USER': 'root',
|
'USER': 'root',
|
||||||
'PASSWORD': 'sXm5VlRaAsXkDd',
|
'PASSWORD': '3bL8X7wGo0kT3b',
|
||||||
'HOST': 'localhost',
|
'HOST': 'localhost',
|
||||||
'PORT': '',
|
'PORT': '',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ def preDockerRun(function):
|
|||||||
return render(request, 'dockerManager/install.html', {'status':admin.type, 'conErr':0})
|
return render(request, 'dockerManager/install.html', {'status':admin.type, 'conErr':0})
|
||||||
|
|
||||||
# Check if docker is running and we are able to connect
|
# Check if docker is running and we are able to connect
|
||||||
|
|
||||||
try:
|
try:
|
||||||
client = docker.from_env()
|
client = docker.from_env()
|
||||||
client.ping()
|
client.ping()
|
||||||
|
|||||||
BIN
serverStatus/static/images/docker.png
Normal file
BIN
serverStatus/static/images/docker.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
@@ -394,6 +394,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
|||||||
|
|
||||||
|
|
||||||
function ListInitialDatas(response) {
|
function ListInitialDatas(response) {
|
||||||
|
console.log(response.data)
|
||||||
|
|
||||||
if (response.data.status.litespeed) {
|
if (response.data.status.litespeed) {
|
||||||
$scope.olsStatus = "Running";
|
$scope.olsStatus = "Running";
|
||||||
@@ -409,8 +410,18 @@ app.controller('servicesManager', function ($scope, $http) {
|
|||||||
$scope.olsStop = false;
|
$scope.olsStop = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update SQL stats
|
if (response.data.status.docker) {
|
||||||
|
$scope.dockerStatus = "Running";
|
||||||
|
$scope.dockerStart = false;
|
||||||
|
$scope.dockerStop = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$scope.dockerStatus = "Stopped";
|
||||||
|
$scope.dockerStart = true;
|
||||||
|
$scope.dockerStop = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update SQL stats
|
||||||
if (response.data.status.mysql) {
|
if (response.data.status.mysql) {
|
||||||
$scope.sqlStatus = "Running";
|
$scope.sqlStatus = "Running";
|
||||||
$scope.sqlStats = true;
|
$scope.sqlStats = true;
|
||||||
@@ -468,7 +479,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
}
|
||||||
getServiceStatus();
|
getServiceStatus();
|
||||||
|
|
||||||
$scope.serviceAction = function (serviceName, action) {
|
$scope.serviceAction = function (serviceName, action) {
|
||||||
|
|||||||
@@ -123,6 +123,28 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% if isDocker %}
|
||||||
|
<div class="col-sm-6 col-md-6">
|
||||||
|
<div class="panel panel-default service-panel">
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="serviceImg">
|
||||||
|
<img src="{% static 'images/docker.png' %}" alt="Docker" class="img-circle">
|
||||||
|
</div>
|
||||||
|
<div class="serviceDetails">
|
||||||
|
<div class="serviceHeading">
|
||||||
|
<h5><b>Docker</b></h5>
|
||||||
|
<span class="help-block" ng-bind="dockerStatus">Stopped</span>
|
||||||
|
</div>
|
||||||
|
<div class="serviceActionBtn">
|
||||||
|
<button type="button" class="btn btn-success" ng-disabled="btnDisable" ng-show="dockerStart" ng-click="serviceAction('docker','start')" data-toggle="tooltip" title="Start!"><i class="glyph-icon icon-play" aria-hidden="true"></i></button>
|
||||||
|
<button type="button" class="btn btn-warning" ng-disabled="btnDisable" ng-show="dockerStop" ng-click="serviceAction('docker','stop')" data-toggle="tooltip" title="Stop!"><i class="glyph-icon icon-pause" aria-hidden="true"></i></button>
|
||||||
|
<button type="button" class="btn btn-default" ng-disabled="btnDisable" ng-click="serviceAction('docker','restart')" data-toggle="tooltip" title="Restart!"><i class="glyph-icon icon-refresh" aria-hidden="true"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label"></label>
|
<label class="col-sm-3 control-label"></label>
|
||||||
|
|||||||
@@ -165,6 +165,12 @@ def services(request):
|
|||||||
else:
|
else:
|
||||||
data['serverName'] = 'LiteSpeed Ent'
|
data['serverName'] = 'LiteSpeed Ent'
|
||||||
|
|
||||||
|
dockerInstallPath = '/usr/bin/docker'
|
||||||
|
if not os.path.exists(dockerInstallPath):
|
||||||
|
data['isDocker'] = False
|
||||||
|
else:
|
||||||
|
data['isDocker'] = True
|
||||||
|
|
||||||
return render(request, 'serverStatus/services.html', data)
|
return render(request, 'serverStatus/services.html', data)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
@@ -178,6 +184,7 @@ def servicesStatus(request):
|
|||||||
dnsStatus = []
|
dnsStatus = []
|
||||||
ftpStatus = []
|
ftpStatus = []
|
||||||
mailStatus = []
|
mailStatus = []
|
||||||
|
dockerStatus = []
|
||||||
|
|
||||||
processlist = subprocess.check_output(['ps', '-A'])
|
processlist = subprocess.check_output(['ps', '-A'])
|
||||||
|
|
||||||
@@ -202,8 +209,10 @@ def servicesStatus(request):
|
|||||||
else:
|
else:
|
||||||
lsStatus.append(0)
|
lsStatus.append(0)
|
||||||
|
|
||||||
# mysql status
|
# Docker status
|
||||||
|
dockerStatus.append(getServiceStats('docker'))
|
||||||
|
|
||||||
|
# mysql status
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
result = s.connect_ex(('127.0.0.1', 3306))
|
result = s.connect_ex(('127.0.0.1', 3306))
|
||||||
|
|
||||||
@@ -241,7 +250,8 @@ def servicesStatus(request):
|
|||||||
'mysql': sqlStatus[0],
|
'mysql': sqlStatus[0],
|
||||||
'powerdns': dnsStatus[0],
|
'powerdns': dnsStatus[0],
|
||||||
'pureftp': ftpStatus[0],
|
'pureftp': ftpStatus[0],
|
||||||
'postfix': mailStatus[0]},
|
'postfix': mailStatus[0],
|
||||||
|
'docker': dockerStatus[0]},
|
||||||
'memUsage':
|
'memUsage':
|
||||||
{'litespeed': lsStatus[1],
|
{'litespeed': lsStatus[1],
|
||||||
'mysql': sqlStatus[1],
|
'mysql': sqlStatus[1],
|
||||||
@@ -277,8 +287,7 @@ def servicesAction(request):
|
|||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if service not in ["lsws", "mysql", "pdns", "pure-ftpd"]:
|
if service not in ["lsws", "mysql", "pdns", "pure-ftpd", "docker"]:
|
||||||
|
|
||||||
final_dic = {'serviceAction': 0, "error_message": "Invalid Service"}
|
final_dic = {'serviceAction': 0, "error_message": "Invalid Service"}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|||||||
Reference in New Issue
Block a user