mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-09 14:56:10 +01:00
finish imunifyav
This commit is contained in:
@@ -180,6 +180,53 @@ pattern_to_watch = ^/home/.+?/(public_html|public_ftp|private_html)(/.*)?$
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
|
||||
|
||||
@staticmethod
|
||||
def submitinstallImunifyAV():
|
||||
try:
|
||||
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"Starting ImunifyAV Installation..\n", 1)
|
||||
|
||||
##
|
||||
|
||||
command = 'mkdir -p /etc/sysconfig/imunify360'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
|
||||
integrationFile = '/etc/sysconfig/imunify360/integration.conf'
|
||||
|
||||
content = """[paths]
|
||||
ui_path = /usr/local/CyberCP/public/imunifyav
|
||||
ui_path_owner = lscpd:lscpd
|
||||
"""
|
||||
|
||||
writeToFile = open(integrationFile, 'w')
|
||||
writeToFile.write(content)
|
||||
writeToFile.close()
|
||||
|
||||
##
|
||||
|
||||
if not os.path.exists('imav-deploy.sh'):
|
||||
command = 'wget https://repo.imunify360.cloudlinux.com/defence360/imav-deploy.sh'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
command = 'bash imav-deploy.sh'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"ImunifyAV reinstalled..\n", 1)
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"Packages successfully installed.[200]\n", 1)
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(description='CyberPanel CageFS Manager')
|
||||
@@ -193,6 +240,8 @@ def main():
|
||||
CageFS.submitCageFSInstall()
|
||||
elif args["function"] == "submitinstallImunify":
|
||||
CageFS.submitinstallImunify(args["key"])
|
||||
elif args["function"] == "submitinstallImunifyAV":
|
||||
CageFS.submitinstallImunifyAV()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -853,6 +853,9 @@
|
||||
<li><a href="{% url 'imunify' %}"
|
||||
title="{% trans 'Imunify 360' %}"><span>{% trans "Imunify 360" %}</span></a>
|
||||
</li>
|
||||
<li><a href="{% url 'imunifyAV' %}"
|
||||
title="{% trans 'ImunifyAV' %}"><span>{% trans "ImunifyAV" %}</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!-- .sidebar-submenu -->
|
||||
|
||||
@@ -25,6 +25,7 @@ class FirewallManager:
|
||||
|
||||
imunifyPath = '/usr/bin/imunify360-agent'
|
||||
CLPath = '/etc/sysconfig/cloudlinux'
|
||||
imunifyAVPath = '/etc/sysconfig/imunify360/integration.conf'
|
||||
|
||||
def __init__(self, request = None):
|
||||
self.request = request
|
||||
@@ -1561,8 +1562,10 @@ class FirewallManager:
|
||||
ipData = f.read()
|
||||
ipAddress = ipData.split('\n', 1)[0]
|
||||
|
||||
fullAddress = '%s:%s' % (ipAddress, ProcessUtilities.fetchCurrentPort())
|
||||
|
||||
data = {}
|
||||
data['ipAddress'] = ipAddress
|
||||
data['ipAddress'] = fullAddress
|
||||
|
||||
if os.path.exists(FirewallManager.CLPath):
|
||||
data['CL'] = 1
|
||||
@@ -1610,3 +1613,63 @@ class FirewallManager:
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
|
||||
|
||||
def imunifyAV(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddress = ipData.split('\n', 1)[0]
|
||||
|
||||
fullAddress = '%s:%s' % (ipAddress, ProcessUtilities.fetchCurrentPort())
|
||||
|
||||
data = {}
|
||||
data['ipAddress'] = fullAddress
|
||||
|
||||
|
||||
|
||||
if os.path.exists(FirewallManager.imunifyAVPath):
|
||||
data['imunify'] = 1
|
||||
else:
|
||||
data['imunify'] = 0
|
||||
|
||||
if data['imunify'] == 0:
|
||||
return render(self.request, 'firewall/notAvailableAV.html', data)
|
||||
else:
|
||||
return render(self.request, 'firewall/imunifyAV.html', data)
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
def submitinstallImunifyAV(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
'Not authorized to install container packages. [404].',
|
||||
1)
|
||||
return 0
|
||||
|
||||
execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/CLManager/CageFS.py"
|
||||
execPath = execPath + " --function submitinstallImunifyAV"
|
||||
ProcessUtilities.popenExecutioner(execPath)
|
||||
|
||||
data_ret = {'status': 1, 'error_message': 'None'}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
|
||||
|
||||
@@ -2146,6 +2146,105 @@ app.controller('installImunify', function ($scope, $http, $timeout, $window) {
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
if (response.data.abort === 0) {
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
$timeout(getRequestStatus, 1000);
|
||||
} else {
|
||||
// Notifications
|
||||
$scope.installDockerStatus = true;
|
||||
$timeout.cancel();
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
if (response.data.installed === 1) {
|
||||
$timeout(function () {
|
||||
$window.location.reload();
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.installDockerStatus = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
/* ImunifyAV */
|
||||
|
||||
app.controller('installImunifyAV', function ($scope, $http, $timeout, $window) {
|
||||
|
||||
$scope.installDockerStatus = true;
|
||||
$scope.installBoxGen = true;
|
||||
$scope.dockerInstallBTN = false;
|
||||
|
||||
$scope.submitinstallImunify = function () {
|
||||
|
||||
$scope.installDockerStatus = false;
|
||||
$scope.installBoxGen = true;
|
||||
$scope.dockerInstallBTN = true;
|
||||
|
||||
url = "/firewall/submitinstallImunifyAV";
|
||||
|
||||
var data = {};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.installBoxGen = false;
|
||||
getRequestStatus();
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function getRequestStatus() {
|
||||
$scope.installDockerStatus = false;
|
||||
|
||||
url = "/serverstatus/switchTOLSWSStatus";
|
||||
|
||||
var data = {};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
if (response.data.abort === 0) {
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
|
||||
41
firewall/templates/firewall/imunifyAV.html
Executable file
41
firewall/templates/firewall/imunifyAV.html
Executable file
@@ -0,0 +1,41 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "ImunifyAV - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "ImunifyAV" %} - <a target="_blank"
|
||||
href="https://go.cyberpanel.net/imunify"
|
||||
style="height: 23px;line-height: 21px;"
|
||||
class="btn btn-border btn-alt border-red btn-link font-red"
|
||||
title=""><span>{% trans "Imunify Docs" %}</span></a></h2>
|
||||
<p>{% trans "Access ImunifyAV" %}</p>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
{% trans "ImunifyAV" %}
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<p>{% trans "ImunifyAV is now integrated via their new API. You can manage Imunify by clicking below. You can use your server root credentials to access Imunify." %}</p>
|
||||
<br>
|
||||
<a target="_blank" href="http://{{ ipAddress }}/imunifyav">
|
||||
<button class="btn btn-primary">Access Now
|
||||
</button>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
69
firewall/templates/firewall/notAvailableAV.html
Executable file
69
firewall/templates/firewall/notAvailableAV.html
Executable file
@@ -0,0 +1,69 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Not available - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Not available" %} - <a target="_blank"
|
||||
href="https://go.cyberpanel.net/imunify"
|
||||
style="height: 23px;line-height: 21px;"
|
||||
class="btn btn-border btn-alt border-red btn-link font-red"
|
||||
title=""><span>{% trans "ImunifyAV Docs" %}</span></a></h2>
|
||||
<p>{% trans "ImunifyAV is not installed" %}</p>
|
||||
</div>
|
||||
|
||||
<div ng-controller="installImunifyAV" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
{% trans "Activate Now" %} <img ng-hide="installDockerStatus"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<p>{% trans "Imunify is not installed, click to install now." %}</p>
|
||||
<!------ LSWS Switch box ----------------->
|
||||
|
||||
<div style="margin-top: 2%" ng-hide="installBoxGen" class="col-md-12">
|
||||
|
||||
<form action="/" id="" class="form-horizontal bordered-row">
|
||||
|
||||
<div class="form-group">
|
||||
<div style="margin-top: 2%;" class="col-sm-12">
|
||||
<textarea ng-model="requestData" rows="15"
|
||||
class="form-control">{{ requestData }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<!----- LSWS Switch box ----------------->
|
||||
<br>
|
||||
|
||||
<form action="/" id="" class="form-horizontal bordered-row">
|
||||
|
||||
<div ng-hide="dockerInstallBTN" ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-6">
|
||||
<button type="button" class="btn btn-primary"
|
||||
ng-click="submitinstallImunify()">
|
||||
Install Now
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -56,6 +56,11 @@ urlpatterns = [
|
||||
url(r'^imunify$', views.imunify, name='imunify'),
|
||||
url(r'^submitinstallImunify$', views.submitinstallImunify, name='submitinstallImunify'),
|
||||
|
||||
## ImunifyAV
|
||||
|
||||
url(r'^imunifyAV$', views.imunifyAV, name='imunifyAV'),
|
||||
url(r'^submitinstallImunifyAV$', views.submitinstallImunifyAV, name='submitinstallImunifyAV'),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -568,3 +568,23 @@ def submitinstallImunify(request):
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
## ImunifyAV
|
||||
|
||||
def imunifyAV(request):
|
||||
try:
|
||||
|
||||
fm = FirewallManager(request)
|
||||
return fm.imunifyAV()
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def submitinstallImunifyAV(request):
|
||||
try:
|
||||
|
||||
fm = FirewallManager(request)
|
||||
return fm.submitinstallImunifyAV()
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
@@ -2146,6 +2146,105 @@ app.controller('installImunify', function ($scope, $http, $timeout, $window) {
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
if (response.data.abort === 0) {
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
$timeout(getRequestStatus, 1000);
|
||||
} else {
|
||||
// Notifications
|
||||
$scope.installDockerStatus = true;
|
||||
$timeout.cancel();
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
if (response.data.installed === 1) {
|
||||
$timeout(function () {
|
||||
$window.location.reload();
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.installDockerStatus = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
/* ImunifyAV */
|
||||
|
||||
app.controller('installImunifyAV', function ($scope, $http, $timeout, $window) {
|
||||
|
||||
$scope.installDockerStatus = true;
|
||||
$scope.installBoxGen = true;
|
||||
$scope.dockerInstallBTN = false;
|
||||
|
||||
$scope.submitinstallImunify = function () {
|
||||
|
||||
$scope.installDockerStatus = false;
|
||||
$scope.installBoxGen = true;
|
||||
$scope.dockerInstallBTN = true;
|
||||
|
||||
url = "/firewall/submitinstallImunifyAV";
|
||||
|
||||
var data = {};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.installBoxGen = false;
|
||||
getRequestStatus();
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function getRequestStatus() {
|
||||
$scope.installDockerStatus = false;
|
||||
|
||||
url = "/serverstatus/switchTOLSWSStatus";
|
||||
|
||||
var data = {};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
if (response.data.abort === 0) {
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
|
||||
Reference in New Issue
Block a user