From 1c3df3d361f2070053ab2b7e48ef37c0a9d42638 Mon Sep 17 00:00:00 2001 From: usmannasir <01-134132-158@student.bahria.edu.pk> Date: Fri, 9 Nov 2018 22:01:28 +0500 Subject: [PATCH] lsws switch --- api/views.py | 3 +- firewall/firewallManager.py | 565 +++++-- firewall/static/firewall/firewall.js | 6 - firewall/templates/firewall/modSecurity.html | 533 +++++-- ftp/ftpManager.py | 3 - install/install.py | 36 +- install/installCyberPanel.py | 1 - plogical/CyberCPLogFileWriter.py | 2 +- plogical/filemanager.py | 7 +- plogical/installUtilities.py | 25 +- plogical/modSec.py | 293 ++-- plogical/processUtilities.py | 76 +- plogical/sslUtilities.py | 272 ++-- plogical/vhost.py | 1138 ++++++++------ plogical/website.py | 1 - .../FileManager/.idea/FIleManager.iml | 8 + .../litespeed/FileManager/.idea/modules.xml | 8 + .../litespeed/FileManager/.idea/workspace.xml | 600 ++++++++ .../litespeed/FileManager/php/caller.php | 127 ++ .../litespeed/FileManager/php/fileManager.php | 748 +++++++++ .../litespeed/FileManager/php/temp.txt | 0 .../litespeed/FileManager/php/tests.php | 0 serverStatus/litespeed/conf/httpd_config.conf | 202 +++ serverStatus/litespeed/conf/mime.properties | 158 ++ .../litespeed/conf/templates/ccl.conf | 86 ++ .../litespeed/conf/templates/ccl.conf0,v | 111 ++ .../litespeed/conf/templates/phpsuexec.conf | 100 ++ .../conf/templates/phpsuexec.conf0,v | 125 ++ .../litespeed/conf/templates/rails.conf | 76 + .../litespeed/conf/templates/rails.conf0,v | 101 ++ .../litespeed/conf/vhosts/Example/htgroup | 4 + .../litespeed/conf/vhosts/Example/htpasswd | 2 + .../litespeed/conf/vhosts/Example/vhconf.conf | 119 ++ serverStatus/litespeed/functions.sh | 1364 +++++++++++++++++ serverStatus/litespeed/httpd.conf | 67 + serverStatus/litespeed/httpd_config.xml | 388 +++++ serverStatus/litespeed/install.sh | 506 ++++++ serverStatus/litespeed/modsec.conf | 21 + serverStatus/serverStatusUtil.py | 213 +++ serverStatus/static/images/agreement.png | Bin 0 -> 2173 bytes serverStatus/static/images/change.png | Bin 0 -> 1125 bytes serverStatus/static/images/litespeed-logo.png | Bin 0 -> 22141 bytes .../static/serverStatus/serverStatus.js | 843 ++++++---- .../serverStatus/litespeedStatus.html | 328 +++- .../templates/serverStatus/services.html | 2 +- serverStatus/urls.py | 18 +- serverStatus/views.py | 154 +- static/firewall/firewall.js | 6 - static/images/litespeed-logo.png | Bin 0 -> 22141 bytes static/serverStatus/serverStatus.js | 731 +++++---- 50 files changed, 8430 insertions(+), 1747 deletions(-) create mode 100644 serverStatus/litespeed/FileManager/.idea/FIleManager.iml create mode 100644 serverStatus/litespeed/FileManager/.idea/modules.xml create mode 100644 serverStatus/litespeed/FileManager/.idea/workspace.xml create mode 100755 serverStatus/litespeed/FileManager/php/caller.php create mode 100755 serverStatus/litespeed/FileManager/php/fileManager.php create mode 100644 serverStatus/litespeed/FileManager/php/temp.txt create mode 100644 serverStatus/litespeed/FileManager/php/tests.php create mode 100644 serverStatus/litespeed/conf/httpd_config.conf create mode 100755 serverStatus/litespeed/conf/mime.properties create mode 100755 serverStatus/litespeed/conf/templates/ccl.conf create mode 100755 serverStatus/litespeed/conf/templates/ccl.conf0,v create mode 100755 serverStatus/litespeed/conf/templates/phpsuexec.conf create mode 100755 serverStatus/litespeed/conf/templates/phpsuexec.conf0,v create mode 100755 serverStatus/litespeed/conf/templates/rails.conf create mode 100755 serverStatus/litespeed/conf/templates/rails.conf0,v create mode 100755 serverStatus/litespeed/conf/vhosts/Example/htgroup create mode 100755 serverStatus/litespeed/conf/vhosts/Example/htpasswd create mode 100644 serverStatus/litespeed/conf/vhosts/Example/vhconf.conf create mode 100644 serverStatus/litespeed/functions.sh create mode 100644 serverStatus/litespeed/httpd.conf create mode 100644 serverStatus/litespeed/httpd_config.xml create mode 100644 serverStatus/litespeed/install.sh create mode 100644 serverStatus/litespeed/modsec.conf create mode 100644 serverStatus/serverStatusUtil.py create mode 100644 serverStatus/static/images/agreement.png create mode 100644 serverStatus/static/images/change.png create mode 100644 serverStatus/static/images/litespeed-logo.png create mode 100644 static/images/litespeed-logo.png diff --git a/api/views.py b/api/views.py index d8fed2a67..bef494afe 100644 --- a/api/views.py +++ b/api/views.py @@ -567,8 +567,9 @@ def changeAdminPassword(request): 'error_message': "None"} json_data = json.dumps(data_ret) return HttpResponse(json_data) + os.remove(randomFile) - admin = Administrator.objects.get(pk="admin") + admin = Administrator.objects.get(userName="admin") admin.password = hashPassword.hash_password(adminPass) admin.save() data_ret = {"changed": 1, diff --git a/firewall/firewallManager.py b/firewall/firewallManager.py index aca646aec..d34581a31 100644 --- a/firewall/firewallManager.py +++ b/firewall/firewallManager.py @@ -13,16 +13,15 @@ from plogical.virtualHostUtilities import virtualHostUtilities import subprocess import shlex from plogical.installUtilities import installUtilities -from django.shortcuts import HttpResponse, render, redirect -from loginSystem.models import Administrator +from django.shortcuts import HttpResponse, render from random import randint import time -from loginSystem.views import loadLoginPage from plogical.firewallUtilities import FirewallUtilities from firewall.models import FirewallRules import thread from plogical.modSec import modSec from plogical.csf import CSF +from plogical.processUtilities import ProcessUtilities class FirewallManager: @@ -604,18 +603,24 @@ class FirewallManager: else: return ACLManager.loadError() - confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + OLS = 1 + confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") - command = "sudo cat " + confPath - httpdConfig = subprocess.check_output(shlex.split(command)).splitlines() + command = "sudo cat " + confPath + httpdConfig = subprocess.check_output(shlex.split(command)).splitlines() - modSecInstalled = 0 + modSecInstalled = 0 - for items in httpdConfig: - if items.find('module mod_security') > -1: - modSecInstalled = 1 - break - return render(request, 'firewall/modSecurity.html', {'modSecInstalled': modSecInstalled}) + for items in httpdConfig: + if items.find('module mod_security') > -1: + modSecInstalled = 1 + break + else: + OLS = 0 + modSecInstalled = 1 + + return render(request, 'firewall/modSecurity.html', {'modSecInstalled': modSecInstalled, 'OLS': OLS}) except BaseException, msg: return HttpResponse(str(msg)) @@ -702,29 +707,89 @@ class FirewallManager: else: return ACLManager.loadErrorJson('fetchStatus', 0) - modsecurity = 0 - SecAuditEngine = 0 - SecRuleEngine = 0 - SecDebugLogLevel = "9" - SecAuditLogRelevantStatus = '^(?:5|4(?!04))' - SecAuditLogParts = 'ABIJDEFHZ' - SecAuditLogType = 'Serial' + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: - confPath = os.path.join(virtualHostUtilities.Server_root, 'conf/httpd_config.conf') - modSecPath = os.path.join(virtualHostUtilities.Server_root, 'modules', 'mod_security.so') + modsecurity = 0 + SecAuditEngine = 0 + SecRuleEngine = 0 + SecDebugLogLevel = "9" + SecAuditLogRelevantStatus = '^(?:5|4(?!04))' + SecAuditLogParts = 'ABIJDEFHZ' + SecAuditLogType = 'Serial' - if os.path.exists(modSecPath): + confPath = os.path.join(virtualHostUtilities.Server_root, 'conf/httpd_config.conf') + modSecPath = os.path.join(virtualHostUtilities.Server_root, 'modules', 'mod_security.so') + + if os.path.exists(modSecPath): + command = "sudo cat " + confPath + data = subprocess.check_output(shlex.split(command)).splitlines() + + for items in data: + + if items.find('modsecurity ') > -1: + if items.find('on') > -1 or items.find('On') > -1: + modsecurity = 1 + continue + if items.find('SecAuditEngine ') > -1: + if items.find('on') > -1 or items.find('On') > -1: + SecAuditEngine = 1 + continue + + if items.find('SecRuleEngine ') > -1: + if items.find('on') > -1 or items.find('On') > -1: + SecRuleEngine = 1 + continue + + if items.find('SecDebugLogLevel') > -1: + result = items.split(' ') + if result[0] == 'SecDebugLogLevel': + SecDebugLogLevel = result[1] + continue + if items.find('SecAuditLogRelevantStatus') > -1: + result = items.split(' ') + if result[0] == 'SecAuditLogRelevantStatus': + SecAuditLogRelevantStatus = result[1] + continue + if items.find('SecAuditLogParts') > -1: + result = items.split(' ') + if result[0] == 'SecAuditLogParts': + SecAuditLogParts = result[1] + continue + if items.find('SecAuditLogType') > -1: + result = items.split(' ') + if result[0] == 'SecAuditLogType': + SecAuditLogType = result[1] + continue + + final_dic = {'fetchStatus': 1, + 'installed': 1, + 'SecRuleEngine': SecRuleEngine, + 'modsecurity': modsecurity, + 'SecAuditEngine': SecAuditEngine, + 'SecDebugLogLevel': SecDebugLogLevel, + 'SecAuditLogParts': SecAuditLogParts, + 'SecAuditLogRelevantStatus': SecAuditLogRelevantStatus, + 'SecAuditLogType': SecAuditLogType, + } + + else: + final_dic = {'fetchStatus': 1, + 'installed': 0} + else: + SecAuditEngine = 0 + SecRuleEngine = 0 + SecDebugLogLevel = "9" + SecAuditLogRelevantStatus = '^(?:5|4(?!04))' + SecAuditLogParts = 'ABIJDEFHZ' + SecAuditLogType = 'Serial' + + confPath = os.path.join(virtualHostUtilities.Server_root, 'conf/modsec.conf') command = "sudo cat " + confPath data = subprocess.check_output(shlex.split(command)).splitlines() for items in data: - - if items.find('modsecurity ') > -1: - if items.find('on') > -1 or items.find('On') > -1: - modsecurity = 1 - continue if items.find('SecAuditEngine ') > -1: if items.find('on') > -1 or items.find('On') > -1: SecAuditEngine = 1 @@ -759,7 +824,6 @@ class FirewallManager: final_dic = {'fetchStatus': 1, 'installed': 1, 'SecRuleEngine': SecRuleEngine, - 'modsecurity': modsecurity, 'SecAuditEngine': SecAuditEngine, 'SecDebugLogLevel': SecDebugLogLevel, 'SecAuditLogParts': SecAuditLogParts, @@ -767,10 +831,6 @@ class FirewallManager: 'SecAuditLogType': SecAuditLogType, } - else: - final_dic = {'fetchStatus': 1, - 'installed': 0} - final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -788,68 +848,126 @@ class FirewallManager: else: return ACLManager.loadErrorJson('saveStatus', 0) - modsecurity = data['modsecurity_status'] - SecAuditEngine = data['SecAuditEngine'] - SecRuleEngine = data['SecRuleEngine'] - SecDebugLogLevel = data['SecDebugLogLevel'] - SecAuditLogParts = data['SecAuditLogParts'] - SecAuditLogRelevantStatus = data['SecAuditLogRelevantStatus'] - SecAuditLogType = data['SecAuditLogType'] + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: - if modsecurity == True: - modsecurity = "modsecurity on" + modsecurity = data['modsecurity_status'] + SecAuditEngine = data['SecAuditEngine'] + SecRuleEngine = data['SecRuleEngine'] + SecDebugLogLevel = data['SecDebugLogLevel'] + SecAuditLogParts = data['SecAuditLogParts'] + SecAuditLogRelevantStatus = data['SecAuditLogRelevantStatus'] + SecAuditLogType = data['SecAuditLogType'] + + if modsecurity == True: + modsecurity = "modsecurity on" + else: + modsecurity = "modsecurity off" + + if SecAuditEngine == True: + SecAuditEngine = "SecAuditEngine on" + else: + SecAuditEngine = "SecAuditEngine off" + + if SecRuleEngine == True: + SecRuleEngine = "SecRuleEngine On" + else: + SecRuleEngine = "SecRuleEngine off" + + SecDebugLogLevel = "SecDebugLogLevel " + str(SecDebugLogLevel) + SecAuditLogParts = "SecAuditLogParts " + str(SecAuditLogParts) + SecAuditLogRelevantStatus = "SecAuditLogRelevantStatus " + SecAuditLogRelevantStatus + SecAuditLogType = "SecAuditLogType " + SecAuditLogType + + ## writing data temporary to file + + + tempConfigPath = "/home/cyberpanel/" + str(randint(1000, 9999)) + + confPath = open(tempConfigPath, "w") + + confPath.writelines(modsecurity + "\n") + confPath.writelines(SecAuditEngine + "\n") + confPath.writelines(SecRuleEngine + "\n") + confPath.writelines(SecDebugLogLevel + "\n") + confPath.writelines(SecAuditLogParts + "\n") + confPath.writelines(SecAuditLogRelevantStatus + "\n") + confPath.writelines(SecAuditLogType + "\n") + + confPath.close() + + ## save configuration data + + execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" + + execPath = execPath + " saveModSecConfigs --tempConfigPath " + tempConfigPath + + output = subprocess.check_output(shlex.split(execPath)) + + if output.find("1,None") > -1: + installUtilities.reStartLiteSpeed() + data_ret = {'saveStatus': 1, 'error_message': "None"} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + else: + data_ret = {'saveStatus': 0, 'error_message': output} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) else: - modsecurity = "modsecurity off" + SecAuditEngine = data['SecAuditEngine'] + SecRuleEngine = data['SecRuleEngine'] + SecDebugLogLevel = data['SecDebugLogLevel'] + SecAuditLogParts = data['SecAuditLogParts'] + SecAuditLogRelevantStatus = data['SecAuditLogRelevantStatus'] + SecAuditLogType = data['SecAuditLogType'] - if SecAuditEngine == True: - SecAuditEngine = "SecAuditEngine on" - else: - SecAuditEngine = "SecAuditEngine off" + if SecAuditEngine == True: + SecAuditEngine = "SecAuditEngine on" + else: + SecAuditEngine = "SecAuditEngine off" - if SecRuleEngine == True: - SecRuleEngine = "SecRuleEngine On" - else: - SecRuleEngine = "SecRuleEngine off" + if SecRuleEngine == True: + SecRuleEngine = "SecRuleEngine On" + else: + SecRuleEngine = "SecRuleEngine off" - SecDebugLogLevel = "SecDebugLogLevel " + str(SecDebugLogLevel) - SecAuditLogParts = "SecAuditLogParts " + str(SecAuditLogParts) - SecAuditLogRelevantStatus = "SecAuditLogRelevantStatus " + SecAuditLogRelevantStatus - SecAuditLogType = "SecAuditLogType " + SecAuditLogType + SecDebugLogLevel = "SecDebugLogLevel " + str(SecDebugLogLevel) + SecAuditLogParts = "SecAuditLogParts " + str(SecAuditLogParts) + SecAuditLogRelevantStatus = "SecAuditLogRelevantStatus " + SecAuditLogRelevantStatus + SecAuditLogType = "SecAuditLogType " + SecAuditLogType - ## writing data temporary to file + ## writing data temporary to file - tempConfigPath = "/home/cyberpanel/" + str(randint(1000, 9999)) + tempConfigPath = "/home/cyberpanel/" + str(randint(1000, 9999)) - confPath = open(tempConfigPath, "w") + confPath = open(tempConfigPath, "w") - confPath.writelines(modsecurity + "\n") - confPath.writelines(SecAuditEngine + "\n") - confPath.writelines(SecRuleEngine + "\n") - confPath.writelines(SecDebugLogLevel + "\n") - confPath.writelines(SecAuditLogParts + "\n") - confPath.writelines(SecAuditLogRelevantStatus + "\n") - confPath.writelines(SecAuditLogType + "\n") + confPath.writelines(SecAuditEngine + "\n") + confPath.writelines(SecRuleEngine + "\n") + confPath.writelines(SecDebugLogLevel + "\n") + confPath.writelines(SecAuditLogParts + "\n") + confPath.writelines(SecAuditLogRelevantStatus + "\n") + confPath.writelines(SecAuditLogType + "\n") - confPath.close() + confPath.close() - ## save configuration data + ## save configuration data - execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" + execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" - execPath = execPath + " saveModSecConfigs --tempConfigPath " + tempConfigPath + execPath = execPath + " saveModSecConfigs --tempConfigPath " + tempConfigPath - output = subprocess.check_output(shlex.split(execPath)) + output = subprocess.check_output(shlex.split(execPath)) - if output.find("1,None") > -1: - installUtilities.reStartLiteSpeed() - data_ret = {'saveStatus': 1, 'error_message': "None"} - json_data = json.dumps(data_ret) - return HttpResponse(json_data) - else: - data_ret = {'saveStatus': 0, 'error_message': output} - json_data = json.dumps(data_ret) - return HttpResponse(json_data) + if output.find("1,None") > -1: + installUtilities.reStartLiteSpeed() + data_ret = {'saveStatus': 1, 'error_message': "None"} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + else: + data_ret = {'saveStatus': 0, 'error_message': output} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) except BaseException, msg: data_ret = {'saveStatus': 0, 'error_message': str(msg)} @@ -866,17 +984,20 @@ class FirewallManager: else: return ACLManager.loadError() - confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") - command = "sudo cat " + confPath - httpdConfig = subprocess.check_output(shlex.split(command)).splitlines() + command = "sudo cat " + confPath + httpdConfig = subprocess.check_output(shlex.split(command)).splitlines() - modSecInstalled = 0 + modSecInstalled = 0 - for items in httpdConfig: - if items.find('module mod_security') > -1: - modSecInstalled = 1 - break + for items in httpdConfig: + if items.find('module mod_security') > -1: + modSecInstalled = 1 + break + else: + modSecInstalled = 1 return render(request, 'firewall/modSecurityRules.html', {'modSecInstalled': modSecInstalled}) @@ -892,21 +1013,39 @@ class FirewallManager: else: return ACLManager.loadErrorJson('modSecInstalled', 0) - confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: - command = "sudo cat " + confPath - httpdConfig = subprocess.check_output(shlex.split(command)).splitlines() + confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") - modSecInstalled = 0 + command = "sudo cat " + confPath + httpdConfig = subprocess.check_output(shlex.split(command)).splitlines() - for items in httpdConfig: - if items.find('module mod_security') > -1: - modSecInstalled = 1 - break + modSecInstalled = 0 - rulesPath = os.path.join(virtualHostUtilities.Server_root + "/conf/modsec/rules.conf") + for items in httpdConfig: + if items.find('module mod_security') > -1: + modSecInstalled = 1 + break + + rulesPath = os.path.join(virtualHostUtilities.Server_root + "/conf/modsec/rules.conf") + + if modSecInstalled: + command = "sudo cat " + rulesPath + currentModSecRules = subprocess.check_output(shlex.split(command)) + + final_dic = {'modSecInstalled': 1, + 'currentModSecRules': currentModSecRules} + + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + else: + final_dic = {'modSecInstalled': 0} + + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + else: + rulesPath = os.path.join(virtualHostUtilities.Server_root + "/conf/rules.conf") - if modSecInstalled: command = "sudo cat " + rulesPath currentModSecRules = subprocess.check_output(shlex.split(command)) @@ -915,11 +1054,6 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - else: - final_dic = {'modSecInstalled': 0} - - final_json = json.dumps(final_dic) - return HttpResponse(final_json) except BaseException, msg: final_dic = {'modSecInstalled': 0, @@ -941,17 +1075,13 @@ class FirewallManager: ## writing data temporary to file rulesPath = open(modSec.tempRulesFile, "w") - rulesPath.write(newModSecRules) - rulesPath.close() ## save configuration data execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" - execPath = execPath + " saveModSecRules" - output = subprocess.check_output(shlex.split(execPath)) if output.find("1,None") > -1: @@ -979,17 +1109,21 @@ class FirewallManager: else: return ACLManager.loadError() - confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: - command = "sudo cat " + confPath - httpdConfig = subprocess.check_output(shlex.split(command)).splitlines() + confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") - modSecInstalled = 0 + command = "sudo cat " + confPath + httpdConfig = subprocess.check_output(shlex.split(command)).splitlines() - for items in httpdConfig: - if items.find('module mod_security') > -1: - modSecInstalled = 1 - break + modSecInstalled = 0 + + for items in httpdConfig: + if items.find('module mod_security') > -1: + modSecInstalled = 1 + break + else: + modSecInstalled = 1 return render(request, 'firewall/modSecurityRulesPacks.html', {'modSecInstalled': modSecInstalled}) @@ -1006,47 +1140,70 @@ class FirewallManager: else: return ACLManager.loadErrorJson('modSecInstalled', 0) - confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") - command = "sudo cat " + confPath - httpdConfig = subprocess.check_output(shlex.split(command)).splitlines() - - modSecInstalled = 0 - - for items in httpdConfig: - if items.find('module mod_security') > -1: - modSecInstalled = 1 - break - - comodoInstalled = 0 - owaspInstalled = 0 - - if modSecInstalled: command = "sudo cat " + confPath httpdConfig = subprocess.check_output(shlex.split(command)).splitlines() + modSecInstalled = 0 + for items in httpdConfig: - - if items.find('modsec/comodo') > -1: - comodoInstalled = 1 - elif items.find('modsec/owasp') > -1: - owaspInstalled = 1 - - if owaspInstalled == 1 and comodoInstalled == 1: + if items.find('module mod_security') > -1: + modSecInstalled = 1 break + comodoInstalled = 0 + owaspInstalled = 0 + + if modSecInstalled: + command = "sudo cat " + confPath + httpdConfig = subprocess.check_output(shlex.split(command)).splitlines() + + for items in httpdConfig: + + if items.find('modsec/comodo') > -1: + comodoInstalled = 1 + elif items.find('modsec/owasp') > -1: + owaspInstalled = 1 + + if owaspInstalled == 1 and comodoInstalled == 1: + break + + final_dic = { + 'modSecInstalled': 1, + 'owaspInstalled': owaspInstalled, + 'comodoInstalled': comodoInstalled + } + + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + else: + final_dic = {'modSecInstalled': 0} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + + else: + comodoInstalled = 0 + owaspInstalled = 0 + + try: + command = 'sudo cat /usr/local/lsws/conf/comodo_litespeed/rules.conf.main' + res = subprocess.call(shlex.split(command)) + + if res == 0: + comodoInstalled = 1 + except subprocess.CalledProcessError: + pass + final_dic = { 'modSecInstalled': 1, 'owaspInstalled': owaspInstalled, 'comodoInstalled': comodoInstalled } + final_json = json.dumps(final_dic) + return HttpResponse(final_json) - final_json = json.dumps(final_dic) - return HttpResponse(final_json) - else: - final_dic = {'modSecInstalled': 0} - final_json = json.dumps(final_dic) - return HttpResponse(final_json) except BaseException, msg: final_dic = {'modSecInstalled': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) @@ -1064,21 +1221,40 @@ class FirewallManager: packName = data['packName'] - execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: - execPath = execPath + " " + packName + execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" + execPath = execPath + " " + packName - output = subprocess.check_output(shlex.split(execPath)) + output = subprocess.check_output(shlex.split(execPath)) - if output.find("1,None") > -1: - installUtilities.reStartLiteSpeed() - data_ret = {'installStatus': 1, 'error_message': "None"} - json_data = json.dumps(data_ret) - return HttpResponse(json_data) + if output.find("1,None") > -1: + installUtilities.reStartLiteSpeed() + data_ret = {'installStatus': 1, 'error_message': "None"} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + else: + data_ret = {'installStatus': 0, 'error_message': output} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) else: - data_ret = {'installStatus': 0, 'error_message': output} - json_data = json.dumps(data_ret) - return HttpResponse(json_data) + if packName == 'disableOWASP' or packName == 'installOWASP': + final_json = json.dumps({'installStatus': 0, 'error_message': "OWASP will be available later.", }) + return HttpResponse(final_json) + + execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" + execPath = execPath + " " + packName + output = subprocess.check_output(shlex.split(execPath)) + + if output.find("1,None") > -1: + installUtilities.reStartLiteSpeed() + data_ret = {'installStatus': 1, 'error_message': "None"} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + else: + data_ret = {'installStatus': 0, 'error_message': output} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) except BaseException, msg: data_ret = {'installStatus': 0, 'error_message': str(msg)} @@ -1096,26 +1272,70 @@ class FirewallManager: packName = data['packName'] - confPath = os.path.join(virtualHostUtilities.Server_root, 'conf/httpd_config.conf') + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + confPath = os.path.join(virtualHostUtilities.Server_root, 'conf/httpd_config.conf') - command = "sudo cat " + confPath - httpdConfig = subprocess.check_output(shlex.split(command)).splitlines() + command = "sudo cat " + confPath + httpdConfig = subprocess.check_output(shlex.split(command)).splitlines() - json_data = "[" - checker = 0 - counter = 0 + json_data = "[" + checker = 0 + counter = 0 - for items in httpdConfig: + for items in httpdConfig: - if items.find('modsec/' + packName) > -1: - counter = counter + 1 - if items[0] == '#': - status = False + if items.find('modsec/' + packName) > -1: + counter = counter + 1 + if items[0] == '#': + status = False + else: + status = True + + fileName = items.lstrip('#') + fileName = fileName.split('/')[-1] + + dic = { + 'id': counter, + 'fileName': fileName, + 'packName': packName, + 'status': status, + + } + + if checker == 0: + json_data = json_data + json.dumps(dic) + checker = 1 + else: + json_data = json_data + ',' + json.dumps(dic) + + json_data = json_data + ']' + final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data}) + return HttpResponse(final_json) + else: + if packName == 'owasp': + final_json = json.dumps({'fetchStatus': 0, 'error_message': "OWASP will be available later.", }) + return HttpResponse(final_json) + + comodoPath = '/usr/local/lsws/conf/comodo_litespeed' + command = 'sudo chown -R cyberpanel:cyberpanel /usr/local/lsws/conf' + subprocess.call(shlex.split(command)) + + json_data = "[" + + counter = 0 + checker = 0 + for fileName in os.listdir(comodoPath): + + if fileName == 'categories.conf': + continue + + if fileName.endswith('dis'): + status = 0 + fileName = fileName.rstrip('.dis') + elif fileName.endswith('conf'): + status = 1 else: - status = True - - fileName = items.lstrip('#') - fileName = fileName.split('/')[-1] + continue dic = { 'id': counter, @@ -1125,15 +1345,20 @@ class FirewallManager: } + counter = counter + 1 + if checker == 0: json_data = json_data + json.dumps(dic) checker = 1 else: json_data = json_data + ',' + json.dumps(dic) - json_data = json_data + ']' - final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data}) - return HttpResponse(final_json) + command = 'sudo chown -R lsadm:lsadm /usr/local/lsws/conf' + subprocess.call(shlex.split(command)) + + json_data = json_data + ']' + final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data}) + return HttpResponse(final_json) except BaseException, msg: final_dic = {'fetchStatus': 0, 'error_message': str(msg)} diff --git a/firewall/static/firewall/firewall.js b/firewall/static/firewall/firewall.js index ba9df9207..bb0e4a07f 100644 --- a/firewall/static/firewall/firewall.js +++ b/firewall/static/firewall/firewall.js @@ -3,10 +3,6 @@ */ - - - - /* Java script code to ADD Firewall Rules */ app.controller('firewallController', function($scope,$http) { @@ -548,8 +544,6 @@ app.controller('firewallController', function($scope,$http) { /* Java script code to ADD Firewall Rules */ - - /* Java script code to Secure SSH */ app.controller('secureSSHCTRL', function($scope,$http) { diff --git a/firewall/templates/firewall/modSecurity.html b/firewall/templates/firewall/modSecurity.html index e0476e917..768caa26e 100644 --- a/firewall/templates/firewall/modSecurity.html +++ b/firewall/templates/firewall/modSecurity.html @@ -3,189 +3,396 @@ {% block title %}{% trans "ModSecurity - CyberPanel" %}{% endblock %} {% block content %} -{% load static %} -{% get_current_language as LANGUAGE_CODE %} - + {% load static %} + {% get_current_language as LANGUAGE_CODE %} + + {% if OLS %} -
-
-

{% trans "ModSecurity Configurations!" %} - {% trans "ModSec Docs" %}

-

{% trans "On this page you can configure ModSecurity settings." %}

-
+
+
+

{% trans "ModSecurity Configurations!" %} - {% trans "ModSec Docs" %} +

+

{% trans "On this page you can configure ModSecurity settings." %}

+
-
-
-

- {% trans "ModSecurity" %} -

+
+
+

+ {% trans "ModSecurity" %} +

-
-
+
+
- {% if modSecInstalled == 0 %} + {% if modSecInstalled == 0 %} -
-

{% trans "ModSecurity is not installed " %} -

-
- - - -
- -
- -
-

{% trans "Failed to start installation, Error message: " %} {$ errorMessage $}

+
+

{% trans "ModSecurity is not installed " %} + +

-
-

{% trans "Could not connect. Please refresh this page." %}

-
+ -
-

{% trans "Installation failed." %} {$ errorMessage $}

-
+
+ +
-
-

{% trans "ModSecurity successfully installed, refreshing page in 3 seconds.." %}

-
-
-
+
+

{% trans "Failed to start installation, Error message: " %} {$ + errorMessage + $}

+
- -
- -
-
-
-

{% trans "Winter is coming, but so is ModSecurity." %}

-
-
- -
-
-
-
- - - - {% else %} - -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
-
{$ SecDebugLogLevel $}
-
-
- -
- -
- -
-
- - -
- -
- -
-
- -
- -
- -
-
- - - -
- -
- - -
-
- - - -
- -
- -
-

{% trans "Failed to save ModSecurity configurations. Error message: " %} {$ errorMessage $}

-
- -
-

{% trans "ModSecurity configurations successfully saved." %}

-
- -
+

{% trans "Could not connect. Please refresh this page." %}

+
+ +
+

{% trans "Installation failed." %} {$ errorMessage $}

+
+ +
+

{% trans "ModSecurity successfully installed, refreshing page in 3 seconds.." %}

+
+
+ + +
+ + +
+
+

{% trans "Winter is coming, but so is ModSecurity." %} +

+
+
+ +
+
+ +
+ + + + {% else %} + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
{$ SecDebugLogLevel $}
+
+
+ +
+ +
+ +
+
+ + +
+ +
+ +
+
+ +
+ +
+ +
+
+ + +
+ +
+ + +
+
+ + +
+ +
+ +
+

{% trans "Failed to save ModSecurity configurations. Error message: " %} + {$ errorMessage $}

+
+ +
+

{% trans "ModSecurity configurations successfully saved." %}

+
+ +
+

{% trans "Could not connect. Please refresh this page." %}

+
+ +
+
+ + +
+
+ + {% endif %} + -
- - - -
- - {% endif %} - - - +
+ +
-
+ + {% else %} + +
+
+

{% trans "ModSecurity Configurations!" %} - {% trans "ModSec Docs" %} +

+

{% trans "On this page you can configure ModSecurity settings." %}

+
+ +
+
+

+ {% trans "ModSecurity" %} +

+ +
+
+ + {% if modSecInstalled == 0 %} + +
+

{% trans "ModSecurity is not installed " %} + +

+
+ + + +
+ +
+ +
+

{% trans "Failed to start installation, Error message: " %} {$ + errorMessage $}

+
+ +
+

{% trans "Could not connect. Please refresh this page." %}

+
+ +
+

{% trans "Installation failed." %} {$ errorMessage $}

+
+ +
+

{% trans "ModSecurity successfully installed, refreshing page in 3 seconds.." %}

+
+
+
-
+
+ +
+
+
+

{% trans "Winter is coming, but so is ModSecurity." %} +

+
+
+ +
+
+
+
+ + + + {% else %} + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
{$ SecDebugLogLevel $}
+
+
+ +
+ +
+ +
+
+ + +
+ +
+ +
+
+ +
+ +
+ +
+
+ + +
+ +
+ + +
+
+ + +
+ +
+ +
+

{% trans "Failed to save ModSecurity configurations. Error message: " %} + {$ errorMessage $}

+
+ +
+

{% trans "ModSecurity configurations successfully saved." %}

+
+ +
+

{% trans "Could not connect. Please refresh this page." %}

+
+ +
+
+ + +
+
+ + {% endif %} + + +
+
+
+
+ + +
+ + {% endif %} {% endblock %} \ No newline at end of file diff --git a/ftp/ftpManager.py b/ftp/ftpManager.py index e7ce81ef5..8dc4b85f4 100644 --- a/ftp/ftpManager.py +++ b/ftp/ftpManager.py @@ -79,12 +79,9 @@ class FTPManager: path = 'None' execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/ftpUtilities.py" - execPath = execPath + " submitFTPCreation --domainName " + domainName + " --userName " + userName \ + " --password " + password + " --path " + path + " --owner " + admin.userName + ' --api ' + api - output = subprocess.check_output(shlex.split(execPath)) - if output.find("1,None") > -1: data_ret = {'status': 1, 'creatFTPStatus': 1, 'error_message': 'None'} json_data = json.dumps(data_ret) diff --git a/install/install.py b/install/install.py index 923701a88..48d37e65a 100644 --- a/install/install.py +++ b/install/install.py @@ -296,24 +296,26 @@ class preFlightsChecks: preFlightsChecks.stdOut("Exception during CyberPanel install") os._exit(os.EX_SOFTWARE) - else: - while(1): - cmd.append("rpm") - cmd.append("-ivh") - cmd.append("http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm") - res = subprocess.call(cmd) + else: + while (1): + cmd.append("rpm") + cmd.append("-ivh") + cmd.append("http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm") + res = subprocess.call(cmd) - if res == 1: - count = count + 1 - preFlightsChecks.stdOut("Unable to add CyberPanel official repository, trying again, try number: " + str(count) + "\n") - if count == 3: - logging.InstallLog.writeToFile("Unable to add CyberPanel official repository, exiting installer! [installCyberPanelRepo]") - preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - os._exit(0) - else: - logging.InstallLog.writeToFile("CyberPanel Repo added!") - preFlightsChecks.stdOut("CyberPanel Repo added!") - break + if res == 1: + count = count + 1 + preFlightsChecks.stdOut( + "Unable to add CyberPanel official repository, trying again, try number: " + str(count) + "\n") + if count == 3: + logging.InstallLog.writeToFile( + "Unable to add CyberPanel official repository, exiting installer! [installCyberPanelRepo]") + preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") + os._exit(0) + else: + logging.InstallLog.writeToFile("CyberPanel Repo added!") + preFlightsChecks.stdOut("CyberPanel Repo added!") + break def enableEPELRepo(self): try: diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 4942079ef..d591262cd 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -234,7 +234,6 @@ class InstallCyberPanel: 'lsphp7?-ldap lsphp7?-mysql lsphp7?-opcache lsphp7?-pspell lsphp7?-recode ' \ 'lsphp7?-sqlite3 lsphp7?-tidy' res = os.system(command) - else: command = 'yum -y groupinstall lsphp-all' cmd = shlex.split(command) diff --git a/plogical/CyberCPLogFileWriter.py b/plogical/CyberCPLogFileWriter.py index dc2d11890..2ff68a41d 100644 --- a/plogical/CyberCPLogFileWriter.py +++ b/plogical/CyberCPLogFileWriter.py @@ -41,7 +41,7 @@ class CyberCPLogFileWriter: @staticmethod def statusWriter(tempStatusPath, mesg): try: - statusFile = open(tempStatusPath, 'w') + statusFile = open(tempStatusPath, 'a') statusFile.writelines(mesg) statusFile.close() except BaseException, msg: diff --git a/plogical/filemanager.py b/plogical/filemanager.py index 2c95c8ca8..69faec37a 100644 --- a/plogical/filemanager.py +++ b/plogical/filemanager.py @@ -1,12 +1,7 @@ -import os.path -import shutil import CyberCPLogFileWriter as logging -import subprocess import argparse -import shlex from random import randint - class filemanager: @staticmethod @@ -25,7 +20,7 @@ class filemanager: except BaseException,msg: logging.CyberCPLogFileWriter.writeToFile( - str(msg) + " [createEmailAccount]") + str(msg) + " [createTemporaryFile]") print "0," + str(msg) diff --git a/plogical/installUtilities.py b/plogical/installUtilities.py index 7b697e50d..dfbf42fd1 100644 --- a/plogical/installUtilities.py +++ b/plogical/installUtilities.py @@ -4,8 +4,8 @@ import CyberCPLogFileWriter as logging import shutil import pexpect import os -import thread import shlex +from processUtilities import ProcessUtilities class installUtilities: @@ -136,15 +136,15 @@ class installUtilities: @staticmethod def reStartLiteSpeed(): try: - FNULL = open(os.devnull, 'w') - command = "sudo systemctl restart lsws" + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + command = "sudo systemctl restart lsws" + else: + command = "sudo /usr/local/lsws/bin/lswsctrl restart" cmd = shlex.split(command) - - res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) - + subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) except OSError, msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]") @@ -159,12 +159,12 @@ class installUtilities: def reStartOpenLiteSpeed(restart,orestart): try: - FNULL = open(os.devnull, 'w') - - command = "sudo systemctl restart lsws" + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + command = "sudo systemctl restart lsws" + else: + command = "sudo /usr/local/lsws/bin/lswsctrl restart" cmd = shlex.split(command) - res = subprocess.call(cmd) if res == 1: @@ -177,7 +177,6 @@ class installUtilities: print(" Litespeed Re-Started ") print("###############################################") - except OSError, msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartOpenLiteSpeed]") return 0 @@ -279,8 +278,6 @@ class installUtilities: return 1 - - @staticmethod def installMainWebServer(): if installUtilities.enableEPELRepo() == 1: @@ -370,7 +367,6 @@ class installUtilities: return 1 - @staticmethod def startMariaDB(): @@ -406,7 +402,6 @@ class installUtilities: return 1 - @staticmethod def installMySQL(password): diff --git a/plogical/modSec.py b/plogical/modSec.py index efcfae27b..60ec1f8bf 100644 --- a/plogical/modSec.py +++ b/plogical/modSec.py @@ -7,6 +7,7 @@ import os import tarfile import shutil from mailUtilities import mailUtilities +from processUtilities import ProcessUtilities class modSec: installLogPath = "/home/cyberpanel/modSecInstallLog" @@ -111,42 +112,74 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf data = open(tempConfigPath).readlines() os.remove(tempConfigPath) - confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: - confData = open(confFile).readlines() + confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") + confData = open(confFile).readlines() + conf = open(confFile, 'w') - conf = open(confFile, 'w') + for items in confData: - for items in confData: + if items.find('modsecurity ') > -1: + conf.writelines(data[0]) + continue + elif items.find('SecAuditEngine ') > -1: + conf.writelines(data[1]) + continue + elif items.find('SecRuleEngine ') > -1: + conf.writelines(data[2]) + continue + elif items.find('SecDebugLogLevel') > -1: + conf.writelines(data[3]) + continue + elif items.find('SecAuditLogRelevantStatus ') > -1: + conf.writelines(data[5]) + continue + elif items.find('SecAuditLogParts ') > -1: + conf.writelines(data[4]) + continue + elif items.find('SecAuditLogType ') > -1: + conf.writelines(data[6]) + continue + else: + conf.writelines(items) - if items.find('modsecurity ') > -1: - conf.writelines(data[0]) - continue - elif items.find('SecAuditEngine ') > -1: - conf.writelines(data[1]) - continue - elif items.find('SecRuleEngine ') > -1: - conf.writelines(data[2]) - continue - elif items.find('SecDebugLogLevel') > -1: - conf.writelines(data[3]) - continue - elif items.find('SecAuditLogRelevantStatus ') > -1: - conf.writelines(data[5]) - continue - elif items.find('SecAuditLogParts ') > -1: - conf.writelines(data[4]) - continue - elif items.find('SecAuditLogType ') > -1: - conf.writelines(data[6]) - continue - else: - conf.writelines(items) + conf.close() - conf.close() + print "1,None" + return + else: + confFile = os.path.join(virtualHostUtilities.Server_root, "conf/modsec.conf") + confData = open(confFile).readlines() + conf = open(confFile, 'w') - print "1,None" - return + for items in confData: + + if items.find('SecAuditEngine ') > -1: + conf.writelines(data[0]) + continue + elif items.find('SecRuleEngine ') > -1: + conf.writelines(data[1]) + continue + elif items.find('SecDebugLogLevel') > -1: + conf.writelines(data[2]) + continue + elif items.find('SecAuditLogRelevantStatus ') > -1: + conf.writelines(data[4]) + continue + elif items.find('SecAuditLogParts ') > -1: + conf.writelines(data[3]) + continue + elif items.find('SecAuditLogType ') > -1: + conf.writelines(data[5]) + continue + else: + conf.writelines(items) + + conf.close() + + print "1,None" + return except BaseException, msg: logging.CyberCPLogFileWriter.writeToFile( @@ -160,7 +193,10 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf data = rulesFile.read() rulesFile.close() - rulesFilePath = os.path.join(virtualHostUtilities.Server_root, "conf/modsec/rules.conf") + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + rulesFilePath = os.path.join(virtualHostUtilities.Server_root, "conf/modsec/rules.conf") + else: + rulesFilePath = os.path.join(virtualHostUtilities.Server_root, "conf/rules.conf") rulesFile = open(rulesFilePath,'w') rulesFile.write(data) @@ -180,26 +216,47 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf @staticmethod def setupComodoRules(): try: - pathTOOWASPFolder = os.path.join(virtualHostUtilities.Server_root, "conf/modsec/comodo") - extractLocation = os.path.join(virtualHostUtilities.Server_root, "conf/modsec") - if os.path.exists(pathTOOWASPFolder): - shutil.rmtree(pathTOOWASPFolder) + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + pathTOOWASPFolder = os.path.join(virtualHostUtilities.Server_root, "conf/modsec/comodo") + extractLocation = os.path.join(virtualHostUtilities.Server_root, "conf/modsec") - if os.path.exists('comodo.tar.gz'): - os.remove('comodo.tar.gz') + if os.path.exists(pathTOOWASPFolder): + shutil.rmtree(pathTOOWASPFolder) - command = "wget https://" + modSec.mirrorPath + "/modsec/comodo.tar.gz" - result = subprocess.call(shlex.split(command)) + if os.path.exists('comodo.tar.gz'): + os.remove('comodo.tar.gz') - if result == 1: - return 0 + command = "wget https://" + modSec.mirrorPath + "/modsec/comodo.tar.gz" + result = subprocess.call(shlex.split(command)) - tar = tarfile.open('comodo.tar.gz') - tar.extractall(extractLocation) - tar.close() + if result == 1: + return 0 - return 1 + tar = tarfile.open('comodo.tar.gz') + tar.extractall(extractLocation) + tar.close() + + return 1 + else: + if os.path.exists('/usr/local/lsws/conf/comodo_litespeed'): + shutil.rmtree('/usr/local/lsws/conf/comodo_litespeed') + + extractLocation = os.path.join(virtualHostUtilities.Server_root, "conf") + + if os.path.exists('cpanel_litespeed_vendor'): + os.remove('cpanel_litespeed_vendor') + + command = "wget https://waf.comodo.com/api/cpanel_litespeed_vendor" + result = subprocess.call(shlex.split(command)) + + if result == 1: + return 0 + + command = "unzip cpanel_litespeed_vendor -d " + extractLocation + subprocess.call(shlex.split(command)) + + return 1 except BaseException, msg: logging.CyberCPLogFileWriter.writeToFile( @@ -209,60 +266,85 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf @staticmethod def installComodo(): try: - if modSec.setupComodoRules() == 0: - print '0, Unable to download Comodo Rules.' + + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + if modSec.setupComodoRules() == 0: + print '0, Unable to download Comodo Rules.' + return + + owaspRulesConf = """modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/modsecurity.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/00_Init_Initialization.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/01_Init_AppsInitialization.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/02_Global_Generic.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/03_Global_Agents.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/04_Global_Domains.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/05_Global_Backdoor.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/06_XSS_XSS.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/07_Global_Other.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/08_Bruteforce_Bruteforce.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/09_HTTP_HTTP.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/10_HTTP_HTTPDoS.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/11_HTTP_Protocol.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/12_HTTP_Request.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/13_Outgoing_FilterGen.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/14_Outgoing_FilterASP.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/15_Outgoing_FilterPHP.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/16_Outgoing_FilterSQL.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/17_Outgoing_FilterOther.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/18_Outgoing_FilterInFrame.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/19_Outgoing_FiltersEnd.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/20_PHP_PHPGen.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/21_SQL_SQLi.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/22_Apps_Joomla.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/23_Apps_JComponent.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/24_Apps_WordPress.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/25_Apps_WPPlugin.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/26_Apps_WHMCS.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/27_Apps_Drupal.conf + modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/28_Apps_OtherApps.conf + """ + + confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") + + confData = open(confFile).readlines() + + conf = open(confFile, 'w') + + for items in confData: + if items.find('/usr/local/lsws/conf/modsec/rules.conf') > -1: + conf.writelines(items) + conf.write(owaspRulesConf) + continue + else: + conf.writelines(items) + + conf.close() + + print "1,None" return + else: + if os.path.exists('/usr/local/lsws/conf/comodo_litespeed'): + shutil.rmtree('/usr/local/lsws/conf/comodo_litespeed') - owaspRulesConf = """modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/modsecurity.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/00_Init_Initialization.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/01_Init_AppsInitialization.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/02_Global_Generic.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/03_Global_Agents.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/04_Global_Domains.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/05_Global_Backdoor.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/06_XSS_XSS.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/07_Global_Other.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/08_Bruteforce_Bruteforce.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/09_HTTP_HTTP.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/10_HTTP_HTTPDoS.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/11_HTTP_Protocol.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/12_HTTP_Request.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/13_Outgoing_FilterGen.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/14_Outgoing_FilterASP.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/15_Outgoing_FilterPHP.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/16_Outgoing_FilterSQL.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/17_Outgoing_FilterOther.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/18_Outgoing_FilterInFrame.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/19_Outgoing_FiltersEnd.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/20_PHP_PHPGen.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/21_SQL_SQLi.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/22_Apps_Joomla.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/23_Apps_JComponent.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/24_Apps_WordPress.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/25_Apps_WPPlugin.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/26_Apps_WHMCS.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/27_Apps_Drupal.conf -modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/28_Apps_OtherApps.conf -""" + extractLocation = os.path.join(virtualHostUtilities.Server_root, "conf") - confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") + if os.path.exists('cpanel_litespeed_vendor'): + os.remove('cpanel_litespeed_vendor') - confData = open(confFile).readlines() + command = "wget https://waf.comodo.com/api/cpanel_litespeed_vendor" + result = subprocess.call(shlex.split(command)) - conf = open(confFile, 'w') + if result == 1: + return 0 - for items in confData: - if items.find('/usr/local/lsws/conf/modsec/rules.conf') > -1: - conf.writelines(items) - conf.write(owaspRulesConf) - continue - else: - conf.writelines(items) + command = "unzip cpanel_litespeed_vendor -d " + extractLocation + result = subprocess.call(shlex.split(command)) - conf.close() + command = 'sudo chown -R lsadm:lsadm /usr/local/lsws/conf' + subprocess.call(shlex.split(command)) - print "1,None" - return + print "1,None" + return except BaseException, msg: logging.CyberCPLogFileWriter.writeToFile( @@ -273,19 +355,28 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/28_Apps_OtherApps.conf def disableComodo(): try: - confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") - confData = open(confFile).readlines() - conf = open(confFile, 'w') + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") + confData = open(confFile).readlines() + conf = open(confFile, 'w') - for items in confData: - if items.find('modsec/comodo') > -1: - continue - else: - conf.writelines(items) + for items in confData: + if items.find('modsec/comodo') > -1: + continue + else: + conf.writelines(items) - conf.close() + conf.close() + + print "1,None" + + else: + try: + shutil.rmtree('/usr/local/lsws/conf/comodo_litespeed') + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [disableComodo]') + print "1,None" - print "1,None" except BaseException, msg: logging.CyberCPLogFileWriter.writeToFile( diff --git a/plogical/processUtilities.py b/plogical/processUtilities.py index a87264190..e86a1b081 100644 --- a/plogical/processUtilities.py +++ b/plogical/processUtilities.py @@ -1,11 +1,15 @@ from CyberCPLogFileWriter import CyberCPLogFileWriter as logging import subprocess import shlex - - +import os +from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging class ProcessUtilities: litespeedProcess = "litespeed" + ent = 1 + OLS = 0 + centos = 1 + ubuntu = 0 @staticmethod def getLitespeedProcessNumber(): @@ -14,7 +18,7 @@ class ProcessUtilities: try: import psutil for proc in psutil.process_iter(): - if proc.name() == ProcessUtilities.litespeedProcess: + if proc.name().find(ProcessUtilities.litespeedProcess) > -1: finalListOfProcesses.append(proc.pid) except BaseException,msg: @@ -30,7 +34,11 @@ class ProcessUtilities: @staticmethod def restartLitespeed(): try: - command = "sudo systemctl restart lsws" + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + command = "sudo systemctl restart lsws" + else: + command = "sudo /usr/local/lsws/bin/lswsctrl restart" + cmd = shlex.split(command) res = subprocess.call(cmd) @@ -45,7 +53,11 @@ class ProcessUtilities: @staticmethod def stopLitespeed(): try: - command = "sudo systemctl stop lsws" + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + command = "sudo systemctl stop lsws" + else: + command = "sudo /usr/local/lsws/bin/lswsctrl stop" + cmd = shlex.split(command) res = subprocess.call(cmd) @@ -57,4 +69,58 @@ class ProcessUtilities: except subprocess.CalledProcessError, msg: logging.writeToFile(str(msg) + "[stopLitespeed]") + @staticmethod + def executioner(command): + try: + res = subprocess.call(shlex.split(command)) + if res == 1: + raise 0 + else: + return 1 + except BaseException, msg: + return 0 + + @staticmethod + def killLiteSpeed(): + pids = ProcessUtilities.getLitespeedProcessNumber() + if pids !=0: + for items in pids: + try: + command = 'sudo kill -9 ' + str(items) + ProcessUtilities.executioner(command) + except: + pass + + @staticmethod + def decideServer(): + entPath = '/usr/local/lsws/bin/lshttpd' + + if os.readlink(entPath) == '/usr/local/lsws/bin/lshttpd/openlitespeed': + return ProcessUtilities.OLS + else: + return ProcessUtilities.ent + + @staticmethod + def decideDistro(): + distroPath = '/etc/lsb-release' + + if os.path.exists(distroPath): + return ProcessUtilities.ubuntu + else: + return ProcessUtilities.centos + + @staticmethod + def executioner(command, statusFile): + try: + res = subprocess.call(shlex.split(command), stdout=statusFile, stderr=statusFile) + if res == 1: + raise 0 + else: + return 1 + + except BaseException, msg: + logging.writeToFile(str(msg)) + return 0 + + diff --git a/plogical/sslUtilities.py b/plogical/sslUtilities.py index 13b66b51f..687a3432c 100644 --- a/plogical/sslUtilities.py +++ b/plogical/sslUtilities.py @@ -1,9 +1,10 @@ import CyberCPLogFileWriter as logging -import shutil import os import shlex import subprocess import socket +from plogical.processUtilities import ProcessUtilities +from websiteFunctions.models import ChildDomains, Websites class sslUtilities: @@ -58,109 +59,189 @@ class sslUtilities: return [0, "347 " + str(msg) + " [issueSSLForDomain]"] @staticmethod - def installSSLForDomain(virtualHostName): + def installSSLForDomain(virtualHostName, adminEmail='usman@cyberpersons.com'): + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + confPath = sslUtilities.Server_root + "/conf/vhosts/" + virtualHostName + completePathToConfigFile = confPath + "/vhost.conf" - confPath = sslUtilities.Server_root + "/conf/vhosts/" + virtualHostName - completePathToConfigFile = confPath + "/vhost.conf" - - try: - map = " map " + virtualHostName + " " + virtualHostName + "\n" - - if sslUtilities.checkSSLListener() != 1: - - writeDataToFile = open("/usr/local/lsws/conf/httpd_config.conf", 'a') - - listener = "listener SSL {" + "\n" - address = " address *:443" + "\n" - secure = " secure 1" + "\n" - keyFile = " keyFile /etc/letsencrypt/live/" + virtualHostName + "/privkey.pem\n" - certFile = " certFile /etc/letsencrypt/live/" + virtualHostName + "/fullchain.pem\n" - certChain = " certChain 1" + "\n" - sslProtocol = " sslProtocol 30" + "\n" + try: map = " map " + virtualHostName + " " + virtualHostName + "\n" - final = "}" + "\n" + "\n" - writeDataToFile.writelines("\n") - writeDataToFile.writelines(listener) - writeDataToFile.writelines(address) - writeDataToFile.writelines(secure) - writeDataToFile.writelines(keyFile) - writeDataToFile.writelines(certFile) - writeDataToFile.writelines(certChain) - writeDataToFile.writelines(sslProtocol) - writeDataToFile.writelines(map) - writeDataToFile.writelines(final) - writeDataToFile.writelines("\n") - writeDataToFile.close() + if sslUtilities.checkSSLListener() != 1: + writeDataToFile = open("/usr/local/lsws/conf/httpd_config.conf", 'a') - else: - - if sslUtilities.checkIfSSLMap(virtualHostName) == 0: - - data = open("/usr/local/lsws/conf/httpd_config.conf").readlines() - writeDataToFile = open("/usr/local/lsws/conf/httpd_config.conf", 'w') - sslCheck = 0 - - for items in data: - if items.find("listener") > -1 and items.find("SSL") > -1: - sslCheck = 1 - - if (sslCheck == 1): - writeDataToFile.writelines(items) - writeDataToFile.writelines(map) - sslCheck = 0 - else: - writeDataToFile.writelines(items) - writeDataToFile.close() - - ###################### Write per host Configs for SSL ################### - - data = open(completePathToConfigFile, "r").readlines() - - ## check if vhssl is already in vhconf file - - vhsslPresense = 0 - - for items in data: - if items.find("vhssl") > -1: - vhsslPresense = 1 - - if vhsslPresense == 0: - writeSSLConfig = open(completePathToConfigFile, "a") - - vhssl = "vhssl {" + "\n" - keyFile = " keyFile /etc/letsencrypt/live/" + virtualHostName + "/privkey.pem\n" - certFile = " certFile /etc/letsencrypt/live/" + virtualHostName + "/fullchain.pem\n" + listener = "listener SSL {" + "\n" + address = " address *:443" + "\n" + secure = " secure 1" + "\n" + keyFile = " keyFile /etc/letsencrypt/live/" + virtualHostName + "/privkey.pem\n" + certFile = " certFile /etc/letsencrypt/live/" + virtualHostName + "/fullchain.pem\n" certChain = " certChain 1" + "\n" sslProtocol = " sslProtocol 30" + "\n" - final = "}" + map = " map " + virtualHostName + " " + virtualHostName + "\n" + final = "}" + "\n" + "\n" - writeSSLConfig.writelines("\n") + writeDataToFile.writelines("\n") + writeDataToFile.writelines(listener) + writeDataToFile.writelines(address) + writeDataToFile.writelines(secure) + writeDataToFile.writelines(keyFile) + writeDataToFile.writelines(certFile) + writeDataToFile.writelines(certChain) + writeDataToFile.writelines(sslProtocol) + writeDataToFile.writelines(map) + writeDataToFile.writelines(final) + writeDataToFile.writelines("\n") + writeDataToFile.close() - writeSSLConfig.writelines(vhssl) - writeSSLConfig.writelines(keyFile) - writeSSLConfig.writelines(certFile) - writeSSLConfig.writelines(certChain) - writeSSLConfig.writelines(sslProtocol) - writeSSLConfig.writelines(final) - writeSSLConfig.writelines("\n") + else: - writeSSLConfig.close() + if sslUtilities.checkIfSSLMap(virtualHostName) == 0: - return 1 + data = open("/usr/local/lsws/conf/httpd_config.conf").readlines() + writeDataToFile = open("/usr/local/lsws/conf/httpd_config.conf", 'w') + sslCheck = 0 + + for items in data: + if items.find("listener") > -1 and items.find("SSL") > -1: + sslCheck = 1 + + if (sslCheck == 1): + writeDataToFile.writelines(items) + writeDataToFile.writelines(map) + sslCheck = 0 + else: + writeDataToFile.writelines(items) + writeDataToFile.close() + + ###################### Write per host Configs for SSL ################### + + data = open(completePathToConfigFile, "r").readlines() + + ## check if vhssl is already in vhconf file + + vhsslPresense = 0 + + for items in data: + if items.find("vhssl") > -1: + vhsslPresense = 1 + + if vhsslPresense == 0: + writeSSLConfig = open(completePathToConfigFile, "a") + + vhssl = "vhssl {" + "\n" + keyFile = " keyFile /etc/letsencrypt/live/" + virtualHostName + "/privkey.pem\n" + certFile = " certFile /etc/letsencrypt/live/" + virtualHostName + "/fullchain.pem\n" + certChain = " certChain 1" + "\n" + sslProtocol = " sslProtocol 30" + "\n" + final = "}" + + writeSSLConfig.writelines("\n") + + writeSSLConfig.writelines(vhssl) + writeSSLConfig.writelines(keyFile) + writeSSLConfig.writelines(certFile) + writeSSLConfig.writelines(certChain) + writeSSLConfig.writelines(sslProtocol) + writeSSLConfig.writelines(final) + + writeSSLConfig.writelines("\n") + + writeSSLConfig.close() + + return 1 + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installSSLForDomain]]") + return 0 + else: + confPath = sslUtilities.Server_root + "/conf/vhosts/" + virtualHostName + completePathToConfigFile = confPath + "/vhost.conf" + + ## Check if SSL VirtualHost already exists + + data = open(completePathToConfigFile, 'r').readlines() + + for items in data: + if items.find('*:443') > -1: + return 1 + + try: + + try: + chilDomain = ChildDomains.objects.get(domain=virtualHostName) + externalApp = chilDomain.master.externalApp + DocumentRoot = ' DocumentRoot ' + chilDomain.path + '\n' + except BaseException, msg: + website = Websites.objects.get(domain=virtualHostName) + externalApp = website.externalApp + DocumentRoot = ' DocumentRoot /home/' + virtualHostName + '/public_html\n' + + data = open(completePathToConfigFile, 'r').readlines() + phpHandler = '' + + for items in data: + if items.find('AddHandler') > -1 and items.find('php') > -1: + phpHandler = items + break + + confFile = open(completePathToConfigFile, 'a') + + doNotModify = '\n\n# Do not modify this file, this is auto-generated file.\n\n' + + VirtualHost = '\n\n' + ServerName = ' ServerName ' + virtualHostName + '\n' + ServerAlias = ' ServerAlias www.' + virtualHostName + '\n' + ScriptAlias = ' Alias /.filemanager/ /usr/local/lsws/FileManager\n' + ServerAdmin = ' ServerAdmin ' + adminEmail + '\n' + SeexecUserGroup = ' SuexecUserGroup ' + externalApp + ' ' + externalApp + '\n' + CustomLogCombined = ' CustomLog /home/' + virtualHostName + '/logs/' + virtualHostName + '.access_log combined\n' + + confFile.writelines(doNotModify) + confFile.writelines(VirtualHost) + confFile.writelines(ServerName) + confFile.writelines(ServerAlias) + confFile.writelines(ScriptAlias) + confFile.writelines(ServerAdmin) + confFile.writelines(SeexecUserGroup) + confFile.writelines(DocumentRoot) + confFile.writelines(CustomLogCombined) + DirectoryFileManager = """\n + AllowOverride All + Options +Includes -Indexes +ExecCGI + php_value display_errors "Off" + php_value upload_max_filesize "200M" + php_value post_max_size "250M" + \n""" + confFile.writelines(DirectoryFileManager) + + SSLEngine = ' SSLEngine on\n' + SSLVerifyClient = ' SSLVerifyClient none\n' + SSLCertificateFile = ' SSLCertificateFile /etc/letsencrypt/live/' + virtualHostName + '/fullchain.pem\n' + SSLCertificateKeyFile = ' SSLCertificateKeyFile /etc/letsencrypt/live/' + virtualHostName + '/privkey.pem\n' + + confFile.writelines(SSLEngine) + confFile.writelines(SSLVerifyClient) + confFile.writelines(SSLCertificateFile) + confFile.writelines(SSLCertificateKeyFile) + confFile.writelines(phpHandler) + + VirtualHostEnd = '\n' + confFile.writelines(VirtualHostEnd) + confFile.close() + return 1 + + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installSSLForDomain]") + return 0 - except BaseException, msg: - logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installSSLForDomain]]") - return 0 @staticmethod def obtainSSLForADomain(virtualHostName,adminEmail,sslpath, aliasDomain = None): try: acmePath = '/root/.acme.sh/acme.sh' - if os.path.exists('/etc/lsb-release'): + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: acmePath = '/home/cyberpanel/.acme.sh/acme.sh' if not os.path.exists(acmePath): @@ -239,30 +320,13 @@ class sslUtilities: def issueSSLForDomain(domain, adminEmail, sslpath, aliasDomain = None): try: - if sslUtilities.obtainSSLForADomain(domain, adminEmail, sslpath, aliasDomain) == 1: - - if sslUtilities.installSSLForDomain(domain) == 1: + if sslUtilities.installSSLForDomain(domain, adminEmail) == 1: return [1, "None"] else: return [0, "210 Failed to install SSL for domain. [issueSSLForDomain]"] else: - pathToStoreSSL = "/etc/letsencrypt/live/" + domain - command = 'mkdir -p ' + pathToStoreSSL - subprocess.call(shlex.split(command)) - - pathToStoreSSLPrivKey = "/etc/letsencrypt/live/" + domain + "/privkey.pem" - pathToStoreSSLFullChain = "/etc/letsencrypt/live/" + domain + "/fullchain.pem" - - command = 'openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout ' + pathToStoreSSLPrivKey + ' -out ' + pathToStoreSSLFullChain - cmd = shlex.split(command) - subprocess.call(cmd) - - if sslUtilities.installSSLForDomain(domain) == 1: - logging.CyberCPLogFileWriter.writeToFile("Self signed SSL issued for " + domain + ".") - return [1, "None"] - else: - return [0, "220 Failed to install SSL for domain. [issueSSLForDomain]"] + return [0, "283 Failed to obtain SSL for domain. [issueSSLForDomain]"] except BaseException,msg: return [0, "347 "+ str(msg)+ " [issueSSLForDomain]"] \ No newline at end of file diff --git a/plogical/vhost.py b/plogical/vhost.py index a8aa849ce..e9932c80e 100644 --- a/plogical/vhost.py +++ b/plogical/vhost.py @@ -16,6 +16,7 @@ from databases.models import Databases from mysqlUtilities import mysqlUtilities from dnsUtilities import DNS from random import randint +from processUtilities import ProcessUtilities ## If you want justice, you have come to the wrong place. @@ -87,7 +88,12 @@ class vhost: cmd = shlex.split(command) subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) - command = "chmod -R 666 " + pathLogs + + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + command = "chmod -R 666 " + pathLogs + else: + command = "chmod -R 755 " + pathLogs + cmd = shlex.split(command) subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) @@ -176,215 +182,279 @@ class vhost: @staticmethod def perHostVirtualConf(vhFile, administratorEmail,virtualHostUser, phpVersion, virtualHostName, openBasedir): # General Configurations tab - try: - confFile = open(vhFile, "w+") + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + try: + confFile = open(vhFile, "w+") - docRoot = "docRoot $VH_ROOT/public_html" + "\n" - vhDomain = "vhDomain $VH_NAME" + "\n" - vhAliases = "vhAliases www.$VH_NAME"+ "\n" - adminEmails = "adminEmails " + administratorEmail + "\n" - enableGzip = "enableGzip 1" + "\n" - enableIpGeo = "enableIpGeo 1" + "\n" + "\n" + docRoot = "docRoot $VH_ROOT/public_html" + "\n" + vhDomain = "vhDomain $VH_NAME" + "\n" + vhAliases = "vhAliases www.$VH_NAME"+ "\n" + adminEmails = "adminEmails " + administratorEmail + "\n" + enableGzip = "enableGzip 1" + "\n" + enableIpGeo = "enableIpGeo 1" + "\n" + "\n" - confFile.writelines(docRoot) - confFile.writelines(vhDomain) - confFile.writelines(vhAliases) - confFile.writelines(adminEmails) - confFile.writelines(enableGzip) - confFile.writelines(enableIpGeo) + confFile.writelines(docRoot) + confFile.writelines(vhDomain) + confFile.writelines(vhAliases) + confFile.writelines(adminEmails) + confFile.writelines(enableGzip) + confFile.writelines(enableIpGeo) - # Index file settings + # Index file settings - index = "index {" + "\n" - userServer = " useServer 0" + "\n" - indexFiles = " indexFiles index.php, index.html" + "\n" - index_end = "}" + "\n" + "\n" + index = "index {" + "\n" + userServer = " useServer 0" + "\n" + indexFiles = " indexFiles index.php, index.html" + "\n" + index_end = "}" + "\n" + "\n" - confFile.writelines(index) - confFile.writelines(userServer) - confFile.writelines(indexFiles) - confFile.writelines(index_end) + confFile.writelines(index) + confFile.writelines(userServer) + confFile.writelines(indexFiles) + confFile.writelines(index_end) - # Error Log Settings + # Error Log Settings - error_log = "errorlog $VH_ROOT/logs/$VH_NAME.error_log {" + "\n" - useServer = " useServer 0" + "\n" - logLevel = " logLevel ERROR" + "\n" - rollingSize = " rollingSize 10M" + "\n" - error_log_end = "}" + "\n" + "\n" + error_log = "errorlog $VH_ROOT/logs/$VH_NAME.error_log {" + "\n" + useServer = " useServer 0" + "\n" + logLevel = " logLevel ERROR" + "\n" + rollingSize = " rollingSize 10M" + "\n" + error_log_end = "}" + "\n" + "\n" - confFile.writelines(error_log) - confFile.writelines(useServer) - confFile.writelines(logLevel) - confFile.writelines(rollingSize) - confFile.writelines(error_log_end) + confFile.writelines(error_log) + confFile.writelines(useServer) + confFile.writelines(logLevel) + confFile.writelines(rollingSize) + confFile.writelines(error_log_end) - # Access Log Settings + # Access Log Settings - access_Log = "accesslog $VH_ROOT/logs/$VH_NAME.access_log {" + "\n" - useServer = " useServer 0" + "\n" - logFormat = ' logFormat "%v %h %l %u %t \"%r\" %>s %b"' + "\n" - logHeaders = " logHeaders 5" + "\n" - rollingSize = " rollingSize 10M" + "\n" - keepDays = " keepDays 10" - compressArchive = " compressArchive 1" + "\n" - access_Log_end = "}" + "\n" + "\n" + access_Log = "accesslog $VH_ROOT/logs/$VH_NAME.access_log {" + "\n" + useServer = " useServer 0" + "\n" + logFormat = ' logFormat "%v %h %l %u %t \"%r\" %>s %b"' + "\n" + logHeaders = " logHeaders 5" + "\n" + rollingSize = " rollingSize 10M" + "\n" + keepDays = " keepDays 10" + compressArchive = " compressArchive 1" + "\n" + access_Log_end = "}" + "\n" + "\n" - confFile.writelines(access_Log) - confFile.writelines(useServer) - confFile.writelines(logFormat) - confFile.writelines(logHeaders) - confFile.writelines(rollingSize) - confFile.writelines(keepDays) - confFile.writelines(compressArchive) - confFile.writelines(access_Log_end) + confFile.writelines(access_Log) + confFile.writelines(useServer) + confFile.writelines(logFormat) + confFile.writelines(logHeaders) + confFile.writelines(rollingSize) + confFile.writelines(keepDays) + confFile.writelines(compressArchive) + confFile.writelines(access_Log_end) - # php settings + # php settings - scripthandler = "scripthandler {" + "\n" - add = " add lsapi:"+virtualHostUser+" php" + "\n" - php_end = "}" + "\n" + "\n" + scripthandler = "scripthandler {" + "\n" + add = " add lsapi:"+virtualHostUser+" php" + "\n" + php_end = "}" + "\n" + "\n" - confFile.writelines(scripthandler) - confFile.writelines(add) - confFile.writelines(php_end) + confFile.writelines(scripthandler) + confFile.writelines(add) + confFile.writelines(php_end) - ## external app + ## external app - if phpVersion == "PHP 5.3": - php = "53" - elif phpVersion == "PHP 5.4": - php = "55" - elif phpVersion == "PHP 5.5": - php = "55" - elif phpVersion == "PHP 5.6": - php = "56" - elif phpVersion == "PHP 7.0": - php = "70" - elif phpVersion == "PHP 7.1": - php = "71" - elif phpVersion == "PHP 7.2": - php = "72" + if phpVersion == "PHP 5.3": + php = "53" + elif phpVersion == "PHP 5.4": + php = "55" + elif phpVersion == "PHP 5.5": + php = "55" + elif phpVersion == "PHP 5.6": + php = "56" + elif phpVersion == "PHP 7.0": + php = "70" + elif phpVersion == "PHP 7.1": + php = "71" + elif phpVersion == "PHP 7.2": + php = "72" - extprocessor = "extprocessor "+virtualHostUser+" {\n" - type = " type lsapi\n" - address = " address UDS://tmp/lshttpd/"+virtualHostUser+".sock\n" - maxConns = " maxConns 10\n" - env = " env LSAPI_CHILDREN=10\n" - initTimeout = " initTimeout 600\n" - retryTimeout = " retryTimeout 0\n" - persistConn = " persistConn 1\n" - persistConnTimeout = " pcKeepAliveTimeout 1\n" - respBuffer = " respBuffer 0\n" - autoStart = " autoStart 1\n" - path = " path /usr/local/lsws/lsphp"+php+"/bin/lsphp\n" - extUser = " extUser " + virtualHostUser + "\n" - extGroup = " extGroup " + virtualHostUser + "\n" - memSoftLimit = " memSoftLimit 2047M\n" - memHardLimit = " memHardLimit 2047M\n" - procSoftLimit = " procSoftLimit 400\n" - procHardLimit = " procHardLimit 500\n" - extprocessorEnd = "}\n" + extprocessor = "extprocessor "+virtualHostUser+" {\n" + type = " type lsapi\n" + address = " address UDS://tmp/lshttpd/"+virtualHostUser+".sock\n" + maxConns = " maxConns 10\n" + env = " env LSAPI_CHILDREN=10\n" + initTimeout = " initTimeout 600\n" + retryTimeout = " retryTimeout 0\n" + persistConn = " persistConn 1\n" + persistConnTimeout = " pcKeepAliveTimeout 1\n" + respBuffer = " respBuffer 0\n" + autoStart = " autoStart 1\n" + path = " path /usr/local/lsws/lsphp"+php+"/bin/lsphp\n" + extUser = " extUser " + virtualHostUser + "\n" + extGroup = " extGroup " + virtualHostUser + "\n" + memSoftLimit = " memSoftLimit 2047M\n" + memHardLimit = " memHardLimit 2047M\n" + procSoftLimit = " procSoftLimit 400\n" + procHardLimit = " procHardLimit 500\n" + extprocessorEnd = "}\n" - confFile.writelines(extprocessor) - confFile.writelines(type) - confFile.writelines(address) - confFile.writelines(maxConns) - confFile.writelines(env) - confFile.writelines(initTimeout) - confFile.writelines(retryTimeout) - confFile.writelines(persistConn) - confFile.writelines(persistConnTimeout) - confFile.writelines(respBuffer) - confFile.writelines(autoStart) - confFile.writelines(path) - confFile.writelines(extUser) - confFile.writelines(extGroup) - confFile.writelines(memSoftLimit) - confFile.writelines(memHardLimit) - confFile.writelines(procSoftLimit) - confFile.writelines(procHardLimit) - confFile.writelines(extprocessorEnd) + confFile.writelines(extprocessor) + confFile.writelines(type) + confFile.writelines(address) + confFile.writelines(maxConns) + confFile.writelines(env) + confFile.writelines(initTimeout) + confFile.writelines(retryTimeout) + confFile.writelines(persistConn) + confFile.writelines(persistConnTimeout) + confFile.writelines(respBuffer) + confFile.writelines(autoStart) + confFile.writelines(path) + confFile.writelines(extUser) + confFile.writelines(extGroup) + confFile.writelines(memSoftLimit) + confFile.writelines(memHardLimit) + confFile.writelines(procSoftLimit) + confFile.writelines(procHardLimit) + confFile.writelines(extprocessorEnd) - ## File Manager defination + ## File Manager defination - context = "context /.filemanager {\n" - location = " location /usr/local/lsws/Example/html/FileManager\n" - allowBrowse = " allowBrowse 1\n" - autoIndex = " autoIndex 1\n\n" + context = "context /.filemanager {\n" + location = " location /usr/local/lsws/Example/html/FileManager\n" + allowBrowse = " allowBrowse 1\n" + autoIndex = " autoIndex 1\n\n" - accessControl = " accessControl {\n" - allow = " allow 127.0.0.1, localhost\n" - deny = " deny 0.0.0.0/0\n" - accessControlEnds = " }\n" + accessControl = " accessControl {\n" + allow = " allow 127.0.0.1, localhost\n" + deny = " deny 0.0.0.0/0\n" + accessControlEnds = " }\n" - rewriteInherit = """ rewrite { - inherit 0 + rewriteInherit = """ rewrite { + inherit 0 + + } + """ - } - """ - - phpIniOverride = "phpIniOverride {\n" - php_admin_value = 'php_admin_value open_basedir "/tmp:/usr/local/lsws/Example/html/FileManager:$VH_ROOT"\n' - php_value = 'php_value display_errors "Off"\n' - php_value_upload_max_size = 'php_value upload_max_filesize "200M"\n' - php_value_post_max_size = 'php_value post_max_size "250M"\n' - endPHPIniOverride = "}\n" + phpIniOverride = "phpIniOverride {\n" + php_admin_value = 'php_admin_value open_basedir "/tmp:/usr/local/lsws/Example/html/FileManager:$VH_ROOT"\n' + php_value = 'php_value display_errors "Off"\n' + php_value_upload_max_size = 'php_value upload_max_filesize "200M"\n' + php_value_post_max_size = 'php_value post_max_size "250M"\n' + endPHPIniOverride = "}\n" - defaultCharSet = " addDefaultCharset off\n" - contextEnds = "}\n" + defaultCharSet = " addDefaultCharset off\n" + contextEnds = "}\n" - confFile.writelines(context) - confFile.writelines(location) - confFile.writelines(allowBrowse) - confFile.writelines(autoIndex) - confFile.writelines(accessControl) - confFile.writelines(allow) - confFile.writelines(deny) - confFile.writelines(accessControlEnds) - confFile.write(rewriteInherit) + confFile.writelines(context) + confFile.writelines(location) + confFile.writelines(allowBrowse) + confFile.writelines(autoIndex) + confFile.writelines(accessControl) + confFile.writelines(allow) + confFile.writelines(deny) + confFile.writelines(accessControlEnds) + confFile.write(rewriteInherit) - confFile.writelines(phpIniOverride) - if openBasedir == 1: - confFile.writelines(php_admin_value) - confFile.write(php_value) - confFile.write(php_value_upload_max_size) - confFile.write(php_value_post_max_size) - confFile.writelines(endPHPIniOverride) + confFile.writelines(phpIniOverride) + if openBasedir == 1: + confFile.writelines(php_admin_value) + confFile.write(php_value) + confFile.write(php_value_upload_max_size) + confFile.write(php_value_post_max_size) + confFile.writelines(endPHPIniOverride) - confFile.writelines(defaultCharSet) - confFile.writelines(contextEnds) + confFile.writelines(defaultCharSet) + confFile.writelines(contextEnds) - ## OpenBase Dir Protection + ## OpenBase Dir Protection - phpIniOverride = "phpIniOverride {\n" - php_admin_value = 'php_admin_value open_basedir "/tmp:$VH_ROOT"\n' - endPHPIniOverride = "}\n" + phpIniOverride = "phpIniOverride {\n" + php_admin_value = 'php_admin_value open_basedir "/tmp:$VH_ROOT"\n' + endPHPIniOverride = "}\n" - confFile.writelines(phpIniOverride) - if openBasedir == 1: - confFile.writelines(php_admin_value) - confFile.writelines(endPHPIniOverride) + confFile.writelines(phpIniOverride) + if openBasedir == 1: + confFile.writelines(php_admin_value) + confFile.writelines(endPHPIniOverride) - htaccessAutoLoad = """ -rewrite { - enable 1 - autoLoadHtaccess 1 -} -""" - confFile.write(htaccessAutoLoad) + htaccessAutoLoad = """ + rewrite { + enable 1 + autoLoadHtaccess 1 + } + """ + confFile.write(htaccessAutoLoad) - confFile.close() + confFile.close() + + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile( + str(msg) + " [IO Error with per host config file [perHostVirtualConf]]") + return 0 + return 1 + else: + try: + confFile = open(vhFile, "w+") + + doNotModify = '# Do not modify this file, this is auto-generated file.\n\n' + + VirtualHost = '\n\n' + ServerName = ' ServerName ' + virtualHostName + '\n' + ServerAlias = ' ServerAlias www.' + virtualHostName + '\n' + ScriptAlias = ' Alias /.filemanager/ /usr/local/lsws/FileManager\n' + ServerAdmin = ' ServerAdmin ' + administratorEmail + '\n' + SeexecUserGroup = ' SuexecUserGroup ' + virtualHostUser + ' ' + virtualHostUser + '\n' + DocumentRoot = ' DocumentRoot /home/' + virtualHostName + '/public_html\n' + CustomLogCombined = ' CustomLog /home/' + virtualHostName + '/logs/' + virtualHostName + '.access_log combined\n' + + confFile.writelines(doNotModify) + confFile.writelines(VirtualHost) + confFile.writelines(ServerName) + confFile.writelines(ServerAlias) + confFile.writelines(ScriptAlias) + confFile.writelines(ServerAdmin) + confFile.writelines(SeexecUserGroup) + confFile.writelines(DocumentRoot) + confFile.writelines(CustomLogCombined) + + DirectoryFileManager = """\n + Options +Includes -Indexes +ExecCGI + php_value display_errors "Off" + php_value upload_max_filesize "200M" + php_value post_max_size "250M" + \n""" + confFile.writelines(DirectoryFileManager) + + ## external app + + if phpVersion == "PHP 5.3": + php = "53" + elif phpVersion == "PHP 5.4": + php = "55" + elif phpVersion == "PHP 5.5": + php = "55" + elif phpVersion == "PHP 5.6": + php = "56" + elif phpVersion == "PHP 7.0": + php = "70" + elif phpVersion == "PHP 7.1": + php = "71" + elif phpVersion == "PHP 7.2": + php = "72" + + AddType = ' AddHandler application/x-httpd-php' + php + ' .php .php7 .phtml\n\n' + VirtualHostEnd = '\n' + + confFile.writelines(AddType) + confFile.writelines(VirtualHostEnd) + + confFile.close() + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile( + str(msg) + " [IO Error with per host config file [perHostVirtualConf]]") + return 0 + return 1 - except BaseException, msg: - logging.CyberCPLogFileWriter.writeToFile( - str(msg) + " [IO Error with per host config file [perHostVirtualConf]]") - return 0 - return 1 @staticmethod def createNONSSLMapEntry(virtualHostName): @@ -420,121 +490,203 @@ rewrite { #restrained 1 #} - try: + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + try: - if vhost.createNONSSLMapEntry(virtualHostName) == 0: - return [0, "Failed to create NON SSL Map Entry [createConfigInMainVirtualHostFile]"] + if vhost.createNONSSLMapEntry(virtualHostName) == 0: + return [0, "Failed to create NON SSL Map Entry [createConfigInMainVirtualHostFile]"] - writeDataToFile = open("/usr/local/lsws/conf/httpd_config.conf", 'a') + writeDataToFile = open("/usr/local/lsws/conf/httpd_config.conf", 'a') - writeDataToFile.writelines("virtualHost " + virtualHostName + " {\n") - writeDataToFile.writelines(" vhRoot /home/$VH_NAME\n") - writeDataToFile.writelines(" configFile $SERVER_ROOT/conf/vhosts/$VH_NAME/vhost.conf\n") - writeDataToFile.writelines(" allowSymbolLink 1\n") - writeDataToFile.writelines(" enableScript 1\n") - writeDataToFile.writelines(" restrained 1\n") - writeDataToFile.writelines("}\n") - writeDataToFile.writelines("\n") + writeDataToFile.writelines("virtualHost " + virtualHostName + " {\n") + writeDataToFile.writelines(" vhRoot /home/$VH_NAME\n") + writeDataToFile.writelines(" configFile $SERVER_ROOT/conf/vhosts/$VH_NAME/vhost.conf\n") + writeDataToFile.writelines(" allowSymbolLink 1\n") + writeDataToFile.writelines(" enableScript 1\n") + writeDataToFile.writelines(" restrained 1\n") + writeDataToFile.writelines("}\n") + writeDataToFile.writelines("\n") - writeDataToFile.close() + writeDataToFile.close() - writeDataToFile.close() - return [1,"None"] + writeDataToFile.close() + return [1,"None"] + except BaseException,msg: + logging.CyberCPLogFileWriter.writeToFile(str(msg) + "223 [IO Error with main config file [createConfigInMainVirtualHostFile]]") + return [0,"223 [IO Error with main config file [createConfigInMainVirtualHostFile]]"] + else: + try: + writeDataToFile = open("/usr/local/lsws/conf/httpd.conf", 'a') + configFile = 'Include /usr/local/lsws/conf/vhosts/' + virtualHostName + '/vhost.conf\n' + writeDataToFile.writelines(configFile) + writeDataToFile.close() - except BaseException,msg: - logging.CyberCPLogFileWriter.writeToFile(str(msg) + "223 [IO Error with main config file [createConfigInMainVirtualHostFile]]") - return [0,"223 [IO Error with main config file [createConfigInMainVirtualHostFile]]"] + writeDataToFile.close() + return [1, "None"] + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile( + str(msg) + "223 [IO Error with main config file [createConfigInMainVirtualHostFile]]") + return [0, "223 [IO Error with main config file [createConfigInMainVirtualHostFile]]"] @staticmethod def deleteVirtualHostConfigurations(virtualHostName): + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + try: - try: + ## Deleting master conf + numberOfSites = str(Websites.objects.count() + ChildDomains.objects.count()) + vhost.deleteCoreConf(virtualHostName, numberOfSites) - ## Deleting master conf - numberOfSites = str(Websites.objects.count() + ChildDomains.objects.count()) - vhost.deleteCoreConf(virtualHostName, numberOfSites) + delWebsite = Websites.objects.get(domain=virtualHostName) + databases = Databases.objects.filter(website=delWebsite) - delWebsite = Websites.objects.get(domain=virtualHostName) - databases = Databases.objects.filter(website=delWebsite) + childDomains = delWebsite.childdomains_set.all() - childDomains = delWebsite.childdomains_set.all() + ## Deleting child domains - ## Deleting child domains + for items in childDomains: + numberOfSites = Websites.objects.count() + ChildDomains.objects.count() + vhost.deleteCoreConf(items.domain, numberOfSites) - for items in childDomains: - numberOfSites = Websites.objects.count() + ChildDomains.objects.count() - vhost.deleteCoreConf(items.domain, numberOfSites) + for items in databases: + mysqlUtilities.deleteDatabase(items.dbName, items.dbUser) - for items in databases: - mysqlUtilities.deleteDatabase(items.dbName, items.dbUser) + delWebsite.delete() - delWebsite.delete() + ## Deleting DNS Zone if there is any. - ## Deleting DNS Zone if there is any. + DNS.deleteDNSZone(virtualHostName) - DNS.deleteDNSZone(virtualHostName) + installUtilities.installUtilities.reStartLiteSpeed() - installUtilities.installUtilities.reStartLiteSpeed() + ## Delete mail accounts - ## Delete mail accounts + command = "sudo rm -rf /home/vmail/" + virtualHostName + subprocess.call(shlex.split(command)) + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [Not able to remove virtual host configuration from main configuration file.]") + return 0 + return 1 + else: + try: + ## Deleting master conf + numberOfSites = str(Websites.objects.count() + ChildDomains.objects.count()) + vhost.deleteCoreConf(virtualHostName, numberOfSites) - command = "sudo rm -rf /home/vmail/" + virtualHostName - subprocess.call(shlex.split(command)) + delWebsite = Websites.objects.get(domain=virtualHostName) + databases = Databases.objects.filter(website=delWebsite) - except BaseException, msg: - logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [Not able to remove virtual host configuration from main configuration file.]") - return 0 + childDomains = delWebsite.childdomains_set.all() + + ## Deleting child domains + + for items in childDomains: + numberOfSites = Websites.objects.count() + ChildDomains.objects.count() + vhost.deleteCoreConf(items.domain, numberOfSites) + + for items in databases: + mysqlUtilities.deleteDatabase(items.dbName, items.dbUser) + + delWebsite.delete() + + ## Deleting DNS Zone if there is any. + + DNS.deleteDNSZone(virtualHostName) + + installUtilities.installUtilities.reStartLiteSpeed() + + ## Delete mail accounts + + command = "sudo rm -rf /home/vmail/" + virtualHostName + subprocess.call(shlex.split(command)) + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile( + str(msg) + " [Not able to remove virtual host configuration from main configuration file.]") + return 0 + return 1 - return 1 @staticmethod def deleteCoreConf(virtualHostName, numberOfSites): - try: + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + try: + virtualHostPath = "/home/" + virtualHostName + if os.path.exists(virtualHostPath): + shutil.rmtree(virtualHostPath) + + confPath = vhost.Server_root + "/conf/vhosts/" + virtualHostName + if os.path.exists(confPath): + shutil.rmtree(confPath) + + data = open("/usr/local/lsws/conf/httpd_config.conf").readlines() + + writeDataToFile = open("/usr/local/lsws/conf/httpd_config.conf", 'w') + + check = 1 + sslCheck = 1 + + for items in data: + if numberOfSites == 1: + if (items.find(' ' + virtualHostName) > -1 and items.find(" map " + virtualHostName) > -1): + continue + if (items.find(' ' + virtualHostName) > -1 and (items.find("virtualHost") > -1 or items.find("virtualhost") > -1)): + check = 0 + if items.find("listener") > -1 and items.find("SSL") > -1: + sslCheck = 0 + if (check == 1 and sslCheck == 1): + writeDataToFile.writelines(items) + if (items.find("}") > -1 and (check == 0 or sslCheck == 0)): + check = 1 + sslCheck = 1 + else: + if (items.find(' ' + virtualHostName) > -1 and items.find(" map " + virtualHostName) > -1): + continue + if (items.find(' ' + virtualHostName) > -1 and (items.find("virtualHost") > -1 or items.find("virtualhost") > -1)): + check = 0 + if (check == 1): + writeDataToFile.writelines(items) + if (items.find("}") > -1 and check == 0): + check = 1 + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile( + str(msg) + " [Not able to remove virtual host configuration from main configuration file.]") + return 0 + return 1 + else: virtualHostPath = "/home/" + virtualHostName - if os.path.exists(virtualHostPath): + try: shutil.rmtree(virtualHostPath) + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile( + str(msg) + " [Not able to remove virtual host directory from /home continuing..]") - confPath = vhost.Server_root + "/conf/vhosts/" + virtualHostName - if os.path.exists(confPath): + try: + confPath = vhost.Server_root + "/conf/vhosts/" + virtualHostName shutil.rmtree(confPath) + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile( + str(msg) + " [Not able to remove virtual host configuration directory from /conf ]") - data = open("/usr/local/lsws/conf/httpd_config.conf").readlines() + try: + data = open("/usr/local/lsws/conf/httpd.conf").readlines() - writeDataToFile = open("/usr/local/lsws/conf/httpd_config.conf", 'w') + writeDataToFile = open("/usr/local/lsws/conf/httpd.conf", 'w') - check = 1 - sslCheck = 1 - - for items in data: - if numberOfSites == 1: - if (items.find(' ' + virtualHostName) > -1 and items.find(" map " + virtualHostName) > -1): - continue - if (items.find(' ' + virtualHostName) > -1 and (items.find("virtualHost") > -1 or items.find("virtualhost") > -1)): - check = 0 - if items.find("listener") > -1 and items.find("SSL") > -1: - sslCheck = 0 - if (check == 1 and sslCheck == 1): + for items in data: + if items.find('/' + virtualHostName + '/') > -1: + pass + else: writeDataToFile.writelines(items) - if (items.find("}") > -1 and (check == 0 or sslCheck == 0)): - check = 1 - sslCheck = 1 - else: - if (items.find(' ' + virtualHostName) > -1 and items.find(" map " + virtualHostName) > -1): - continue - if (items.find(' ' + virtualHostName) > -1 and (items.find("virtualHost") > -1 or items.find("virtualhost") > -1)): - check = 0 - if (check == 1): - writeDataToFile.writelines(items) - if (items.find("}") > -1 and check == 0): - check = 1 - except BaseException, msg: - logging.CyberCPLogFileWriter.writeToFile( - str(msg) + " [Not able to remove virtual host configuration from main configuration file.]") - return 0 - return 1 + writeDataToFile.close() + + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile( + str(msg) + " [Not able to remove virtual host configuration from main configuration file.]") + return 0 + return 1 @staticmethod def checkIfVirtualHostExists(virtualHostName): @@ -544,51 +696,88 @@ rewrite { @staticmethod def changePHP(vhFile, phpVersion): + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + finalphp = 0 + try: + data = open(vhFile, "r").readlines() - # General Configurations tab + if phpVersion == "PHP 5.3": + finalphp = 53 + elif phpVersion == "PHP 5.4": + finalphp = 54 + elif phpVersion == "PHP 5.5": + finalphp = 55 + elif phpVersion == "PHP 5.6": + finalphp = 56 + elif phpVersion == "PHP 7.0": + finalphp = 70 + elif phpVersion == "PHP 7.1": + finalphp = 71 + elif phpVersion == "PHP 7.2": + finalphp = 72 - finalphp = 0 + writeDataToFile = open(vhFile, "w") - try: - data = open(vhFile, "r").readlines() + path = " path /usr/local/lsws/lsphp" + str(finalphp) + "/bin/lsphp\n" - if phpVersion == "PHP 5.3": - finalphp = 53 - elif phpVersion == "PHP 5.4": - finalphp = 54 - elif phpVersion == "PHP 5.5": - finalphp = 55 - elif phpVersion == "PHP 5.6": - finalphp = 56 - elif phpVersion == "PHP 7.0": - finalphp = 70 - elif phpVersion == "PHP 7.1": - finalphp = 71 - elif phpVersion == "PHP 7.2": - finalphp = 72 + for items in data: + if items.find("/usr/local/lsws/lsphp") > -1 and items.find("path") > -1: + writeDataToFile.writelines(path) + else: + writeDataToFile.writelines(items) - writeDataToFile = open(vhFile, "w") + writeDataToFile.close() - path = " path /usr/local/lsws/lsphp" + str(finalphp) + "/bin/lsphp\n" + installUtilities.installUtilities.reStartLiteSpeed() - for items in data: - if items.find("/usr/local/lsws/lsphp") > -1 and items.find("path") > -1: - writeDataToFile.writelines(path) - else: - writeDataToFile.writelines(items) + print "1,None" + return 1,'None' + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile( + str(msg) + " [IO Error with per host config file [changePHP]]") + print 0,str(msg) + return [0, str(msg) + " [IO Error with per host config file [changePHP]]"] + else: + try: + data = open(vhFile, "r").readlines() + if phpVersion == "PHP 5.3": + finalphp = 53 - writeDataToFile.close() + elif phpVersion == "PHP 5.4": + finalphp = 54 + elif phpVersion == "PHP 5.5": + finalphp = 55 + elif phpVersion == "PHP 5.6": + finalphp = 56 + elif phpVersion == "PHP 7.0": + finalphp = 70 + elif phpVersion == "PHP 7.1": + finalphp = 71 + elif phpVersion == "PHP 7.2": + finalphp = 72 - installUtilities.installUtilities.reStartLiteSpeed() + writeDataToFile = open(vhFile, "w") - print "1,None" - return 1,'None' + finalString = ' AddHandler application/x-httpd-php' + str(finalphp) + ' .php\n' + + for items in data: + if items.find("AddHandler application/x-httpd") > -1: + writeDataToFile.writelines(finalString) + else: + writeDataToFile.writelines(items) + + writeDataToFile.close() + + installUtilities.installUtilities.reStartLiteSpeed() + + print "1,None" + return 1, 'None' + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile( + str(msg) + " [IO Error with per host config file [changePHP]]") + print 0, str(msg) + return [0, str(msg) + " [IO Error with per host config file [changePHP]]"] - except BaseException, msg: - logging.CyberCPLogFileWriter.writeToFile( - str(msg) + " [IO Error with per host config file [changePHP]]") - print 0,str(msg) - return [0, str(msg) + " [IO Error with per host config file [changePHP]]"] @staticmethod def addRewriteRules(virtualHostName, fileName=None): @@ -648,8 +837,6 @@ rewrite { print str(inMB) + "," + str(percentage) else: print "0,0" - - except OSError, msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [findDomainBW]") print "0,0" @@ -782,176 +969,227 @@ rewrite { logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createDirectoryForDomain]]") return [0, "[351 Not able to directories for virtual host [createDirectoryForDomain]]"] - if vhost.perHostDomainConf(path, masterDomain, completePathToConfigFile, - administratorEmail, phpVersion, virtualHostUser, openBasedir) == 1: + if vhost.perHostDomainConf(path, masterDomain, domain, completePathToConfigFile, + administratorEmail, phpVersion, virtualHostUser, openBasedir) == 1: return [1, "None"] else: return [0, "[359 Not able to create per host virtual configurations [perHostVirtualConf]"] @staticmethod - def perHostDomainConf(path, masterDomain, vhFile, administratorEmail, phpVersion, virtualHostUser, openBasedir): + def perHostDomainConf(path, masterDomain, domain, vhFile, administratorEmail, phpVersion, virtualHostUser, openBasedir): + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + try: + confFile = open(vhFile, "w+") - # General Configurations tab + docRoot = "docRoot " + path + "\n" + vhDomain = "vhDomain $VH_NAME" + "\n" + vhAliases = "vhAliases www.$VH_NAME" + "\n" + adminEmails = "adminEmails " + administratorEmail + "\n" + enableGzip = "enableGzip 1" + "\n" + enableIpGeo = "enableIpGeo 1" + "\n" + "\n" - try: - confFile = open(vhFile, "w+") + confFile.writelines(docRoot) + confFile.writelines(vhDomain) + confFile.writelines(vhAliases) + confFile.writelines(adminEmails) + confFile.writelines(enableGzip) + confFile.writelines(enableIpGeo) - docRoot = "docRoot " + path + "\n" - vhDomain = "vhDomain $VH_NAME" + "\n" - vhAliases = "vhAliases www.$VH_NAME" + "\n" - adminEmails = "adminEmails " + administratorEmail + "\n" - enableGzip = "enableGzip 1" + "\n" - enableIpGeo = "enableIpGeo 1" + "\n" + "\n" + # Index file settings - confFile.writelines(docRoot) - confFile.writelines(vhDomain) - confFile.writelines(vhAliases) - confFile.writelines(adminEmails) - confFile.writelines(enableGzip) - confFile.writelines(enableIpGeo) + index = "index {" + "\n" + userServer = " useServer 0" + "\n" + indexFiles = " indexFiles index.php, index.html" + "\n" + index_end = "}" + "\n" + "\n" - # Index file settings + confFile.writelines(index) + confFile.writelines(userServer) + confFile.writelines(indexFiles) + confFile.writelines(index_end) - index = "index {" + "\n" - userServer = " useServer 0" + "\n" - indexFiles = " indexFiles index.php, index.html" + "\n" - index_end = "}" + "\n" + "\n" - - confFile.writelines(index) - confFile.writelines(userServer) - confFile.writelines(indexFiles) - confFile.writelines(index_end) - - # Error Log Settings + # Error Log Settings - error_log = "errorlog $VH_ROOT/logs/" + masterDomain + ".error_log {" + "\n" - useServer = " useServer 0" + "\n" - logLevel = " logLevel ERROR" + "\n" - rollingSize = " rollingSize 10M" + "\n" - error_log_end = "}" + "\n" + "\n" + error_log = "errorlog $VH_ROOT/logs/" + masterDomain + ".error_log {" + "\n" + useServer = " useServer 0" + "\n" + logLevel = " logLevel ERROR" + "\n" + rollingSize = " rollingSize 10M" + "\n" + error_log_end = "}" + "\n" + "\n" - confFile.writelines(error_log) - confFile.writelines(useServer) - confFile.writelines(logLevel) - confFile.writelines(rollingSize) - confFile.writelines(error_log_end) + confFile.writelines(error_log) + confFile.writelines(useServer) + confFile.writelines(logLevel) + confFile.writelines(rollingSize) + confFile.writelines(error_log_end) - # Access Log Settings + # Access Log Settings - access_Log = "accesslog $VH_ROOT/logs/" + masterDomain + ".access_log {" + "\n" - useServer = " useServer 0" + "\n" - logFormat = ' logFormat "%v %h %l %u %t \"%r\" %>s %b"' + "\n" - logHeaders = " logHeaders 5" + "\n" - rollingSize = " rollingSize 10M" + "\n" - keepDays = " keepDays 10" - compressArchive = " compressArchive 1" + "\n" - access_Log_end = "}" + "\n" + "\n" + access_Log = "accesslog $VH_ROOT/logs/" + masterDomain + ".access_log {" + "\n" + useServer = " useServer 0" + "\n" + logFormat = ' logFormat "%v %h %l %u %t \"%r\" %>s %b"' + "\n" + logHeaders = " logHeaders 5" + "\n" + rollingSize = " rollingSize 10M" + "\n" + keepDays = " keepDays 10" + compressArchive = " compressArchive 1" + "\n" + access_Log_end = "}" + "\n" + "\n" - confFile.writelines(access_Log) - confFile.writelines(useServer) - confFile.writelines(logFormat) - confFile.writelines(logHeaders) - confFile.writelines(rollingSize) - confFile.writelines(keepDays) - confFile.writelines(compressArchive) - confFile.writelines(access_Log_end) + confFile.writelines(access_Log) + confFile.writelines(useServer) + confFile.writelines(logFormat) + confFile.writelines(logHeaders) + confFile.writelines(rollingSize) + confFile.writelines(keepDays) + confFile.writelines(compressArchive) + confFile.writelines(access_Log_end) - ## OpenBase Dir Protection + ## OpenBase Dir Protection - phpIniOverride = "phpIniOverride {\n" - php_admin_value = 'php_admin_value open_basedir "/tmp:/usr/local/lsws/Example/html/FileManager:$VH_ROOT"\n' - endPHPIniOverride = "}\n" + phpIniOverride = "phpIniOverride {\n" + php_admin_value = 'php_admin_value open_basedir "/tmp:/usr/local/lsws/Example/html/FileManager:$VH_ROOT"\n' + endPHPIniOverride = "}\n" - confFile.writelines(phpIniOverride) - if openBasedir == 1: - confFile.writelines(php_admin_value) - confFile.writelines(endPHPIniOverride) + confFile.writelines(phpIniOverride) + if openBasedir == 1: + confFile.writelines(php_admin_value) + confFile.writelines(endPHPIniOverride) - # php settings + # php settings - sockRandomPath = str(randint(1000, 9999)) + sockRandomPath = str(randint(1000, 9999)) - scripthandler = "scripthandler {" + "\n" - add = " add lsapi:" + virtualHostUser + sockRandomPath + " php" + "\n" - php_end = "}" + "\n" + "\n" + scripthandler = "scripthandler {" + "\n" + add = " add lsapi:" + virtualHostUser + sockRandomPath + " php" + "\n" + php_end = "}" + "\n" + "\n" - confFile.writelines(scripthandler) - confFile.writelines(add) - confFile.writelines(php_end) + confFile.writelines(scripthandler) + confFile.writelines(add) + confFile.writelines(php_end) - ## external app + ## external app - if phpVersion == "PHP 5.3": - php = "53" - elif phpVersion == "PHP 5.4": - php = "55" - elif phpVersion == "PHP 5.5": - php = "55" - elif phpVersion == "PHP 5.6": - php = "56" - elif phpVersion == "PHP 7.0": - php = "70" - elif phpVersion == "PHP 7.1": - php = "71" - elif phpVersion == "PHP 7.2": - php = "72" + if phpVersion == "PHP 5.3": + php = "53" + elif phpVersion == "PHP 5.4": + php = "55" + elif phpVersion == "PHP 5.5": + php = "55" + elif phpVersion == "PHP 5.6": + php = "56" + elif phpVersion == "PHP 7.0": + php = "70" + elif phpVersion == "PHP 7.1": + php = "71" + elif phpVersion == "PHP 7.2": + php = "72" - extprocessor = "extprocessor " + virtualHostUser + sockRandomPath + " {\n" - type = " type lsapi\n" - address = " address UDS://tmp/lshttpd/" + virtualHostUser + sockRandomPath + ".sock\n" - maxConns = " maxConns 10\n" - env = " env LSAPI_CHILDREN=10\n" - initTimeout = " initTimeout 60\n" - retryTimeout = " retryTimeout 0\n" - persistConn = " persistConn 1\n" - persistConnTimeout = " pcKeepAliveTimeout 1\n" - respBuffer = " respBuffer 0\n" - autoStart = " autoStart 1\n" - path = " path /usr/local/lsws/lsphp" + php + "/bin/lsphp\n" - extUser = " extUser " + virtualHostUser + "\n" - extGroup = " extGroup " + virtualHostUser + "\n" - memSoftLimit = " memSoftLimit 2047M\n" - memHardLimit = " memHardLimit 2047M\n" - procSoftLimit = " procSoftLimit 400\n" - procHardLimit = " procHardLimit 500\n" - extprocessorEnd = "}\n" + extprocessor = "extprocessor " + virtualHostUser + sockRandomPath + " {\n" + type = " type lsapi\n" + address = " address UDS://tmp/lshttpd/" + virtualHostUser + sockRandomPath + ".sock\n" + maxConns = " maxConns 10\n" + env = " env LSAPI_CHILDREN=10\n" + initTimeout = " initTimeout 60\n" + retryTimeout = " retryTimeout 0\n" + persistConn = " persistConn 1\n" + persistConnTimeout = " pcKeepAliveTimeout 1\n" + respBuffer = " respBuffer 0\n" + autoStart = " autoStart 1\n" + path = " path /usr/local/lsws/lsphp" + php + "/bin/lsphp\n" + extUser = " extUser " + virtualHostUser + "\n" + extGroup = " extGroup " + virtualHostUser + "\n" + memSoftLimit = " memSoftLimit 2047M\n" + memHardLimit = " memHardLimit 2047M\n" + procSoftLimit = " procSoftLimit 400\n" + procHardLimit = " procHardLimit 500\n" + extprocessorEnd = "}\n" - confFile.writelines(extprocessor) - confFile.writelines(type) - confFile.writelines(address) - confFile.writelines(maxConns) - confFile.writelines(env) - confFile.writelines(initTimeout) - confFile.writelines(retryTimeout) - confFile.writelines(persistConn) - confFile.writelines(persistConnTimeout) - confFile.writelines(respBuffer) - confFile.writelines(autoStart) - confFile.writelines(path) - confFile.writelines(extUser) - confFile.writelines(extGroup) - confFile.writelines(memSoftLimit) - confFile.writelines(memHardLimit) - confFile.writelines(procSoftLimit) - confFile.writelines(procHardLimit) - confFile.writelines(extprocessorEnd) + confFile.writelines(extprocessor) + confFile.writelines(type) + confFile.writelines(address) + confFile.writelines(maxConns) + confFile.writelines(env) + confFile.writelines(initTimeout) + confFile.writelines(retryTimeout) + confFile.writelines(persistConn) + confFile.writelines(persistConnTimeout) + confFile.writelines(respBuffer) + confFile.writelines(autoStart) + confFile.writelines(path) + confFile.writelines(extUser) + confFile.writelines(extGroup) + confFile.writelines(memSoftLimit) + confFile.writelines(memHardLimit) + confFile.writelines(procSoftLimit) + confFile.writelines(procHardLimit) + confFile.writelines(extprocessorEnd) - htaccessAutoLoad = """ -rewrite { - enable 1 - autoLoadHtaccess 1 -} -""" - confFile.write(htaccessAutoLoad) + htaccessAutoLoad = """ + rewrite { + enable 1 + autoLoadHtaccess 1 + } + """ + confFile.write(htaccessAutoLoad) - confFile.close() + confFile.close() + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile( + str(msg) + " [IO Error with per host config file [perHostDomainConf]]") + return 0 + return 1 + else: + try: + + confFile = open(vhFile, "w+") + + doNotModify = '# Do not modify this file, this is auto-generated file.\n\n' + + VirtualHost = '\n\n' + ServerName = ' ServerName ' + domain + '\n' + ServerAlias = ' ServerAlias www.' + domain + '\n' + ServerAdmin = ' ServerAdmin ' + administratorEmail + '\n' + SeexecUserGroup = ' SuexecUserGroup ' + virtualHostUser + ' ' + virtualHostUser + '\n' + DocumentRoot = ' DocumentRoot ' + path + '\n' + CustomLogCombined = ' CustomLog /home/' + masterDomain + '/logs/' + masterDomain + '.access_log combined\n' + + confFile.writelines(doNotModify) + confFile.writelines(VirtualHost) + confFile.writelines(ServerName) + confFile.writelines(ServerAlias) + confFile.writelines(ServerAdmin) + confFile.writelines(SeexecUserGroup) + confFile.writelines(DocumentRoot) + confFile.writelines(CustomLogCombined) + + ## external app + + if phpVersion == "PHP 5.3": + php = "53" + elif phpVersion == "PHP 5.4": + php = "55" + elif phpVersion == "PHP 5.5": + php = "55" + elif phpVersion == "PHP 5.6": + php = "56" + elif phpVersion == "PHP 7.0": + php = "70" + elif phpVersion == "PHP 7.1": + php = "71" + elif phpVersion == "PHP 7.2": + php = "72" + + AddType = ' AddHandler application/x-httpd-php' + php + ' .php .php7 .phtml\n\n' + VirtualHostEnd = '\n' + + confFile.writelines(AddType) + confFile.writelines(VirtualHostEnd) + + confFile.close() + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile( + str(msg) + " [IO Error with per host config file [perHostDomainConf]]") + return 0 + return 1 - except BaseException, msg: - logging.CyberCPLogFileWriter.writeToFile( - str(msg) + " [IO Error with per host config file [perHostDomainConf]]") - return 0 - return 1 @staticmethod def createConfigInMainDomainHostFile(domain, masterDomain): @@ -963,28 +1201,40 @@ rewrite { # restrained 1 # } - try: + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + try: - if vhost.createNONSSLMapEntry(domain) == 0: - return [0, "Failed to create NON SSL Map Entry [createConfigInMainVirtualHostFile]"] + if vhost.createNONSSLMapEntry(domain) == 0: + return [0, "Failed to create NON SSL Map Entry [createConfigInMainVirtualHostFile]"] - writeDataToFile = open("/usr/local/lsws/conf/httpd_config.conf", 'a') + writeDataToFile = open("/usr/local/lsws/conf/httpd_config.conf", 'a') - writeDataToFile.writelines("\n") - writeDataToFile.writelines("virtualHost " + domain + " {\n") - writeDataToFile.writelines(" vhRoot /home/" + masterDomain + "\n") - writeDataToFile.writelines(" configFile $SERVER_ROOT/conf/vhosts/$VH_NAME/vhost.conf\n") - writeDataToFile.writelines(" allowSymbolLink 1\n") - writeDataToFile.writelines(" enableScript 1\n") - writeDataToFile.writelines(" restrained 1\n") - writeDataToFile.writelines("}\n") - writeDataToFile.writelines("\n") + writeDataToFile.writelines("\n") + writeDataToFile.writelines("virtualHost " + domain + " {\n") + writeDataToFile.writelines(" vhRoot /home/" + masterDomain + "\n") + writeDataToFile.writelines(" configFile $SERVER_ROOT/conf/vhosts/$VH_NAME/vhost.conf\n") + writeDataToFile.writelines(" allowSymbolLink 1\n") + writeDataToFile.writelines(" enableScript 1\n") + writeDataToFile.writelines(" restrained 1\n") + writeDataToFile.writelines("}\n") + writeDataToFile.writelines("\n") - writeDataToFile.close() + writeDataToFile.close() - return [1, "None"] + return [1, "None"] - except BaseException, msg: - logging.CyberCPLogFileWriter.writeToFile( - str(msg) + "223 [IO Error with main config file [createConfigInMainDomainHostFile]]") - return [0, "223 [IO Error with main config file [createConfigInMainDomainHostFile]]"] + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile( + str(msg) + "223 [IO Error with main config file [createConfigInMainDomainHostFile]]") + return [0, "223 [IO Error with main config file [createConfigInMainDomainHostFile]]"] + else: + try: + writeDataToFile = open("/usr/local/lsws/conf/httpd.conf", 'a') + configFile = 'Include /usr/local/lsws/conf/vhosts/' + domain + '/vhost.conf\n' + writeDataToFile.writelines(configFile) + writeDataToFile.close() + return [1, "None"] + except BaseException, msg: + logging.CyberCPLogFileWriter.writeToFile( + str(msg) + "223 [IO Error with main config file [createConfigInMainDomainHostFile]]") + return [0, "223 [IO Error with main config file [createConfigInMainDomainHostFile]]"] diff --git a/plogical/website.py b/plogical/website.py index eca026cf5..e35f3c6d3 100644 --- a/plogical/website.py +++ b/plogical/website.py @@ -150,7 +150,6 @@ class WebsiteManager: ## Create Configurations execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" - execPath = execPath + " createVirtualHost --virtualHostName " + domain + \ " --administratorEmail " + adminEmail + " --phpVersion '" + phpSelection + \ "' --virtualHostUser " + externalApp + " --ssl " + str(data['ssl']) + " --dkimCheck " \ diff --git a/serverStatus/litespeed/FileManager/.idea/FIleManager.iml b/serverStatus/litespeed/FileManager/.idea/FIleManager.iml new file mode 100644 index 000000000..c956989b2 --- /dev/null +++ b/serverStatus/litespeed/FileManager/.idea/FIleManager.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/serverStatus/litespeed/FileManager/.idea/modules.xml b/serverStatus/litespeed/FileManager/.idea/modules.xml new file mode 100644 index 000000000..34abd3fc4 --- /dev/null +++ b/serverStatus/litespeed/FileManager/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/serverStatus/litespeed/FileManager/.idea/workspace.xml b/serverStatus/litespeed/FileManager/.idea/workspace.xml new file mode 100644 index 000000000..026ca8720 --- /dev/null +++ b/serverStatus/litespeed/FileManager/.idea/workspace.xml @@ -0,0 +1,600 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ../../assets + ajax/libs/angularjs/1.2.12/angular.js + AbnTestController + AbnTest + listAction + $commandToExecute + + + assets + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+
+ + +
+ + + +
+ +
+
+
+

{% trans "With great wisdom comes great responsibility." %} +

+
+
+ +
+
+
+
+ + + + + +
+
- + + {% else %} +
+ +
+

{% trans "LiteSpeed Status:" %}

+

{% trans "On this page you can get information regarding your LiteSpeed processes." %}

+
+ + +
+
+
+
+
+ + {% if processList %} + +

+ {% trans "LiteSpeed Processes" %} +

+ + + + + + + + + + + {% for items in processList %} + + + + + + {% if forloop.counter == 1 %} + + + {% elif forloop.counter == 2 %} + + + {% else %} + + + {% endif %} + + {% endfor %} + + +
#{% trans "Process ID" %}{% trans "Name" %}
{{ forloop.counter }} {{ items }}{% trans "Main Process" %}{% trans "lscgid Process" %}{% trans "Worker Process" %}
+ {% else %} +
+

{% trans "Could not fetch details, either LiteSpeed is not running or some error occurred, please see CyberPanel Main log file." %}

+
+ {% endif %} + + + + + + + + +
+

{% trans "Action successful." %}

+
+ + +
+

{% trans "Error Occurred. See CyberPanel main log file." %}

+
+ + +
+

{% trans "Could not connect to server." %}

+
+ + +
+
+
+
+
+ + +
+
+

+ {% trans "License Manager" %} +

+ +
+
+ + + + + + + +
+ +
+
+
+ +
+
+

{$ lsSerial $}

+

{$ lsexpiration $}

+
+
+
+ +
+ + + +
+
+ +
+ +
+ +
+
+ + +
+ +
+ +
+
+ + +
+
+ + + + +
+
+
+
+ + +
+ {% endif %} {% endblock %} \ No newline at end of file diff --git a/serverStatus/templates/serverStatus/services.html b/serverStatus/templates/serverStatus/services.html index 54ed94e0f..dab445905 100644 --- a/serverStatus/templates/serverStatus/services.html +++ b/serverStatus/templates/serverStatus/services.html @@ -35,7 +35,7 @@
-
OpenLiteSpeed
+
{{ serverName }}
Stopped
diff --git a/serverStatus/urls.py b/serverStatus/urls.py index fa6060e27..39569e1c4 100644 --- a/serverStatus/urls.py +++ b/serverStatus/urls.py @@ -3,13 +3,17 @@ import views urlpatterns = [ url(r'^$', views.serverStatusHome, name='serverStatusHome'), - url(r'^litespeedStatus', views.litespeedStatus, name='litespeedStatus'), - url(r'^startorstopLitespeed', views.stopOrRestartLitespeed, name='startorstopLitespeed'), - url(r'^cyberCPMainLogFile', views.cyberCPMainLogFile, name='cyberCPMainLogFile'), - url(r'^getFurtherDataFromLogFile',views.getFurtherDataFromLogFile,name='getFurtherDataFromLogFile'), + url(r'^litespeedStatus$', views.litespeedStatus, name='litespeedStatus'), + url(r'^startorstopLitespeed$', views.stopOrRestartLitespeed, name='startorstopLitespeed'), + url(r'^cyberCPMainLogFile$', views.cyberCPMainLogFile, name='cyberCPMainLogFile'), + url(r'^getFurtherDataFromLogFile$',views.getFurtherDataFromLogFile,name='getFurtherDataFromLogFile'), - url(r'^servicesStatus', views.servicesStatus, name='servicesStatus'), - url(r'^servicesAction', views.servicesAction, name='servicesAction'), - url(r'^services', views.services, name='services'), + url(r'^servicesStatus$', views.servicesStatus, name='servicesStatus'), + url(r'^servicesAction$', views.servicesAction, name='servicesAction'), + url(r'^services$', views.services, name='services'), + url(r'^switchTOLSWS$', views.switchTOLSWS, name='switchTOLSWS'), + url(r'^switchTOLSWSStatus$', views.switchTOLSWSStatus, name='switchTOLSWSStatus'), + url(r'^licenseStatus$', views.licenseStatus, name='licenseStatus'), + url(r'^changeLicense$', views.changeLicense, name='changeLicense'), ] \ No newline at end of file diff --git a/serverStatus/views.py b/serverStatus/views.py index 623bd8f1f..b269fadd2 100644 --- a/serverStatus/views.py +++ b/serverStatus/views.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals from django.shortcuts import render,redirect from django.http import HttpResponse -from plogical.processUtilities import ProcessUtilities import plogical.CyberCPLogFileWriter as logging from loginSystem.views import loadLoginPage import json @@ -13,6 +12,10 @@ import shlex import socket from plogical.acl import ACLManager import os +from plogical.virtualHostUtilities import virtualHostUtilities +import time +import serverStatusUtil +from plogical.processUtilities import ProcessUtilities # Create your views here. def serverStatusHome(request): @@ -26,7 +29,6 @@ def litespeedStatus(request): try: userID = request.session['userID'] - currentACL = ACLManager.loadedACL(userID) if currentACL['admin'] == 1: @@ -36,6 +38,9 @@ def litespeedStatus(request): processList = ProcessUtilities.getLitespeedProcessNumber() + OLS = 0 + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + OLS = 1 try: versionInformation = subprocess.check_output(["/usr/local/lsws/bin/lshttpd", "-v"]).split("\n") @@ -54,16 +59,16 @@ def litespeedStatus(request): except subprocess.CalledProcessError,msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]") - return render(request,"serverStatus/litespeedStatus.html",{"processList":processList,"liteSpeedVersionStatus":"For some reaons not able to load version details, see CyberCP main log file."}) + return render(request,"serverStatus/litespeedStatus.html",{"processList":processList,"liteSpeedVersionStatus":"For some reaons not able to load version details, see CyberCP main log file.", 'OLS': OLS}) if(processList!=0): dataForHtml = {"processList": processList, "lsversion": lsversion, "modules": modules, - "loadedModules": loadedModules} + "loadedModules": loadedModules, 'OLS':OLS} return render(request,"serverStatus/litespeedStatus.html",dataForHtml) else: dataForHtml = {"lsversion": lsversion, "modules": modules, - "loadedModules": loadedModules} + "loadedModules": loadedModules, 'OLS': OLS} return render(request, "serverStatus/litespeedStatus.html",dataForHtml) except KeyError,msg: @@ -152,8 +157,14 @@ def services(request): pass else: return ACLManager.loadError() + data = {} - return render(request, 'serverStatus/services.html') + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + data['serverName'] = 'OpenLiteSpeed' + else: + data['serverName'] = 'LiteSpeed Ent' + + return render(request, 'serverStatus/services.html', data) except KeyError: return redirect(loadLoginPage) @@ -302,3 +313,134 @@ def servicesAction(request): final_dic = {'serviceAction': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) + +def switchTOLSWS(request): + try: + userID = request.session['userID'] + + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadErrorJson('status', 0) + + data = json.loads(request.body) + + execPath = "sudo /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/serverStatus/serverStatusUtil.py" + execPath = execPath + " switchTOLSWS --licenseKey " + data['licenseKey'] + + subprocess.Popen(shlex.split(execPath)) + time.sleep(2) + + data_ret = {'status': 1, 'error_message': "None", } + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + except BaseException, msg: + data_ret = {'status': 0, 'error_message': str(msg)} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + +def switchTOLSWSStatus(request): + try: + + command = 'sudo cat ' + serverStatusUtil.ServerStatusUtil.lswsInstallStatusPath + output = subprocess.check_output(shlex.split(command)) + + if output.find('[404]') > -1: + data_ret = {'abort': 1, 'requestStatus': output, 'installed': 0} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + elif output.find('[200]') > -1: + data_ret = {'abort': 1, 'requestStatus': output, 'installed': 1} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + else: + data_ret = {'abort': 0, 'requestStatus': output, 'installed': 0} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + except BaseException, msg: + data_ret = {'abort': 1, 'requestStatus': str(msg), 'installed': 0} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + +def licenseStatus(request): + try: + userID = request.session['userID'] + + try: + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadErrorJson('status', 0) + + command = 'sudo cat /usr/local/lsws/conf/serial.no' + serial = subprocess.check_output(shlex.split(command)) + + + command = 'sudo /usr/local/lsws/bin/lshttpd -V' + expiration = subprocess.check_output(shlex.split(command)) + + final_dic = {'status': 1, "erroMessage": 0, 'lsSerial': serial, 'lsexpiration': expiration} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + + except BaseException, msg: + final_dic = {'status': 0, 'erroMessage': str(msg)} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + except KeyError, msg: + final_dic = {'status': 0, 'erroMessage': str(msg)} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + +def changeLicense(request): + try: + userID = request.session['userID'] + + try: + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadErrorJson('status', 0) + + data = json.loads(request.body) + newKey = data['newKey'] + + command = 'sudo chown -R cyberpanel:cyberpanel /usr/local/lsws/conf' + subprocess.call(shlex.split(command)) + + serialPath = '/usr/local/lsws/conf/serial.no' + serialFile = open(serialPath, 'w') + serialFile.write(newKey) + serialFile.close() + + command = 'sudo chown -R lsadm:lsadm /usr/local/lsws/conf' + subprocess.call(shlex.split(command)) + + + command = 'sudo /usr/local/lsws/bin/lshttpd -r' + subprocess.call(shlex.split(command)) + + command = 'sudo /usr/local/lsws/bin/lswsctrl restart' + subprocess.call(shlex.split(command)) + + + final_dic = {'status': 1, "erroMessage": 'None'} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + + except BaseException, msg: + final_dic = {'status': 0, 'erroMessage': str(msg)} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + except KeyError, msg: + final_dic = {'status': 0, 'erroMessage': str(msg)} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) \ No newline at end of file diff --git a/static/firewall/firewall.js b/static/firewall/firewall.js index ba9df9207..bb0e4a07f 100644 --- a/static/firewall/firewall.js +++ b/static/firewall/firewall.js @@ -3,10 +3,6 @@ */ - - - - /* Java script code to ADD Firewall Rules */ app.controller('firewallController', function($scope,$http) { @@ -548,8 +544,6 @@ app.controller('firewallController', function($scope,$http) { /* Java script code to ADD Firewall Rules */ - - /* Java script code to Secure SSH */ app.controller('secureSSHCTRL', function($scope,$http) { diff --git a/static/images/litespeed-logo.png b/static/images/litespeed-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..5ac9124e5a901df940868f615e0ea6d10f5388dc GIT binary patch literal 22141 zcmc$_cT|(x*De|mB#JbZA_$==s1#9}0YXu#6cIv^-lU6Y=%FYeN`O#A5TqzQ^dcZt zDF#$P2pwsH6zPOs?+Uv2?;H1g=Z<^Fx#OHac6JQ!yVhK5&iTwa*L>ECJDSQgCs|KI zAP^c=m0NcqkYk*r|DeagFGCNH+kyX`Ln#`dbX@MEJS-mBK;*4mENwVdoh@u_?%G&b zd%3pSNJAicFx6Y~x}Jmc!&+E2`((Ziez%S_Co3}hCzR-A`8Rc1n8C)yR{FUIH*YYT zDb|u}D@lwQX-_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?d00001 diff --git a/static/serverStatus/serverStatus.js b/static/serverStatus/serverStatus.js index e52d380fe..99b324364 100644 --- a/static/serverStatus/serverStatus.js +++ b/static/serverStatus/serverStatus.js @@ -5,7 +5,7 @@ /* Java script code to start/stop litespeed */ -app.controller('litespeedStatus', function($scope,$http) { +app.controller('litespeedStatus', function ($scope, $http) { $scope.restartorStopLoading = true; $scope.actionResult = true; @@ -13,424 +13,507 @@ app.controller('litespeedStatus', function($scope,$http) { $scope.serverStatusCouldNotConnect = true; - $scope.restartLitespeed = function(){ + $scope.restartLitespeed = function () { - $scope.disableReboot = true; - $scope.disableStop = true; - $scope.restartorStopLoading = false; + $scope.disableReboot = true; + $scope.disableStop = true; + $scope.restartorStopLoading = false; + var url = "/serverstatus/startorstopLitespeed"; + + var data = { + reboot: 1, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - var url = "/serverstatus/startorstopLitespeed"; + function ListInitialDatas(response) { - var data = { - reboot:1, - }; + $scope.restartorStopLoading = true; + $scope.disableReboot = false; + $scope.disableStop = false; - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + if (response.data.reboot == 1) { - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - $scope.restartorStopLoading = true; - $scope.disableReboot = false; - $scope.disableStop = false; - - if(response.data.reboot == 1){ - - $scope.restartorStopLoading = true; - $scope.actionResult = false; - $scope.actionResultBad = true; - $scope.serverStatusCouldNotConnect = true; - - } - else{ - - $scope.restartorStopLoading = true; - $scope.actionResult = true; - $scope.actionResultBad = false; - $scope.serverStatusCouldNotConnect = true; - } - - - } - function cantLoadInitialDatas(response) { - $scope.restartorStopLoading = true; - $scope.actionResult = true; - $scope.actionResultBad = true; - $scope.serverStatusCouldNotConnect = false; - $scope.disableReboot = false; - $scope.disableStop = false; - } + $scope.restartorStopLoading = true; + $scope.actionResult = false; + $scope.actionResultBad = true; + $scope.serverStatusCouldNotConnect = true; + + } + else { + + $scope.restartorStopLoading = true; + $scope.actionResult = true; + $scope.actionResultBad = false; + $scope.serverStatusCouldNotConnect = true; + } + } + function cantLoadInitialDatas(response) { + $scope.restartorStopLoading = true; + $scope.actionResult = true; + $scope.actionResultBad = true; + $scope.serverStatusCouldNotConnect = false; + $scope.disableReboot = false; + $scope.disableStop = false; + } }; - $scope.stopLitespeed = function(){ + $scope.stopLitespeed = function () { - $scope.disableReboot = true; - $scope.disableStop = true; - $scope.restartorStopLoading = false; + $scope.disableReboot = true; + $scope.disableStop = true; + $scope.restartorStopLoading = false; + var url = "/serverstatus/startorstopLitespeed"; + + var data = { + reboot: 0, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - var url = "/serverstatus/startorstopLitespeed"; + function ListInitialDatas(response) { - var data = { - reboot:0, - }; + $scope.restartorStopLoading = true; + $scope.disableReboot = false; + $scope.disableStop = false; - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + if (response.data.shutdown == 1) { - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - $scope.restartorStopLoading = true; - $scope.disableReboot = false; - $scope.disableStop = false; - - if(response.data.shutdown == 1){ - - $scope.restartorStopLoading = true; - $scope.actionResult = false; - $scope.actionResultBad = true; - $scope.serverStatusCouldNotConnect = true; - - } - else{ - - $scope.restartorStopLoading = true; - $scope.actionResult = true; - $scope.actionResultBad = false; - $scope.serverStatusCouldNotConnect = true; - } - - - } - function cantLoadInitialDatas(response) { - $scope.restartorStopLoading = true; - $scope.actionResult = true; - $scope.actionResultBad = true; - $scope.serverStatusCouldNotConnect = false; - $scope.disableReboot = false; - $scope.disableStop = false; - } + $scope.restartorStopLoading = true; + $scope.actionResult = false; + $scope.actionResultBad = true; + $scope.serverStatusCouldNotConnect = true; + + } + else { + + $scope.restartorStopLoading = true; + $scope.actionResult = true; + $scope.actionResultBad = false; + $scope.serverStatusCouldNotConnect = true; + } + } + function cantLoadInitialDatas(response) { + $scope.restartorStopLoading = true; + $scope.actionResult = true; + $scope.actionResultBad = true; + $scope.serverStatusCouldNotConnect = false; + $scope.disableReboot = false; + $scope.disableStop = false; + } }; }); - - /* Java script code to start/stop litespeed */ - - - /* Java script code to read log file */ +app.controller('readCyberCPLogFile', function ($scope, $http) { -app.controller('readCyberCPLogFile', function($scope,$http) { + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; - $scope.logFileLoading = false; - $scope.logsFeteched = true; + + var url = "/serverstatus/getFurtherDataFromLogFile"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.logstatus == 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = false; + $scope.couldNotFetchLogs = true; + + $scope.logsData = response.data.logsdata; + + + } + else { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + } + + + $scope.fetchLogs = function () { + + + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + var url = "/serverstatus/getFurtherDataFromLogFile"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.logstatus == 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = false; $scope.couldNotFetchLogs = true; - - var url = "/serverstatus/getFurtherDataFromLogFile"; - - var data = {}; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + $scope.logsData = response.data.logsdata; - function ListInitialDatas(response) { + } + else { - - - if(response.data.logstatus == 1){ - - $scope.logFileLoading = true; - $scope.logsFeteched = false; - $scope.couldNotFetchLogs = true; - - $scope.logsData = response.data.logsdata; - - - - } - else{ - - $scope.logFileLoading = true; - $scope.logsFeteched = true; - $scope.couldNotFetchLogs = false; - - - } - - - } - function cantLoadInitialDatas(response) { - - $scope.logFileLoading = true; - $scope.logsFeteched = true; - $scope.couldNotFetchLogs = false; - - } - - - - - $scope.fetchLogs = function(){ - - - $scope.logFileLoading = false; + $scope.logFileLoading = true; $scope.logsFeteched = true; - $scope.couldNotFetchLogs = true; + $scope.couldNotFetchLogs = false; - var url = "/serverstatus/getFurtherDataFromLogFile"; - - var data = {}; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + } - function ListInitialDatas(response) { - - - - if(response.data.logstatus == 1){ - - $scope.logFileLoading = true; - $scope.logsFeteched = false; - $scope.couldNotFetchLogs = true; - - $scope.logsData = response.data.logsdata; - - - - } - else{ - - $scope.logFileLoading = true; - $scope.logsFeteched = true; - $scope.couldNotFetchLogs = false; - - - } - - - } - function cantLoadInitialDatas(response) { - - $scope.logFileLoading = true; - $scope.logsFeteched = true; - $scope.couldNotFetchLogs = false; - - } + } + function cantLoadInitialDatas(response) { + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + } }; }); - - /* Java script code to read log file ends here */ - /* Java script code to read log file ends here */ /* Services */ -app.controller('servicesManager', function($scope,$http) { +app.controller('servicesManager', function ($scope, $http) { - $scope.services = false; - $scope.btnDisable = false; - $scope.actionLoader = false; + $scope.services = false; + $scope.btnDisable = false; + $scope.actionLoader = false; - function getServiceStatus(){ - $scope.btnDisable = true; + function getServiceStatus() { + $scope.btnDisable = true; - url = "/serverstatus/servicesStatus"; + url = "/serverstatus/servicesStatus"; - $http.post(url).then(ListInitialDatas, cantLoadInitialDatas); + $http.post(url).then(ListInitialDatas, cantLoadInitialDatas); - function ListInitialDatas(response) { + function ListInitialDatas(response) { - if (response.data.status.litespeed) { - $scope.olsStatus = "Running"; - $scope.olsStats = true; - $scope.olsStart = false; - $scope.olsStop = true; - $scope.olsMem = Math.round(parseInt(response.data.memUsage.litespeed) / 1048576) + " MB"; - } - else { - $scope.olsStatus = "Stopped"; - $scope.olsStats = false; - $scope.olsStart = true; - $scope.olsStop = false; - } + if (response.data.status.litespeed) { + $scope.olsStatus = "Running"; + $scope.olsStats = true; + $scope.olsStart = false; + $scope.olsStop = true; + $scope.olsMem = Math.round(parseInt(response.data.memUsage.litespeed) / 1048576) + " MB"; + } + else { + $scope.olsStatus = "Stopped"; + $scope.olsStats = false; + $scope.olsStart = true; + $scope.olsStop = false; + } - // Update SQL stats + // Update SQL stats - if (response.data.status.mysql) { - $scope.sqlStatus = "Running"; - $scope.sqlStats = true; - $scope.sqlStart = false; - $scope.sqlStop = true; - $scope.sqlMem = Math.round(parseInt(response.data.memUsage.mysql) / 1048576) + " MB"; - } - else { - $scope.sqlStatus = "Stopped"; - $scope.sqlStats = false; - $scope.sqlStart = true; - $scope.sqlStop = false; - } + if (response.data.status.mysql) { + $scope.sqlStatus = "Running"; + $scope.sqlStats = true; + $scope.sqlStart = false; + $scope.sqlStop = true; + $scope.sqlMem = Math.round(parseInt(response.data.memUsage.mysql) / 1048576) + " MB"; + } + else { + $scope.sqlStatus = "Stopped"; + $scope.sqlStats = false; + $scope.sqlStart = true; + $scope.sqlStop = false; + } - // Update DNS stats + // Update DNS stats - if (response.data.status.powerdns) { - $scope.dnsStatus = "Running"; - $scope.dnsStats = true; - $scope.dnsStart = false; - $scope.dnsStop = true; - $scope.dnsMem = Math.round(parseInt(response.data.memUsage.powerdns) / 1048576) + " MB"; - } - else { - $scope.dnsStatus = "Stopped"; - $scope.dnsStats = false; - $scope.dnsStart = true; - $scope.dnsStop = false; - } + if (response.data.status.powerdns) { + $scope.dnsStatus = "Running"; + $scope.dnsStats = true; + $scope.dnsStart = false; + $scope.dnsStop = true; + $scope.dnsMem = Math.round(parseInt(response.data.memUsage.powerdns) / 1048576) + " MB"; + } + else { + $scope.dnsStatus = "Stopped"; + $scope.dnsStats = false; + $scope.dnsStart = true; + $scope.dnsStop = false; + } - // Update FTP stats + // Update FTP stats - if (response.data.status.pureftp) { - $scope.ftpStatus = "Running"; - $scope.ftpStats = true; - $scope.ftpStart = false; - $scope.ftpStop = true; - $scope.ftpMem = Math.round(parseInt(response.data.memUsage.pureftp) / 1048576) + " MB"; - } - else { - $scope.ftpStatus = "Stopped"; - $scope.ftpStats = false; - $scope.ftpStart = true; - $scope.ftpStop = false; - } + if (response.data.status.pureftp) { + $scope.ftpStatus = "Running"; + $scope.ftpStats = true; + $scope.ftpStart = false; + $scope.ftpStop = true; + $scope.ftpMem = Math.round(parseInt(response.data.memUsage.pureftp) / 1048576) + " MB"; + } + else { + $scope.ftpStatus = "Stopped"; + $scope.ftpStats = false; + $scope.ftpStart = true; + $scope.ftpStop = false; + } - $scope.services = true; + $scope.services = true; - $scope.btnDisable = false; + $scope.btnDisable = false; - } - function cantLoadInitialDatas(response) { - $scope.couldNotConnect = true; + } - } + function cantLoadInitialDatas(response) { + $scope.couldNotConnect = true; - }; - getServiceStatus(); + } - $scope.serviceAction = function(serviceName, action){ - $scope.ActionProgress = true; - $scope.btnDisable = true; - $scope.ActionSuccessfull = false; - $scope.ActionFailed = false; - $scope.couldNotConnect = false; - $scope.actionLoader = true; + }; + getServiceStatus(); - url = "/serverstatus/servicesAction"; + $scope.serviceAction = function (serviceName, action) { + $scope.ActionProgress = true; + $scope.btnDisable = true; + $scope.ActionSuccessfull = false; + $scope.ActionFailed = false; + $scope.couldNotConnect = false; + $scope.actionLoader = true; - var data = { - service:serviceName, - action:action - }; + url = "/serverstatus/servicesAction"; - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + var data = { + service: serviceName, + action: action + }; - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; - function ListInitialDatas(response) { - console.log(response.data); + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - if(response.data.serviceAction == 1){ - setTimeout(function() { - getServiceStatus(); - $scope.ActionSuccessfull = true; - $scope.ActionFailed = false; - $scope.couldNotConnect = false; - $scope.actionLoader = false; - $scope.btnDisable = false; - }, 3000); - } - else{ - setTimeout(function() { - getServiceStatus(); - $scope.ActionSuccessfull = false; - $scope.ActionFailed = true; - $scope.couldNotConnect = false; - $scope.actionLoader = false; - $scope.btnDisable = false; - }, 5000); + function ListInitialDatas(response) { + console.log(response.data); - } - - } - function cantLoadInitialDatas(response) { - $scope.ActionSuccessfull = false; + if (response.data.serviceAction == 1) { + setTimeout(function () { + getServiceStatus(); + $scope.ActionSuccessfull = true; $scope.ActionFailed = false; - $scope.couldNotConnect = true; + $scope.couldNotConnect = false; $scope.actionLoader = false; $scope.btnDisable = false; - } + }, 3000); + } + else { + setTimeout(function () { + getServiceStatus(); + $scope.ActionSuccessfull = false; + $scope.ActionFailed = true; + $scope.couldNotConnect = false; + $scope.actionLoader = false; + $scope.btnDisable = false; + }, 5000); - } + } + + } + + function cantLoadInitialDatas(response) { + $scope.ActionSuccessfull = false; + $scope.ActionFailed = false; + $scope.couldNotConnect = true; + $scope.actionLoader = false; + $scope.btnDisable = false; + } + + } }); + +app.controller('lswsSwitch', function ($scope, $http, $timeout, $window) { + + + $scope.cyberPanelLoading = true; + $scope.installBoxGen = true; + + $scope.switchTOLSWS = function () { + + $scope.cyberPanelLoading = false; + $scope.installBoxGen = true; + + url = "/serverstatus/switchTOLSWS"; + + var data = { + licenseKey: $scope.licenseKey + }; + + 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.cyberPanelLoading = 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; + $timeout(getRequestStatus, 1000); + } + else { + // Notifications + $scope.cyberPanelLoading = true; + $timeout.cancel(); + $scope.requestData = response.data.requestStatus; + if (response.data.installed === 1) { + $timeout(function () { + $window.location.reload(); + }, 3000); + } + + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + + } + + } + +}); \ No newline at end of file