Skip to content

Commit 4b1f76c

Browse files
committed
finish imunifyav
1 parent 67842a7 commit 4b1f76c

File tree

9 files changed

+449
-1
lines changed

9 files changed

+449
-1
lines changed

CLManager/CageFS.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,53 @@ def submitinstallImunify(key):
180180
except BaseException as msg:
181181
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
182182

183+
@staticmethod
184+
def submitinstallImunifyAV():
185+
try:
186+
187+
188+
mailUtilities.checkHome()
189+
190+
statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
191+
192+
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
193+
"Starting ImunifyAV Installation..\n", 1)
194+
195+
##
196+
197+
command = 'mkdir -p /etc/sysconfig/imunify360'
198+
ServerStatusUtil.executioner(command, statusFile)
199+
200+
201+
integrationFile = '/etc/sysconfig/imunify360/integration.conf'
202+
203+
content = """[paths]
204+
ui_path = /usr/local/CyberCP/public/imunifyav
205+
ui_path_owner = lscpd:lscpd
206+
"""
207+
208+
writeToFile = open(integrationFile, 'w')
209+
writeToFile.write(content)
210+
writeToFile.close()
211+
212+
##
213+
214+
if not os.path.exists('imav-deploy.sh'):
215+
command = 'wget https://repo.imunify360.cloudlinux.com/defence360/imav-deploy.sh'
216+
ServerStatusUtil.executioner(command, statusFile)
217+
218+
command = 'bash imav-deploy.sh'
219+
ServerStatusUtil.executioner(command, statusFile)
220+
221+
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
222+
"ImunifyAV reinstalled..\n", 1)
223+
224+
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
225+
"Packages successfully installed.[200]\n", 1)
226+
227+
except BaseException as msg:
228+
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
229+
183230
def main():
184231

185232
parser = argparse.ArgumentParser(description='CyberPanel CageFS Manager')
@@ -193,6 +240,8 @@ def main():
193240
CageFS.submitCageFSInstall()
194241
elif args["function"] == "submitinstallImunify":
195242
CageFS.submitinstallImunify(args["key"])
243+
elif args["function"] == "submitinstallImunifyAV":
244+
CageFS.submitinstallImunifyAV()
196245

197246

198247

baseTemplate/templates/baseTemplate/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,9 @@
853853
<li><a href="{% url 'imunify' %}"
854854
title="{% trans 'Imunify 360' %}"><span>{% trans "Imunify 360" %}</span></a>
855855
</li>
856+
<li><a href="{% url 'imunifyAV' %}"
857+
title="{% trans 'ImunifyAV' %}"><span>{% trans "ImunifyAV" %}</span></a>
858+
</li>
856859
</ul>
857860

858861
</div><!-- .sidebar-submenu -->

firewall/firewallManager.py

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class FirewallManager:
2525

2626
imunifyPath = '/usr/bin/imunify360-agent'
2727
CLPath = '/etc/sysconfig/cloudlinux'
28+
imunifyAVPath = '/etc/sysconfig/imunify360/integration.conf'
2829

2930
def __init__(self, request = None):
3031
self.request = request
@@ -1561,8 +1562,10 @@ def imunify(self):
15611562
ipData = f.read()
15621563
ipAddress = ipData.split('\n', 1)[0]
15631564

1565+
fullAddress = '%s:%s' % (ipAddress, ProcessUtilities.fetchCurrentPort())
1566+
15641567
data = {}
1565-
data['ipAddress'] = ipAddress
1568+
data['ipAddress'] = fullAddress
15661569

15671570
if os.path.exists(FirewallManager.CLPath):
15681571
data['CL'] = 1
@@ -1610,3 +1613,63 @@ def submitinstallImunify(self):
16101613

16111614
except BaseException as msg:
16121615
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
1616+
1617+
def imunifyAV(self):
1618+
try:
1619+
userID = self.request.session['userID']
1620+
currentACL = ACLManager.loadedACL(userID)
1621+
1622+
if currentACL['admin'] == 1:
1623+
pass
1624+
else:
1625+
return ACLManager.loadError()
1626+
1627+
ipFile = "/etc/cyberpanel/machineIP"
1628+
f = open(ipFile)
1629+
ipData = f.read()
1630+
ipAddress = ipData.split('\n', 1)[0]
1631+
1632+
fullAddress = '%s:%s' % (ipAddress, ProcessUtilities.fetchCurrentPort())
1633+
1634+
data = {}
1635+
data['ipAddress'] = fullAddress
1636+
1637+
1638+
1639+
if os.path.exists(FirewallManager.imunifyAVPath):
1640+
data['imunify'] = 1
1641+
else:
1642+
data['imunify'] = 0
1643+
1644+
if data['imunify'] == 0:
1645+
return render(self.request, 'firewall/notAvailableAV.html', data)
1646+
else:
1647+
return render(self.request, 'firewall/imunifyAV.html', data)
1648+
1649+
1650+
except BaseException as msg:
1651+
return HttpResponse(str(msg))
1652+
1653+
def submitinstallImunifyAV(self):
1654+
try:
1655+
userID = self.request.session['userID']
1656+
currentACL = ACLManager.loadedACL(userID)
1657+
1658+
if currentACL['admin'] == 1:
1659+
pass
1660+
else:
1661+
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
1662+
'Not authorized to install container packages. [404].',
1663+
1)
1664+
return 0
1665+
1666+
execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/CLManager/CageFS.py"
1667+
execPath = execPath + " --function submitinstallImunifyAV"
1668+
ProcessUtilities.popenExecutioner(execPath)
1669+
1670+
data_ret = {'status': 1, 'error_message': 'None'}
1671+
json_data = json.dumps(data_ret)
1672+
return HttpResponse(json_data)
1673+
1674+
except BaseException as msg:
1675+
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)

firewall/static/firewall/firewall.js

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2146,6 +2146,105 @@ app.controller('installImunify', function ($scope, $http, $timeout, $window) {
21462146
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
21472147

21482148

2149+
function ListInitialDatas(response) {
2150+
if (response.data.abort === 0) {
2151+
$scope.requestData = response.data.requestStatus;
2152+
$timeout(getRequestStatus, 1000);
2153+
} else {
2154+
// Notifications
2155+
$scope.installDockerStatus = true;
2156+
$timeout.cancel();
2157+
$scope.requestData = response.data.requestStatus;
2158+
if (response.data.installed === 1) {
2159+
$timeout(function () {
2160+
$window.location.reload();
2161+
}, 3000);
2162+
}
2163+
2164+
}
2165+
}
2166+
2167+
function cantLoadInitialDatas(response) {
2168+
$scope.installDockerStatus = true;
2169+
new PNotify({
2170+
title: 'Operation Failed!',
2171+
text: 'Could not connect to server, please refresh this page',
2172+
type: 'error'
2173+
});
2174+
}
2175+
2176+
}
2177+
});
2178+
2179+
/* ImunifyAV */
2180+
2181+
app.controller('installImunifyAV', function ($scope, $http, $timeout, $window) {
2182+
2183+
$scope.installDockerStatus = true;
2184+
$scope.installBoxGen = true;
2185+
$scope.dockerInstallBTN = false;
2186+
2187+
$scope.submitinstallImunify = function () {
2188+
2189+
$scope.installDockerStatus = false;
2190+
$scope.installBoxGen = true;
2191+
$scope.dockerInstallBTN = true;
2192+
2193+
url = "/firewall/submitinstallImunifyAV";
2194+
2195+
var data = {};
2196+
2197+
var config = {
2198+
headers: {
2199+
'X-CSRFToken': getCookie('csrftoken')
2200+
}
2201+
};
2202+
2203+
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2204+
2205+
function ListInitialDatas(response) {
2206+
$scope.cyberPanelLoading = true;
2207+
if (response.data.status === 1) {
2208+
$scope.installBoxGen = false;
2209+
getRequestStatus();
2210+
} else {
2211+
new PNotify({
2212+
title: 'Operation Failed!',
2213+
text: response.data.error_message,
2214+
type: 'error'
2215+
});
2216+
}
2217+
2218+
}
2219+
2220+
function cantLoadInitialDatas(response) {
2221+
$scope.cyberPanelLoading = true;
2222+
new PNotify({
2223+
title: 'Operation Failed!',
2224+
text: 'Could not connect to server, please refresh this page',
2225+
type: 'error'
2226+
});
2227+
}
2228+
2229+
};
2230+
2231+
function getRequestStatus() {
2232+
$scope.installDockerStatus = false;
2233+
2234+
url = "/serverstatus/switchTOLSWSStatus";
2235+
2236+
var data = {};
2237+
2238+
var config = {
2239+
headers: {
2240+
'X-CSRFToken': getCookie('csrftoken')
2241+
}
2242+
};
2243+
2244+
2245+
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2246+
2247+
21492248
function ListInitialDatas(response) {
21502249
if (response.data.abort === 0) {
21512250
$scope.requestData = response.data.requestStatus;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{% extends "baseTemplate/index.html" %}
2+
{% load i18n %}
3+
{% block title %}{% trans "ImunifyAV - CyberPanel" %}{% endblock %}
4+
{% block content %}
5+
6+
{% load static %}
7+
{% get_current_language as LANGUAGE_CODE %}
8+
<!-- Current language: {{ LANGUAGE_CODE }} -->
9+
10+
11+
<div class="container">
12+
<div id="page-title">
13+
<h2>{% trans "ImunifyAV" %} - <a target="_blank"
14+
href="https://go.cyberpanel.net/imunify"
15+
style="height: 23px;line-height: 21px;"
16+
class="btn btn-border btn-alt border-red btn-link font-red"
17+
title=""><span>{% trans "Imunify Docs" %}</span></a></h2>
18+
<p>{% trans "Access ImunifyAV" %}</p>
19+
</div>
20+
21+
<div class="panel">
22+
<div class="panel-body">
23+
<h3 class="title-hero">
24+
{% trans "ImunifyAV" %}
25+
</h3>
26+
<div class="example-box-wrapper">
27+
28+
<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>
29+
<br>
30+
<a target="_blank" href="http://{{ ipAddress }}/imunifyav">
31+
<button class="btn btn-primary">Access Now
32+
</button>
33+
</a>
34+
35+
</div>
36+
</div>
37+
</div>
38+
39+
</div>
40+
{% endblock %}
41+
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{% extends "baseTemplate/index.html" %}
2+
{% load i18n %}
3+
{% block title %}{% trans "Not available - CyberPanel" %}{% endblock %}
4+
{% block content %}
5+
6+
{% load static %}
7+
{% get_current_language as LANGUAGE_CODE %}
8+
<!-- Current language: {{ LANGUAGE_CODE }} -->
9+
10+
11+
<div class="container">
12+
<div id="page-title">
13+
<h2>{% trans "Not available" %} - <a target="_blank"
14+
href="https://go.cyberpanel.net/imunify"
15+
style="height: 23px;line-height: 21px;"
16+
class="btn btn-border btn-alt border-red btn-link font-red"
17+
title=""><span>{% trans "ImunifyAV Docs" %}</span></a></h2>
18+
<p>{% trans "ImunifyAV is not installed" %}</p>
19+
</div>
20+
21+
<div ng-controller="installImunifyAV" class="panel">
22+
<div class="panel-body">
23+
<h3 class="title-hero">
24+
{% trans "Activate Now" %} <img ng-hide="installDockerStatus"
25+
src="{% static 'images/loading.gif' %}">
26+
</h3>
27+
<div class="example-box-wrapper">
28+
29+
<p>{% trans "Imunify is not installed, click to install now." %}</p>
30+
<!------ LSWS Switch box ----------------->
31+
32+
<div style="margin-top: 2%" ng-hide="installBoxGen" class="col-md-12">
33+
34+
<form action="/" id="" class="form-horizontal bordered-row">
35+
36+
<div class="form-group">
37+
<div style="margin-top: 2%;" class="col-sm-12">
38+
<textarea ng-model="requestData" rows="15"
39+
class="form-control">{{ requestData }}</textarea>
40+
</div>
41+
</div>
42+
</form>
43+
</div>
44+
45+
46+
<!----- LSWS Switch box ----------------->
47+
<br>
48+
49+
<form action="/" id="" class="form-horizontal bordered-row">
50+
51+
<div ng-hide="dockerInstallBTN" ng-hide="installationDetailsForm" class="form-group">
52+
<label class="col-sm-3 control-label"></label>
53+
<div class="col-sm-6">
54+
<button type="button" class="btn btn-primary"
55+
ng-click="submitinstallImunify()">
56+
Install Now
57+
</button>
58+
</div>
59+
</div>
60+
61+
</form>
62+
63+
</div>
64+
</div>
65+
</div>
66+
67+
</div>
68+
{% endblock %}
69+

firewall/urls.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
url(r'^imunify$', views.imunify, name='imunify'),
5757
url(r'^submitinstallImunify$', views.submitinstallImunify, name='submitinstallImunify'),
5858

59+
## ImunifyAV
60+
61+
url(r'^imunifyAV$', views.imunifyAV, name='imunifyAV'),
62+
url(r'^submitinstallImunifyAV$', views.submitinstallImunifyAV, name='submitinstallImunifyAV'),
63+
5964

6065

6166

0 commit comments

Comments
 (0)