diff --git a/CLManager/CageFS.py b/CLManager/CageFS.py index 9c5b6c8e3..9127e4bc5 100644 --- a/CLManager/CageFS.py +++ b/CLManager/CageFS.py @@ -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() diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html index ca13177fc..1f9f0334f 100755 --- a/baseTemplate/templates/baseTemplate/index.html +++ b/baseTemplate/templates/baseTemplate/index.html @@ -853,6 +853,9 @@
  • {% trans "Imunify 360" %}
  • +
  • {% trans "ImunifyAV" %} +
  • diff --git a/firewall/firewallManager.py b/firewall/firewallManager.py index f4d7dad19..7c51b7213 100755 --- a/firewall/firewallManager.py +++ b/firewall/firewallManager.py @@ -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) diff --git a/firewall/static/firewall/firewall.js b/firewall/static/firewall/firewall.js index eaa372adb..70af49df3 100755 --- a/firewall/static/firewall/firewall.js +++ b/firewall/static/firewall/firewall.js @@ -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; diff --git a/firewall/templates/firewall/imunifyAV.html b/firewall/templates/firewall/imunifyAV.html new file mode 100755 index 000000000..696ba2ac2 --- /dev/null +++ b/firewall/templates/firewall/imunifyAV.html @@ -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 %} + + + +
    +
    +

    {% trans "ImunifyAV" %} - {% trans "Imunify Docs" %}

    +

    {% trans "Access ImunifyAV" %}

    +
    + +
    +
    +

    + {% trans "ImunifyAV" %} +

    +
    + +

    {% 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." %}

    +
    + + + + +
    +
    +
    + +
    +{% endblock %} + diff --git a/firewall/templates/firewall/notAvailableAV.html b/firewall/templates/firewall/notAvailableAV.html new file mode 100755 index 000000000..a65be4802 --- /dev/null +++ b/firewall/templates/firewall/notAvailableAV.html @@ -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 %} + + + +
    +
    +

    {% trans "Not available" %} - {% trans "ImunifyAV Docs" %}

    +

    {% trans "ImunifyAV is not installed" %}

    +
    + +
    +
    +

    + {% trans "Activate Now" %} +

    +
    + +

    {% trans "Imunify is not installed, click to install now." %}

    + + +
    + +
    + +
    +
    + +
    +
    +
    +
    + + + +
    + +
    + +
    + +
    + +
    +
    + +
    + +
    +
    +
    + +
    +{% endblock %} + diff --git a/firewall/urls.py b/firewall/urls.py index a5db4ce93..ed912364a 100755 --- a/firewall/urls.py +++ b/firewall/urls.py @@ -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'), + diff --git a/firewall/views.py b/firewall/views.py index 83aab1b74..9193a51a4 100755 --- a/firewall/views.py +++ b/firewall/views.py @@ -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) diff --git a/static/firewall/firewall.js b/static/firewall/firewall.js index eaa372adb..70af49df3 100644 --- a/static/firewall/firewall.js +++ b/static/firewall/firewall.js @@ -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;