diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..7aa1d3f5d Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index 99ec4282e..64dffcb6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ +.DS_Store +.AppleDouble +.LSOverride *.pyc .idea diff --git a/ApachController/ApacheController.py b/ApachController/ApacheController.py index f9fca1b8e..441c090aa 100755 --- a/ApachController/ApacheController.py +++ b/ApachController/ApacheController.py @@ -1,9 +1,9 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os import subprocess import shlex import plogical.CyberCPLogFileWriter as logging -from ApacheVhosts import ApacheVhost +from ApachController.ApacheVhosts import ApacheVhost class ApacheController: @@ -81,7 +81,7 @@ LoadModule mpm_event_module modules/mod_mpm_event.so return 1 else: return 0 - except BaseException, msg: + except BaseException as msg: message = "%s. [%s]" % (str(msg), '[ApacheController.checkIfApacheInstalled]') logging.CyberCPLogFileWriter.writeToFile(message) @@ -94,7 +94,7 @@ LoadModule mpm_event_module modules/mod_mpm_event.so return 0 else: return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -157,7 +157,7 @@ LoadModule mpm_event_module modules/mod_mpm_event.so return 1 - except BaseException, msg: + except BaseException as msg: return str(msg) @staticmethod @@ -302,5 +302,5 @@ LoadModule mpm_event_module modules/mod_mpm_event.so return [0,result] return [1, 'None'] - except BaseException, msg: + except BaseException as msg: return [0, str(msg)] \ No newline at end of file diff --git a/ApachController/ApacheVhosts.py b/ApachController/ApacheVhosts.py index 5775771c3..9be3ca737 100755 --- a/ApachController/ApacheVhosts.py +++ b/ApachController/ApacheVhosts.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os import os.path import sys @@ -144,7 +144,7 @@ class ApacheVhost: ProcessUtilities.normalExecutioner(command) return [1, 'None'] - except BaseException, msg: + except BaseException as msg: return [0, str(msg)] @staticmethod @@ -172,7 +172,7 @@ class ApacheVhost: confFile.close() return [1, 'None'] - except BaseException, msg: + except BaseException as msg: return [0, str(msg)] @staticmethod @@ -183,7 +183,7 @@ class ApacheVhost: confFile.write("REWRITERULE ^(.*)$ HTTP://apachebackend/$1 [P]") confFile.close() return [1, 'None'] - except BaseException, msg: + except BaseException as msg: return [0, str(msg)] @staticmethod @@ -256,7 +256,7 @@ class ApacheVhost: ProcessUtilities.normalExecutioner(command) return [1, 'None'] - except BaseException, msg: + except BaseException as msg: return [0, str(msg)] @staticmethod @@ -285,7 +285,7 @@ class ApacheVhost: command = "systemctl restart httpd" ProcessUtilities.normalExecutioner(command) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) @staticmethod @@ -300,7 +300,7 @@ class ApacheVhost: confFile.write(currentConf) confFile.close() - except BaseException, msg: + except BaseException as msg: logging.writeToFile( str(msg) + " [IO Error with per host config file [ApacheVhosts.perHostVirtualConf]]") @@ -383,6 +383,6 @@ class ApacheVhost: ProcessUtilities.normalExecutioner(command) return 1 - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) return 1 \ No newline at end of file diff --git a/ApachController/BackupUtil.py b/ApachController/BackupUtil.py index 19f76e88d..418b861e6 100644 --- a/ApachController/BackupUtil.py +++ b/ApachController/BackupUtil.py @@ -14,7 +14,7 @@ class BackupUtil: return 1 else: return 0 - except BaseException, msg: + except BaseException as msg: return 0 @staticmethod @@ -25,9 +25,9 @@ class BackupUtil: try: smtpObj = smtplib.SMTP('127.0.0.1') smtpObj.sendmail(sender, receivers, message) - print "Successfully sent email" - except BaseException, msg: - print "Error: unable to send email %s" % str(msg) + print("Successfully sent email") + except BaseException as msg: + print("Error: unable to send email %s" % str(msg)) @staticmethod def SyncHome(): diff --git a/CLManager/CLManagerMain.py b/CLManager/CLManagerMain.py index d476c7b05..2a02fd91c 100644 --- a/CLManager/CLManagerMain.py +++ b/CLManager/CLManagerMain.py @@ -9,7 +9,7 @@ import json from django.shortcuts import HttpResponse from math import ceil from websiteFunctions.models import Websites -from .models import CLPackages +from CLManager.models import CLPackages class CLManagerMain(multi.Thread): @@ -28,7 +28,7 @@ class CLManagerMain(multi.Thread): elif self.function == 'enableOrDisable': self.enableOrDisable() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [ContainerManager.run]') def renderC(self): @@ -41,24 +41,30 @@ class CLManagerMain(multi.Thread): else: return ACLManager.loadError() + ipFile = "/etc/cyberpanel/machineIP" + f = open(ipFile) + ipData = f.read() + ipAddress = ipData.split('\n', 1)[0] + data = {} data['CL'] = 0 - data['CAGEFS'] = 0 + data['activatedPath'] = 0 + data['ipAddress'] = ipAddress CLPath = '/etc/sysconfig/cloudlinux' - CageFSPath = '/usr/sbin/cagefsctl' + activatedPath = '/home/cyberpanel/cloudlinux' if os.path.exists(CLPath): data['CL'] = 1 - if os.path.exists(CageFSPath): - data['CAGEFS'] = 1 + if os.path.exists(activatedPath): + data['activatedPath'] = 1 if data['CL'] == 0: return render(self.request, 'CLManager/notAvailable.html', data) - elif data['CAGEFS'] == 0: + elif data['activatedPath'] == 0: return render(self.request, 'CLManager/notAvailable.html', data) else: - return render(self.request, self.templateName, self.data) + return render(self.request, 'CLManager/cloudLinux.html', data) def submitCageFSInstall(self): try: @@ -73,11 +79,11 @@ class CLManagerMain(multi.Thread): 1) return 0 - execPath = "/usr/local/CyberCP/bin/python2 /usr/local/CyberCP/CLManager/CageFS.py" + execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/CLManager/CageFS.py" execPath = execPath + " --function submitCageFSInstall" ProcessUtilities.outputExecutioner(execPath) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1) def findWebsitesJson(self, currentACL, userID, pageNumber): @@ -144,7 +150,7 @@ class CLManagerMain(multi.Thread): 'pagination': pagination, 'default': default} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -160,7 +166,7 @@ class CLManagerMain(multi.Thread): for items in websites: command = '/usr/sbin/cagefsctl --disable %s' % (items.externalApp) ProcessUtilities.executioner(command) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) def fetchPackages(self, currentACL): diff --git a/CLManager/CLPackages.py b/CLManager/CLPackages.py index 951acbee7..a9574feed 100755 --- a/CLManager/CLPackages.py +++ b/CLManager/CLPackages.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os import os.path import sys @@ -20,7 +20,7 @@ class CLinuxPackages: try: clPackage = CLPackages.objects.get(owner=itemPackage) statement = '%s %s' % (pwd.getpwnam(items.externalApp).pw_uid, clPackage.name) - print statement + print(statement) except: pass @@ -28,7 +28,7 @@ class CLinuxPackages: @staticmethod def listPackages(): for items in CLPackages.objects.all(): - print items.name + print(items.name) @staticmethod def userIDPackage(user): @@ -36,7 +36,7 @@ class CLinuxPackages: itemPackage = website.package try: clPackage = CLPackages.objects.get(owner=itemPackage) - print clPackage + print(clPackage) except: pass @@ -48,7 +48,7 @@ class CLinuxPackages: try: clPackage = CLPackages.objects.get(owner=itemPackage) if clPackage.name == package: - print pwd.getpwnam(items.externalApp).pw_uid + print(pwd.getpwnam(items.externalApp).pw_uid) except: pass diff --git a/CLManager/CageFS.py b/CLManager/CageFS.py index 1fb87ff24..5969219f1 100644 --- a/CLManager/CageFS.py +++ b/CLManager/CageFS.py @@ -1,9 +1,18 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import sys +import os +import django sys.path.append('/usr/local/CyberCP') + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") + +django.setup() import plogical.CyberCPLogFileWriter as logging import argparse from plogical.mailUtilities import mailUtilities +from plogical.processUtilities import ProcessUtilities +from plogical.firewallUtilities import FirewallUtilities +from firewall.models import FirewallRules from serverStatus.serverStatusUtil import ServerStatusUtil @@ -11,6 +20,39 @@ class CageFS: packages = ['talksho'] users = ['5001'] + @staticmethod + def EnableCloudLinux(): + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + confPath = '/usr/local/lsws/conf/httpd_config.conf' + data = open(confPath, 'r').readlines() + + writeToFile = open(confPath, 'w') + + for items in data: + if items.find('priority') > -1: + writeToFile.writelines(items) + writeToFile.writelines('enableLVE 2\n') + else: + writeToFile.writelines(items) + + writeToFile.close() + else: + confPath = '/usr/local/lsws/conf/httpd_config.xml' + data = open(confPath, 'r').readlines() + + writeToFile = open(confPath, 'w') + + for items in data: + if items.find('') > -1: + writeToFile.writelines(items) + writeToFile.writelines(' 2\n') + else: + writeToFile.writelines(items) + + writeToFile.close() + + ProcessUtilities.restartLitespeed() + @staticmethod def submitCageFSInstall(): try: @@ -20,24 +62,57 @@ class CageFS: statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w') logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, - "Starting Packages Installation..\n", 1) + "Checking if LVE Kernel is loaded ..\n", 1) - command = 'sudo yum install cagefs -y' + if ProcessUtilities.outputExecutioner('uname -a').find('lve') == -1: + logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, + "CloudLinux is installed but kernel is not loaded, please reboot your server to load appropriate kernel. [404]\n", 1) + return 0 + + logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, + "CloudLinux Kernel detected..\n", 1) + + logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, + "Enabling CloudLinux in web server ..\n", 1) + + CageFS.EnableCloudLinux() + + logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, + "CloudLinux enabled in server ..\n", 1) + + logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, + "Adding LVEManager port ..\n", 1) + try: + FirewallUtilities.addRule('tcp', '9000', '0.0.0.0/0') + + newFWRule = FirewallRules(name='lvemanager', proto='tcp', port='9000', ipAddress='0.0.0.0/0') + newFWRule.save() + except: + logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, + "LVEManager port added ..\n", 1) + + logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, + "Reinstalling important components ..\n", 1) + + command = 'yum install -y lvemanager' ServerStatusUtil.executioner(command, statusFile) - command = 'sudo /usr/sbin/cagefsctl --init' + command = 'yum reinstall -y lvemanager lve-utils cagefs alt-python27-cllib' ServerStatusUtil.executioner(command, statusFile) - command = 'sudo /usr/sbin/cagefsctl --update-etc' - ServerStatusUtil.executioner(command, statusFile) + logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, + "Important components reinstalled..\n", 1) - command = 'sudo /usr/sbin/cagefsctl --force-update' - ServerStatusUtil.executioner(command, statusFile) + activatedPath = '/home/cyberpanel/cloudlinux' + + writeToFile = open(activatedPath, 'a') + writeToFile.write('CLInstalled') + writeToFile.close() logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Packages successfully installed.[200]\n", 1) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1) def main(): diff --git a/CLManager/admin.py b/CLManager/admin.py index 13be29d96..4c33e0ec3 100644 --- a/CLManager/admin.py +++ b/CLManager/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/CLManager/apps.py b/CLManager/apps.py index 1f97e1e94..a627ea6f3 100644 --- a/CLManager/apps.py +++ b/CLManager/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/CLManager/models.py b/CLManager/models.py index cdbab13b0..ddb2740b5 100644 --- a/CLManager/models.py +++ b/CLManager/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models from packages.models import Package @@ -7,7 +7,7 @@ from packages.models import Package # Create your models here. class CLPackages(models.Model): - owner = models.ForeignKey(Package) + owner = models.ForeignKey(Package, on_delete=models.CASCADE) name = models.CharField(max_length=50,unique=True) speed = models.CharField(max_length=50) vmem = models.CharField(max_length=50) diff --git a/CLManager/static/CLManager/CLManager.js b/CLManager/static/CLManager/CLManager.js index 547a407d5..ae17f696c 100644 --- a/CLManager/static/CLManager/CLManager.js +++ b/CLManager/static/CLManager/CLManager.js @@ -50,7 +50,7 @@ app.controller('installCageFS', function ($scope, $http, $timeout, $window) { }; function getRequestStatus() { - $scope.cyberPanelLoading = false; + $scope.installDockerStatus = false; url = "/serverstatus/switchTOLSWSStatus"; @@ -72,7 +72,7 @@ app.controller('installCageFS', function ($scope, $http, $timeout, $window) { $timeout(getRequestStatus, 1000); } else { // Notifications - $scope.cyberPanelLoading = true; + $scope.installDockerStatus = true; $timeout.cancel(); $scope.requestData = response.data.requestStatus; if (response.data.installed === 1) { @@ -85,7 +85,7 @@ app.controller('installCageFS', function ($scope, $http, $timeout, $window) { } function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; + $scope.installDockerStatus = true; new PNotify({ title: 'Operation Failed!', text: 'Could not connect to server, please refresh this page', diff --git a/CLManager/templates/CLManager/cloudLinux.html b/CLManager/templates/CLManager/cloudLinux.html new file mode 100755 index 000000000..b1316daeb --- /dev/null +++ b/CLManager/templates/CLManager/cloudLinux.html @@ -0,0 +1,37 @@ +{% extends "baseTemplate/index.html" %} +{% load i18n %} +{% block title %}{% trans "CloudLinux - CyberPanel" %}{% endblock %} +{% block content %} + + {% load static %} + {% get_current_language as LANGUAGE_CODE %} + + + +
+
+

{% trans "CloudLinux" %}

+

{% trans "Access LVEManager" %}

+
+ +
+
+

+ {% trans "CloudLinux" %} +

+
+ +

{% trans "CloudLinux is now integrated via their new API. You can manage CageFS and Package limits directly from LVEManager by clicking below. You can use your server root credentials to access LVEManager." %}

+
+ + + + +
+
+
+ +
+{% endblock %} + diff --git a/CLManager/templates/CLManager/notAvailable.html b/CLManager/templates/CLManager/notAvailable.html index c597c3827..1c5bcbd0a 100755 --- a/CLManager/templates/CLManager/notAvailable.html +++ b/CLManager/templates/CLManager/notAvailable.html @@ -19,7 +19,7 @@
-

{% trans "CageFS is only available with CloudLinux OS. " %} {% trans "CloudLinux is not installed on your server." %} Click Here {% trans " for conversion details." %}

@@ -31,12 +31,12 @@

- {% trans "Install Packages" %}

-

{% trans "CageFS is not installed on this server. Please proceed to installation." %}

+

{% trans "CloudLinux is installed, but not activated." %}

@@ -54,7 +54,7 @@
- +
diff --git a/CLManager/tests.py b/CLManager/tests.py index 5982e6bcd..f067dcaac 100644 --- a/CLManager/tests.py +++ b/CLManager/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/CLManager/urls.py b/CLManager/urls.py index d7a531c43..d298e391a 100644 --- a/CLManager/urls.py +++ b/CLManager/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^CageFS$', views.CageFS, name='CageFS'), diff --git a/CLManager/views.py b/CLManager/views.py index e02a3a040..9c96ab45d 100644 --- a/CLManager/views.py +++ b/CLManager/views.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals from django.shortcuts import redirect, HttpResponse from loginSystem.views import loadLoginPage from plogical.acl import ACLManager -from CLManagerMain import CLManagerMain +from .CLManagerMain import CLManagerMain import json from websiteFunctions.models import Websites from plogical.processUtilities import ProcessUtilities @@ -43,7 +42,7 @@ def submitCageFSInstall(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -104,7 +103,7 @@ def enableOrDisable(request): - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -169,7 +168,7 @@ def submitCreatePackage(request): return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -213,7 +212,7 @@ def deleteCLPackage(request): return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -266,7 +265,7 @@ def saveSettings(request): return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -352,7 +351,7 @@ def getUsageData(request): final_json = json.dumps(finalData) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg), 'cpu': 0, 'memory':0} json_data = json.dumps(data_ret) return HttpResponse(json_data) \ No newline at end of file diff --git a/CLScript/CLMain.py b/CLScript/CLMain.py new file mode 100644 index 000000000..26f64fed1 --- /dev/null +++ b/CLScript/CLMain.py @@ -0,0 +1,17 @@ +import json + +class CLMain(): + def __init__(self): + self.path = '/usr/local/CyberCP/version.txt' + #versionInfo = json.loads(open(self.path, 'r').read()) + self.version = '1.9' + self.build = '3' + + ipFile = "/etc/cyberpanel/machineIP" + f = open(ipFile) + ipData = f.read() + self.ipAddress = ipData.split('\n', 1)[0] + + self.initialMeta = { + "result": "ok" + } \ No newline at end of file diff --git a/CLScript/CloudLinuxAdmins.py b/CLScript/CloudLinuxAdmins.py new file mode 100755 index 000000000..944a97f49 --- /dev/null +++ b/CLScript/CloudLinuxAdmins.py @@ -0,0 +1,70 @@ +#!/usr/local/CyberCP/bin/python +import sys +import os.path +import django + +sys.path.append('/usr/local/CyberCP') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") +try: + django.setup() +except: + pass +from loginSystem.models import Administrator, ACL +import argparse +import json +from CLScript.CLMain import CLMain + + +class CloudLinuxAdmins(CLMain): + + def __init__(self, name, isMain): + CLMain.__init__(self) + self.name = name + if isMain == 'true': + self.isMain = 1 + else: + self.isMain = 0 + + def listAll(self): + users = [] + acl = ACL.objects.get(name='admin') + for items in Administrator.objects.filter(acl=acl): + + if items.userName == 'admin': + isMain = True + else: + isMain = False + + if self.isMain: + if isMain == False: + continue + + if self.name != None: + if self.name != items.userName: + continue + + user = {'name': items.userName, + "locale_code": "EN_us", + "unix_user": None, + "email": items.email, + "is_main": isMain + } + + users.append(user) + + final = {'data': users, 'metadata': self.initialMeta} + print(json.dumps(final)) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='CyberPanel CloudLinux Manager') + parser.add_argument('-n','--name', help='Owner') + parser.add_argument('-m', '--is-main', help='Owner') + + args = vars(parser.parse_args()) + + pi = CloudLinuxAdmins(args['name'], args['is_main']) + try: + pi.listAll() + except: + pi.listAll() diff --git a/CLScript/CloudLinuxDB.py b/CLScript/CloudLinuxDB.py new file mode 100755 index 000000000..89be66945 --- /dev/null +++ b/CLScript/CloudLinuxDB.py @@ -0,0 +1,25 @@ +#!/usr/local/CyberCP/bin/python +import sys +sys.path.append('/usr/local/CyberCP') +import json +from CLScript.CLMain import CLMain + + +class PanelInfo(CLMain): + def __init__(self): + CLMain.__init__(self) + + def emit(self): + + initial = { + "mysql": None + } + + final = {'data': initial, 'metadata': self.initialMeta} + + print(json.dumps(final)) + + +if __name__ == '__main__': + pi = PanelInfo() + pi.emit() diff --git a/CLScript/CloudLinuxDomains.py b/CLScript/CloudLinuxDomains.py new file mode 100755 index 000000000..5c947af73 --- /dev/null +++ b/CLScript/CloudLinuxDomains.py @@ -0,0 +1,61 @@ +#!/usr/local/CyberCP/bin/python +import sys +import os.path +import django + +sys.path.append('/usr/local/CyberCP') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") +try: + django.setup() +except: + pass +from websiteFunctions.models import Websites +import argparse +import json +from CLScript.CLMain import CLMain + + +class CloudLinuxDomains(CLMain): + + def __init__(self, name, owner): + CLMain.__init__(self) + self.owner = owner + self.name = name + + def listAll(self): + data = {} + + if self.owner !=None: + websites = Websites.objects.filter(externalApp=self.owner) + else: + websites = Websites.objects.all() + + + for webs in websites: + if self.name != None: + if self.name != webs.domain: + continue + data[webs.domain] = {"owner": webs.externalApp, + "document_root": "/home/%s/public_html/" % (webs.domain), + "is_main": True} + for webs in webs.childdomains_set.all(): + data[webs.domain] = {"owner": webs.master.externalApp, + "document_root": webs.path, + "is_main": False} + + final = {'data': data, 'metadata': self.initialMeta} + print(json.dumps(final)) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='CyberPanel CloudLinux Manager') + parser.add_argument('-o', '--owner', help='Owner') + parser.add_argument('-n', '--name', help='Owner') + + args = parser.parse_args() + + pi = CloudLinuxDomains(args.owner, args.name) + try: + pi.listAll() + except: + pi.listAll() diff --git a/CLScript/CloudLinuxPackages.py b/CLScript/CloudLinuxPackages.py new file mode 100755 index 000000000..e1a37b231 --- /dev/null +++ b/CLScript/CloudLinuxPackages.py @@ -0,0 +1,53 @@ +#!/usr/local/CyberCP/bin/python +import sys +import os.path +import django +sys.path.append('/usr/local/CyberCP') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") +try: + django.setup() +except: + pass +from packages.models import Package +import argparse +import json +from CLScript.CLMain import CLMain +from loginSystem.models import Administrator + + +class CloudLinuxPackages(CLMain): + def __init__(self): + CLMain.__init__(self) + + def listAll(self, owner=None): + packages = [] + + if owner == None: + for items in Package.objects.all(): + try: + packages.append({'name': items.packageName, 'owner': items.admin.userName}) + except: + pass + else: + admin = Administrator.objects.get(userName=owner) + for items in Package.objects.filter(admin=admin): + try: + packages.append({'name': items.packageName, 'owner': items.admin.userName}) + except: + pass + + final = {'data': packages, 'metadata': self.initialMeta} + print(json.dumps(final)) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='CyberPanel CloudLinux Manager') + parser.add_argument('-o', '--owner', help='Owner') + + args = parser.parse_args() + + pi = CloudLinuxPackages() + try: + pi.listAll(args.owner) + except: + pi.listAll() diff --git a/CLScript/CloudLinuxResellers.py b/CLScript/CloudLinuxResellers.py new file mode 100755 index 000000000..0f93d04a6 --- /dev/null +++ b/CLScript/CloudLinuxResellers.py @@ -0,0 +1,56 @@ +#!/usr/local/CyberCP/bin/python +import sys +import os.path +import django + +sys.path.append('/usr/local/CyberCP') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") +try: + django.setup() +except: + pass +from loginSystem.models import Administrator, ACL +import argparse +import json +from CLScript.CLMain import CLMain + + +class CloudLinuxResellers(CLMain): + + def __init__(self, id, name): + CLMain.__init__(self) + self.id = id + self.name = name + + def listAll(self, owner=None): + users = [] + acl = ACL.objects.get(name='reseller') + for items in Administrator.objects.filter(acl=acl): + if self.name != None: + if self.name != items.userName: + continue + + user = {'name': items.userName, + "locale_code": "EN_us", + "email": items.email, + "id": None + } + + users.append(user) + + final = {'data': users, 'metadata': self.initialMeta} + print(json.dumps(final)) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='CyberPanel CloudLinux Manager') + parser.add_argument('--id', help='Owner') + parser.add_argument('-n', '--name', help='Owner') + + args = parser.parse_args() + + pi = CloudLinuxResellers(args.id, args.name) + try: + pi.listAll() + except: + pi.listAll() diff --git a/CLScript/CloudLinuxUsers.py b/CLScript/CloudLinuxUsers.py index ae2b4d8c6..52c3dd8c9 100755 --- a/CLScript/CloudLinuxUsers.py +++ b/CLScript/CloudLinuxUsers.py @@ -10,7 +10,6 @@ try: except: pass from websiteFunctions.models import Websites -from CLManager.CLPackages import CLPackages import argparse import pwd import json @@ -19,40 +18,141 @@ from CLScript.CLMain import CLMain class CloudLinuxUsers(CLMain): - def __init__(self): + def __init__(self, owner, username, packageName, packageOwner, fields, uid): + CLMain.__init__(self) + self.owner = owner + self.username = username + self.packageName = packageName + self.packageOwner = packageOwner + self.fields = fields + if uid!=None: + self.uid = int(uid) + else: + self.uid = uid - def listAll(self, owner=None): + if self.fields == None: + self.id = 1 + self.un = 1 + self.ow = 1 + self.domain = 1 + self.package = 1 + self.email = 1 + self.localecode = 1 + else: + if self.fields.find('id') > -1: + self.id = 1 + else: + self.id = 0 + if self.fields.find('username') > -1: + self.un = 1 + else: + self.un = 0 + + if self.fields.find('owner') > -1: + self.ow = 1 + else: + self.ow = 0 + + if self.fields.find('domain') > -1: + self.domain = 1 + else: + self.domain = 0 + + if self.fields.find('package') > -1: + self.package = 1 + else: + self.package = 0 + + if self.fields.find('email') > -1: + self.email = 1 + else: + self.email = 0 + + if self.fields.find('locale_code') > -1: + self.localecode = 1 + else: + self.localecode = 0 + + + + def fetchJson(self, websites): users = [] - - for webs in Websites.objects.all(): + for webs in websites: itemPackage = webs.package - clPackage = CLPackages.objects.get(owner=itemPackage) - package = {'name': clPackage.name, 'owner': webs.externalApp} + package = {'name': itemPackage.packageName, 'owner': webs.externalApp} - user = {'id': pwd.getpwnam(webs.externalApp).pw_uid, - 'username': webs.externalApp, - 'owner': webs.externalApp, - 'domain': webs.domain, - 'package': package, - 'email': webs.adminEmail, - "locale_code": "EN_us" - } + user = {} - users.append(user) + if self.id: + user['id'] = pwd.getpwnam(webs.externalApp).pw_uid + + if self.un: + user['username'] = webs.externalApp + + if self.ow: + user['owner'] = webs.externalApp + + if self.domain: + user['domain'] = webs.domain + + if self.package: + user['package'] = package + + if self.email: + user['email'] = webs.adminEmail + + if self.localecode: + user['locale_code'] = "EN_us" + + + if self.packageName != None: + if self.package: + if self.packageName == user['package']['name'] and self.packageOwner == user['package']['owner']: + pass + else: + continue + + if self.uid !=None: + if self.id: + if self.uid == user['id']: + users.append(user) + else: + users.append(user) + else: + users.append(user) final = {'data': users, 'metadata': self.initialMeta} print(json.dumps(final)) + def listAll(self): + + if self.owner == None: + websites = Websites.objects.all() + else: + websites = Websites.objects.filter(externalApp=self.owner) + + if self.username != None: + websites = websites.filter(externalApp=self.username) + + self.fetchJson(websites) + + +def main(): + parser = argparse.ArgumentParser(description='CyberPanel CloudLinux Manager') + parser.add_argument('-o', '--owner', help='Owner') + parser.add_argument('--fields', help='Fields to output!') + parser.add_argument('--username', help='Fields to output!') + parser.add_argument('--package-name', help='Fields to output!') + parser.add_argument('--package-owner', help='Fields to output!') + parser.add_argument('--unix-id', help='Fields to output!') + + args = vars(parser.parse_args()) + + pi = CloudLinuxUsers(args['owner'], args['username'], args['package_name'], args['package_owner'], args['fields'], args['unix_id']) + pi.listAll() + + if __name__ == '__main__': - parser = argparse.ArgumentParser(description='CyberPanel CloudLinux Manager') - parser.add_argument('--owner', help='Owner') - - args = parser.parse_args() - - pi = CloudLinuxUsers() - try: - pi.listAll(args.owner) - except: - pi.listAll() + main() diff --git a/CLScript/UserInfo.py b/CLScript/UserInfo.py new file mode 100755 index 000000000..472b614f3 --- /dev/null +++ b/CLScript/UserInfo.py @@ -0,0 +1,22 @@ +#!/usr/local/CyberCP/bin/python +import getpass + +def main(): + if getpass.getuser() == 'root': + userType = "admin" + else: + userType = "user" + + data = """{ + "userName": "%s", + "userType": "%s", + "lang": "en", + "assetsUri": "/usr/local/lvemanager", + "baseUri": "/usr/local/lvemanager", + "defaultDomain": "cyberpanel.net" +}""" % (getpass.getuser(), userType) + + print(data) + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/CLScript/__init__.py b/CLScript/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/CLScript/panel_info.py b/CLScript/panel_info.py new file mode 100755 index 000000000..7d4ab2b40 --- /dev/null +++ b/CLScript/panel_info.py @@ -0,0 +1,27 @@ +#!/usr/local/CyberCP/bin/python +import sys +sys.path.append('/usr/local/CyberCP') +import json +from CLScript.CLMain import CLMain + + +class PanelInfo(CLMain): + def __init__(self): + CLMain.__init__(self) + + def emit(self): + + initial = { + "name": "CyberPanel", + "version": "%s.%s" % (self.version, self.build), + "user_login_url": "https://%s:8090/" % (self.ipAddress) + } + + final = {'data': initial, 'metadata': self.initialMeta} + + print(json.dumps(final)) + + +if __name__ == '__main__': + pi = PanelInfo() + pi.emit() diff --git a/CyberCP/secMiddleware.py b/CyberCP/secMiddleware.py index 986e1780a..901a08147 100755 --- a/CyberCP/secMiddleware.py +++ b/CyberCP/secMiddleware.py @@ -49,7 +49,7 @@ class secMiddleware: try: #logging.writeToFile(request.body) data = json.loads(request.body) - for key, value in data.iteritems(): + for key, value in data.items(): if request.path.find('gitNotify') > -1: break @@ -60,7 +60,7 @@ class secMiddleware: # final_json = json.dumps(final_dic) # return HttpResponse(final_json) - if type(value) == str or type(value) == unicode: + if type(value) == str or type(value) == bytes: pass else: continue @@ -94,7 +94,7 @@ class secMiddleware: final_dic = {'error_message': "Data supplied is not accepted.", "errorMessage": "Data supplied is not accepted following characters are not allowed in the input ` $ & ( ) [ ] { } ; : ‘ < >."} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) response = self.get_response(request) return response diff --git a/CyberCP/settings.py b/CyberCP/settings.py index ec4164ad1..ef656129d 100755 --- a/CyberCP/settings.py +++ b/CyberCP/settings.py @@ -190,4 +190,5 @@ LANGUAGES = ( ) MEDIA_URL = '/home/cyberpanel/media/' -MEDIA_ROOT = MEDIA_URL \ No newline at end of file +MEDIA_ROOT = MEDIA_URL +DATA_UPLOAD_MAX_MEMORY_SIZE = 52428800 \ No newline at end of file diff --git a/IncBackups/IncBackups.py b/IncBackups/IncBackups.py index 792a8fd6e..d3cfb1afb 100644 --- a/IncBackups/IncBackups.py +++ b/IncBackups/IncBackups.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os,sys sys.path.append('/usr/local/CyberCP') import django @@ -155,7 +155,7 @@ class IncJobs(multi.Thread): metaFileXML.append(dnsRecordsXML) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, '%s. [158:prepMeta]' % (str(msg)), 1) ## Email accounts XML @@ -176,7 +176,7 @@ class IncJobs(multi.Thread): emailRecordsXML.append(emailRecordXML) metaFileXML.append(emailRecordsXML) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(self.statusPath, '%s. [warning:179:prepMeta]' % (str(msg)), 1) ## Email meta generated! @@ -196,7 +196,7 @@ class IncJobs(multi.Thread): metaFile = open(metaPath, 'w') metaFile.write(xmlpretty) metaFile.close() - os.chmod(metaPath, 0640) + os.chmod(metaPath, 0o640) ## meta generated @@ -211,7 +211,7 @@ class IncJobs(multi.Thread): return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, "%s [207][5009]" % (str(msg)), 1) return 0 @@ -239,7 +239,7 @@ class IncJobs(multi.Thread): logging.statusWriter(self.statusPath, 'Data for %s backed to %s.' % (self.website.domain, self.backupDestinations), 1) return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath,'%s. [IncJobs.backupData.223][5009]' % str(msg), 1) return 0 @@ -271,7 +271,7 @@ class IncJobs(multi.Thread): destination=self.backupDestinations) newSnapshot.save() return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath,'%s. [IncJobs.backupDatabases.269][5009]' % str(msg), 1) return 0 @@ -304,7 +304,7 @@ class IncJobs(multi.Thread): logging.statusWriter(self.statusPath, 'Emails for %s backed to %s.' % (self.website.domain, self.backupDestinations), 1) return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath,'%s. [IncJobs.backupDatabases.269][5009]' % str(msg), 1) return 0 @@ -323,7 +323,7 @@ class IncJobs(multi.Thread): logging.statusWriter(self.statusPath, 'Repo %s initiated for %s.' % (self.backupDestinations, self.website.domain), 1) return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath,'%s. [IncJobs.initiateRepo.47][5009]' % str(msg), 1) return 0 diff --git a/IncBackups/IncBackupsControl.py b/IncBackups/IncBackupsControl.py index 16cea7e08..f5204fb68 100644 --- a/IncBackups/IncBackupsControl.py +++ b/IncBackups/IncBackupsControl.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os import os.path import sys @@ -115,7 +115,7 @@ class IncJobs(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) #### @@ -137,7 +137,7 @@ class IncJobs(multi.Thread): snapShotid = result.split(' ')[-2] if bType == 'database': newSnapshot = JobSnapshots(job=self.jobid, - type='%s:%s' % (bType, backupPath.split('/')[-1].strip('.sql')), + type='%s:%s' % (bType, backupPath.split('/')[-1].rstrip('.sql')), snapshotid=snapShotid, destination=self.backupDestinations) else: @@ -163,7 +163,7 @@ class IncJobs(multi.Thread): logging.statusWriter(self.statusPath, result, 1) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, "%s [88][5009]" % (str(msg)), 1) return 0 @@ -177,7 +177,7 @@ class IncJobs(multi.Thread): if type == 'database': newSnapshot = JobSnapshots(job=self.jobid, - type='%s:%s' % (type, backupPath.split('/')[-1].strip('.sql')), + type='%s:%s' % (type, backupPath.split('/')[-1].rstrip('.sql')), snapshotid=snapShotid, destination=self.backupDestinations) else: @@ -202,7 +202,7 @@ class IncJobs(multi.Thread): if type == 'database': newSnapshot = JobSnapshots(job=self.jobid, - type='%s:%s' % (type, backupPath.split('/')[-1].strip('.sql')), + type='%s:%s' % (type, backupPath.split('/')[-1].rstrip('.sql')), snapshotid=snapShotid, destination=self.backupDestinations) else: @@ -240,7 +240,7 @@ class IncJobs(multi.Thread): else: self.awsFunction('restore', '', self.jobid.snapshotid) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, "%s [138][5009]" % (str(msg)), 1) return 0 @@ -267,17 +267,17 @@ class IncJobs(multi.Thread): if mysqlUtilities.mysqlUtilities.restoreDatabaseBackup(self.jobid.type.split(':')[1].rstrip('.sql'), '/home/cyberpanel', 'dummy', 'dummy') == 0: - raise BaseException + raise BaseException('Can not restore database backup.') try: if self.reconstruct == 'remote': os.remove('/home/cyberpanel/%s' % (self.path.split('/')[-1])) else: os.remove('/home/cyberpanel/%s.sql' % (self.jobid.type.split(':')[1])) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, "%s [160][5009]" % (str(msg)), 1) return 0 @@ -297,7 +297,7 @@ class IncJobs(multi.Thread): else: self.awsFunction('restore', '', self.jobid.snapshotid) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, "%s [46][5009]" % (str(msg)), 1) return 0 @@ -318,7 +318,7 @@ class IncJobs(multi.Thread): self.awsFunction('restore', '', self.jobid.snapshotid) metaPathNew = '/home/%s/meta.xml' % (self.website) - execPath = "nice -n 10 /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/IncBackups/restoreMeta.py" + execPath = "nice -n 10 /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/restoreMeta.py" execPath = execPath + " submitRestore --metaPath %s --statusFile %s" % (metaPathNew, self.statusPath) result = ProcessUtilities.outputExecutioner(execPath) logging.statusWriter(self.statusPath, result, 1) @@ -328,7 +328,7 @@ class IncJobs(multi.Thread): except: pass - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, "%s [46][5009]" % (str(msg)), 1) return 0 @@ -400,7 +400,7 @@ class IncJobs(multi.Thread): logging.statusWriter(self.statusPath, message, 1) logging.statusWriter(self.statusPath, 'Completed', 1) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.extraArgs['tempPath'], str(msg), 1) ### Backup functions @@ -520,7 +520,7 @@ class IncJobs(multi.Thread): metaFileXML.append(dnsRecordsXML) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, '%s. [158:prepMeta]' % (str(msg)), 1) ## Email accounts XML @@ -541,7 +541,7 @@ class IncJobs(multi.Thread): emailRecordsXML.append(emailRecordXML) metaFileXML.append(emailRecordsXML) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, '%s. [warning:179:prepMeta]' % (str(msg)), 1) ## Email meta generated! @@ -559,9 +559,9 @@ class IncJobs(multi.Thread): xmlpretty = prettify(metaFileXML).encode('ascii', 'ignore') metaFile = open(metaPath, 'w') - metaFile.write(xmlpretty) + metaFile.write(xmlpretty.decode('utf-8')) metaFile.close() - os.chmod(metaPath, 0640) + os.chmod(metaPath, 0o640) ## meta generated @@ -573,7 +573,7 @@ class IncJobs(multi.Thread): return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, "%s [207][5009]" % (str(msg)), 1) return 0 @@ -592,7 +592,7 @@ class IncJobs(multi.Thread): logging.statusWriter(self.statusPath, 'Data for %s backed to %s.' % (self.website.domain, self.backupDestinations), 1) return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, '%s. [IncJobs.backupData.223][5009]' % str(msg), 1) return 0 @@ -617,11 +617,11 @@ class IncJobs(multi.Thread): try: os.remove('/home/cyberpanel/%s.sql' % (items.dbName)) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, 'Failed to delete database: %s. [IncJobs.backupDatabases.456]' % str(msg), 1) return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, '%s. [IncJobs.backupDatabases.269][5009]' % str(msg), 1) return 0 @@ -641,7 +641,7 @@ class IncJobs(multi.Thread): logging.statusWriter(self.statusPath, 'Emails for %s backed to %s.' % (self.website.domain, self.backupDestinations), 1) return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, '%s. [IncJobs.emailBackup.269][5009]' % str(msg), 1) return 0 @@ -661,7 +661,7 @@ class IncJobs(multi.Thread): logging.statusWriter(self.statusPath, 'Meta for %s backed to %s.' % (self.website.domain, self.backupDestinations), 1) return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, '%s. [IncJobs.metaBackup.269][5009]' % str(msg), 1) return 0 @@ -691,7 +691,7 @@ class IncJobs(multi.Thread): logging.statusWriter(self.statusPath, 'Repo %s initiated for %s.' % (self.backupDestinations, self.website.domain), 1) return 1 - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, '%s. [IncJobs.initiateRepo.47][5009]' % str(msg), 1) return 0 @@ -763,7 +763,7 @@ Subject: %s try: command = 'rm -f %s' % (metaPathNew) ProcessUtilities.executioner(command) - except BaseException, msg: + except BaseException as msg: logging.statusWriter(self.statusPath, 'Failed to delete meta file: %s. [IncJobs.createBackup.591]' % str(msg), 1) diff --git a/IncBackups/admin.py b/IncBackups/admin.py index 13be29d96..4c33e0ec3 100644 --- a/IncBackups/admin.py +++ b/IncBackups/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/IncBackups/apps.py b/IncBackups/apps.py index 5511373f4..9605447c5 100644 --- a/IncBackups/apps.py +++ b/IncBackups/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/IncBackups/models.py b/IncBackups/models.py index 174db674e..f75aafaaf 100644 --- a/IncBackups/models.py +++ b/IncBackups/models.py @@ -1,15 +1,15 @@ -from __future__ import unicode_literals + from django.db import models from websiteFunctions.models import Websites from datetime import datetime class IncJob(models.Model): - website = models.ForeignKey(Websites) + website = models.ForeignKey(Websites, on_delete=models.CASCADE) date = models.DateTimeField(default=datetime.now, blank=True) class JobSnapshots(models.Model): - job = models.ForeignKey(IncJob) + job = models.ForeignKey(IncJob, on_delete=models.CASCADE) type = models.CharField(max_length=300) snapshotid = models.CharField(max_length=50) destination = models.CharField(max_length=200, default='') @@ -24,7 +24,7 @@ class BackupJob(models.Model): class JobSites(models.Model): - job = models.ForeignKey(BackupJob) + job = models.ForeignKey(BackupJob, on_delete=models.CASCADE) website = models.CharField(max_length=300) diff --git a/IncBackups/tests.py b/IncBackups/tests.py index 5982e6bcd..f067dcaac 100644 --- a/IncBackups/tests.py +++ b/IncBackups/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/IncBackups/urls.py b/IncBackups/urls.py index fcf10fce5..aa0864b46 100644 --- a/IncBackups/urls.py +++ b/IncBackups/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^createBackup$', views.createBackup, name='createBackupInc'), diff --git a/IncBackups/views.py b/IncBackups/views.py index b6a42569d..fc2aea9f8 100644 --- a/IncBackups/views.py +++ b/IncBackups/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render from plogical.acl import ACLManager @@ -48,7 +48,7 @@ def createBackup(request): destinations.append('s3:s3.amazonaws.com/%s' % (items)) return defRenderer(request, 'IncBackups/createBackup.html', {'websiteList': websitesName, 'destinations': destinations}) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) return redirect(loadLoginPage) @@ -61,7 +61,7 @@ def backupDestinations(request): return ACLManager.loadError() return defRenderer(request, 'IncBackups/incrementalDestinations.html', {}) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) return redirect(loadLoginPage) @@ -99,7 +99,7 @@ def addDestination(request): pass - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" execPath = execPath + " submitDestinationCreation --ipAddress " + ipAddress + " --password " \ + password + " --port " + port @@ -168,7 +168,7 @@ def addDestination(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -235,7 +235,7 @@ def populateCurrentRecords(request): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -264,7 +264,7 @@ def removeDestination(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'destStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -337,7 +337,7 @@ def fetchCurrentBackups(request): return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -398,7 +398,7 @@ def submitBackupCreation(request): final_json = json.dumps({'status': 1, 'error_message': "None", 'tempPath': tempPath}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) final_dic = {'status': 0, 'metaStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) @@ -456,7 +456,7 @@ def getBackupStatus(request): final_json = json.dumps({'backupStatus': 1, 'error_message': "None", "status": 1, "abort": 0}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'backupStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) logging.writeToFile(str(msg) + " [backupStatus]") @@ -483,7 +483,7 @@ def deleteBackup(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'destStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -528,7 +528,7 @@ def fetchRestorePoints(request): json_data = json_data + ']' final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -576,7 +576,7 @@ def restorePoint(request): final_json = json.dumps({'status': 1, 'error_message': "None", 'tempPath': tempPath}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) final_dic = {'status': 0, 'metaStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) @@ -607,7 +607,7 @@ def scheduleBackups(request): destinations.append('s3:s3.amazonaws.com/%s' % (items)) return defRenderer(request, 'IncBackups/backupSchedule.html', {'websiteList': websitesName, 'destinations': destinations}) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) return redirect(loadLoginPage) @@ -657,7 +657,7 @@ def submitBackupSchedule(request): return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_json = json.dumps({'status': 0, 'error_message': str(msg)}) return HttpResponse(final_json) @@ -690,7 +690,7 @@ def getCurrentBackupSchedules(request): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -713,7 +713,7 @@ def scheduleDelete(request): final_json = json.dumps({'status': 1, 'error_message': "None"}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_json = json.dumps({'status': 0, 'error_message': str(msg)}) return HttpResponse(final_json) @@ -741,6 +741,6 @@ def restoreRemoteBackups(request): destinations.append('s3:s3.amazonaws.com/%s' % (items)) return defRenderer(request, 'IncBackups/restoreRemoteBackups.html', {'websiteList': websitesName, 'destinations': destinations}) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) return redirect(loadLoginPage) \ No newline at end of file diff --git a/WebTerminal/CPWebSocket.py b/WebTerminal/CPWebSocket.py index b378f959e..64a7b59cb 100644 --- a/WebTerminal/CPWebSocket.py +++ b/WebTerminal/CPWebSocket.py @@ -82,14 +82,14 @@ class SSHServer(multi.Thread): time.sleep(0.01) else: return 0 - except BaseException, msg: + except BaseException as msg: time.sleep(0.1) def run(self): try: self.recvData() - except BaseException, msg: - print(str(msg)) + except BaseException as msg: + print((str(msg))) class WebTerminalServer(WebSocket): diff --git a/WebTerminal/admin.py b/WebTerminal/admin.py index 13be29d96..4c33e0ec3 100644 --- a/WebTerminal/admin.py +++ b/WebTerminal/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/WebTerminal/apps.py b/WebTerminal/apps.py index b53c3b4c6..724dc1517 100644 --- a/WebTerminal/apps.py +++ b/WebTerminal/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/WebTerminal/cpssh.service b/WebTerminal/cpssh.service index d3e3a064b..efed1e56d 100644 --- a/WebTerminal/cpssh.service +++ b/WebTerminal/cpssh.service @@ -3,9 +3,9 @@ Description = CyberPanel SSH Websocket Daemon [Service] Type=forking -ExecStart = /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/WebTerminal/servCTRL.py start -ExecStop = /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/WebTerminal/servCTRL.py stop -Restart = /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/WebTerminal/servCTRL.py restart +ExecStart = /usr/local/CyberCP/bin/python /usr/local/CyberCP/WebTerminal/servCTRL.py start +ExecStop = /usr/local/CyberCP/bin/python /usr/local/CyberCP/WebTerminal/servCTRL.py stop +Restart = /usr/local/CyberCP/bin/python /usr/local/CyberCP/WebTerminal/servCTRL.py restart Restart=on-abnormal [Install] diff --git a/WebTerminal/models.py b/WebTerminal/models.py index 1dfab7604..4e6a8e76d 100644 --- a/WebTerminal/models.py +++ b/WebTerminal/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/WebTerminal/servCTRL.py b/WebTerminal/servCTRL.py index 66cf9ad56..9ab6056ab 100644 --- a/WebTerminal/servCTRL.py +++ b/WebTerminal/servCTRL.py @@ -20,7 +20,7 @@ class servCTRL: if os.path.exists(servCTRL.pidfile): self.stop() - command = '/usr/local/CyberCP/bin/python2 /usr/local/CyberCP/WebTerminal/CPWebSocket.py' + command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/WebTerminal/CPWebSocket.py' subprocess.Popen(shlex.split(command)) def stop(self): diff --git a/WebTerminal/tests.py b/WebTerminal/tests.py index 5982e6bcd..f067dcaac 100644 --- a/WebTerminal/tests.py +++ b/WebTerminal/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/WebTerminal/urls.py b/WebTerminal/urls.py index a959df39a..73b52d1e5 100755 --- a/WebTerminal/urls.py +++ b/WebTerminal/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^$', views.terminal, name='terminal'), diff --git a/WebTerminal/views.py b/WebTerminal/views.py index a4bab712c..145cfc3bf 100644 --- a/WebTerminal/views.py +++ b/WebTerminal/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render, redirect, HttpResponse from plogical.acl import ACLManager @@ -49,7 +49,7 @@ def terminal(request): newFWRule.save() return render(request, 'WebTerminal/WebTerminal.html', {'verifyPath': verifyPath, 'password': password}) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) return redirect(loadLoginPage) @@ -73,7 +73,7 @@ def restart(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) \ No newline at end of file diff --git a/api/admin.py b/api/admin.py index 13be29d96..4c33e0ec3 100755 --- a/api/admin.py +++ b/api/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/api/apps.py b/api/apps.py index 8f01aa8da..2ab9fa9e6 100755 --- a/api/apps.py +++ b/api/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/api/models.py b/api/models.py index 1dfab7604..4e6a8e76d 100755 --- a/api/models.py +++ b/api/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/api/tests.py b/api/tests.py index e1391c2a6..a3d7b14d4 100755 --- a/api/tests.py +++ b/api/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase import json diff --git a/api/urls.py b/api/urls.py index 89923e4fc..8caf9cb92 100755 --- a/api/urls.py +++ b/api/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^createWebsite', views.createWebsite, name='createWebsiteAPI'), diff --git a/api/views.py b/api/views.py index 070e34f47..e80fa5927 100755 --- a/api/views.py +++ b/api/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + import json from django.shortcuts import redirect from django.http import HttpResponse @@ -46,7 +46,7 @@ def verifyConn(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'verifyConn': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -107,7 +107,7 @@ def getUserInfo(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -150,7 +150,7 @@ def changeUserPassAPI(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'changeStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -195,7 +195,7 @@ def changePackageAPI(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'changePackage': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -240,7 +240,7 @@ def deleteWebsite(request): wm = WebsiteManager() return wm.submitWebsiteDeletion(admin.pk, data) - except BaseException, msg: + except BaseException as msg: data_ret = {'websiteDeleteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -271,7 +271,7 @@ def submitWebsiteStatus(request): wm = WebsiteManager() return wm.submitWebsiteStatus(admin.pk, json.loads(request.body)) - except BaseException, msg: + except BaseException as msg: data_ret = {'websiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -295,7 +295,7 @@ def loginAPI(request): else: return HttpResponse("Invalid Credentials.") - except BaseException, msg: + except BaseException as msg: data = {'userID': 0, 'loginStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) @@ -338,7 +338,7 @@ def fetchSSHkey(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data = {'status' : 0, 'pubKeyStatus': 0,'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) @@ -378,7 +378,7 @@ def remoteTransfer(request): ## Accounts to transfer is a path to file, containing accounts. - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/remoteTransferUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/remoteTransferUtilities.py" execPath = execPath + " remoteTransfer --ipAddress " + ipAddress + " --dir " + dir + " --accountsToTransfer " + path ProcessUtilities.popenExecutioner(execPath) @@ -390,7 +390,7 @@ def remoteTransfer(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data = {'transferStatus': 0,'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) @@ -440,7 +440,7 @@ def fetchAccountsFromRemoteServer(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data = {'fetchStatus': 0,'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) @@ -481,7 +481,7 @@ def FetchRemoteTransferStatus(request): - except BaseException, msg: + except BaseException as msg: data = {'fetchStatus': 0,'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) @@ -528,7 +528,7 @@ def cancelRemoteTransfer(request): return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data = {'cancelStatus': 1, 'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) @@ -572,7 +572,7 @@ def cyberPanelVersion(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = { "getVersion": 0, 'error_message': str(msg) @@ -590,7 +590,7 @@ def runAWSBackups(request): if os.path.exists(randomFile): s3 = S3Backups(request, None, 'runAWSBackups') s3.start() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [API.runAWSBackups]') @@ -620,7 +620,7 @@ def submitUserCreation(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'changeStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) \ No newline at end of file diff --git a/backup/admin.py b/backup/admin.py index 1a5033b50..db8eb8864 100755 --- a/backup/admin.py +++ b/backup/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin from .models import DBUsers diff --git a/backup/apps.py b/backup/apps.py index 2b26d2144..5ec5a728d 100755 --- a/backup/apps.py +++ b/backup/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/backup/backupManager.py b/backup/backupManager.py index 43642f046..161a645ad 100755 --- a/backup/backupManager.py +++ b/backup/backupManager.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os import os.path import sys @@ -33,7 +33,7 @@ class BackupManager: try: currentACL = ACLManager.loadedACL(userID) return render(request, 'backup/index.html', currentACL) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def backupSite(self, request = None, userID = None, data = None): @@ -45,7 +45,7 @@ class BackupManager: websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'backup/backup.html', {'websiteList': websitesName}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def restoreSite(self, request = None, userID = None, data = None): @@ -73,7 +73,7 @@ class BackupManager: return render(request, 'backup/restore.html', {'backups': all_files}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def getCurrentBackups(self, userID = None, data = None): @@ -120,7 +120,7 @@ class BackupManager: json_data = json_data + ']' final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -157,7 +157,7 @@ class BackupManager: final_json = json.dumps({'status': 1, 'metaStatus': 1, 'error_message': "None", 'tempStorage': tempStoragePath}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) final_dic = {'status': 0, 'metaStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) @@ -240,7 +240,7 @@ class BackupManager: final_json = json.dumps({'backupStatus': 0, 'error_message': "None", "status": 0, "abort": 0}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'backupStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupStatus]") @@ -252,20 +252,20 @@ class BackupManager: backupCancellationDomain = data['backupCancellationDomain'] fileName = data['fileName'] - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" execPath = execPath + " cancelBackupCreation --backupCancellationDomain " + backupCancellationDomain + " --fileName " + fileName subprocess.call(shlex.split(execPath)) try: backupOb = Backups.objects.get(fileName=fileName) backupOb.delete() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [cancelBackupCreation]") final_json = json.dumps({'abortStatus': 1, 'error_message': "None", "status": 0}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'abortStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -291,7 +291,7 @@ class BackupManager: final_json = json.dumps({'status': 1, 'deleteStatus': 1, 'error_message': "None"}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'deleteStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) @@ -313,7 +313,7 @@ class BackupManager: else: return ACLManager.loadErrorJson() - execPath = "sudo nice -n 10 /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" + execPath = "sudo nice -n 10 /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" execPath = execPath + " submitRestore --backupFile " + backupFile + " --dir " + dir ProcessUtilities.popenExecutioner(execPath) time.sleep(4) @@ -321,7 +321,7 @@ class BackupManager: final_dic = {'restoreStatus': 1, 'error_message': "None"} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'restoreStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -368,7 +368,7 @@ class BackupManager: 'running': 'Running..'}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) status = "Just Started" final_json = json.dumps( @@ -381,7 +381,7 @@ class BackupManager: 'abort': 1}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'restoreStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -395,7 +395,7 @@ class BackupManager: return render(request, 'backup/backupDestinations.html', {}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def submitDestinationCreation(self, userID = None, data = None): @@ -427,7 +427,7 @@ class BackupManager: except: port = "22" - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" execPath = execPath + " submitDestinationCreation --ipAddress " + ipAddress + " --password " \ + password + " --port " + port @@ -457,7 +457,7 @@ class BackupManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'destStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -492,7 +492,7 @@ class BackupManager: final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -506,7 +506,7 @@ class BackupManager: ipAddress = data['IPAddress'] - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" execPath = execPath + " getConnectionStatus --ipAddress " + ipAddress output = ProcessUtilities.executioner(execPath) @@ -520,7 +520,7 @@ class BackupManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'connStatus': 1, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -573,7 +573,7 @@ class BackupManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'delStatus': 1, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -600,7 +600,7 @@ class BackupManager: return render(request, 'backup/backupSchedule.html', {'destinations': destinations}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def getCurrentBackupSchedules(self, userID = None, data = None): @@ -631,7 +631,7 @@ class BackupManager: final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -658,13 +658,13 @@ class BackupManager: return HttpResponse(final_json) else: if backupDest == "Home" and backupFreq == "Daily": - cronJob = "0 3 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/backupScheduleLocal.py" + cronJob = "0 3 * * * root /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/backupScheduleLocal.py" elif backupDest == "Home" and backupFreq == "Weekly": - cronJob = "0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/backupScheduleLocal.py " + cronJob = "0 0 * * 0 root /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/backupScheduleLocal.py " elif backupDest != "Home" and backupFreq == "Daily": - cronJob = "0 3 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/backupSchedule.py" + cronJob = "0 3 * * * root /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/backupSchedule.py" elif backupDest != "Home" and backupFreq == "Weekly": - cronJob = "0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/backupSchedule.py " + cronJob = "0 0 * * 0 root /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/backupSchedule.py " command = "cat " + path output = ProcessUtilities.outputExecutioner(command) @@ -700,13 +700,13 @@ class BackupManager: return HttpResponse(final_json) except: if backupDest == "Home" and backupFreq == "Daily": - cronJob = "0 3 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/backupScheduleLocal.py" + cronJob = "0 3 * * * root /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/backupScheduleLocal.py" elif backupDest == "Home" and backupFreq == "Weekly": - cronJob = "0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/backupScheduleLocal.py " + cronJob = "0 0 * * 0 root /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/backupScheduleLocal.py " elif backupDest != "Home" and backupFreq == "Daily": - cronJob = "0 3 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/backupSchedule.py" + cronJob = "0 3 * * * root /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/backupSchedule.py" elif backupDest != "Home" and backupFreq == "Weekly": - cronJob = "0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/backupSchedule.py " + cronJob = "0 0 * * 0 root /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/backupSchedule.py " command = "cat " + path output = ProcessUtilities.outputExecutioner(command) @@ -741,7 +741,7 @@ class BackupManager: final_json = json.dumps({'scheduleStatus': 1, 'error_message': "None"}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_json = json.dumps({'scheduleStatus': 0, 'error_message': str(msg)}) return HttpResponse(final_json) @@ -802,7 +802,7 @@ class BackupManager: final_json = json.dumps({'delStatus': 1, 'error_message': "None"}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_json = json.dumps({'delStatus': 0, 'error_message': str(msg)}) return HttpResponse(final_json) @@ -815,7 +815,7 @@ class BackupManager: return render(request, 'backup/remoteBackups.html') - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def submitRemoteBackups(self, userID = None, data = None): @@ -858,7 +858,7 @@ class BackupManager: return HttpResponse(data_ret) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': "Not able to fetch version of remote server. Error Message: " + str( msg), @@ -897,7 +897,7 @@ class BackupManager: ## - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/remoteTransferUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/remoteTransferUtilities.py" execPath = execPath + " writeAuthKey --pathToKey " + pathToKey output = ProcessUtilities.outputExecutioner(execPath) @@ -930,14 +930,14 @@ class BackupManager: data['error_message'], "dir": "Null"} data_ret = json.dumps(data_ret) return HttpResponse(data_ret) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': "Not able to fetch accounts from remote server. Error Message: " + str( msg), "dir": "Null"} data_ret = json.dumps(data_ret) return HttpResponse(data_ret) - except BaseException, msg: + except BaseException as msg: final_json = json.dumps({'status': 0, 'error_message': str(msg)}) return HttpResponse(final_json) @@ -995,13 +995,13 @@ class BackupManager: data['error_message']}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_json = json.dumps({'remoteTransferStatus': 0, 'error_message': "Can not initiate remote transfer. Error message: " + str(msg)}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_json = json.dumps({'remoteTransferStatus': 0, 'error_message': str(msg)}) return HttpResponse(final_json) @@ -1045,7 +1045,7 @@ class BackupManager: 'backupsSent': 0} json_data = json.dumps(data) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data = {'remoteTransferStatus': 0, 'error_message': str(msg), 'backupsSent': 0} json_data = json.dumps(data) return HttpResponse(json_data) @@ -1063,7 +1063,7 @@ class BackupManager: ## - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/remoteTransferUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/remoteTransferUtilities.py" execPath = execPath + " remoteBackupRestore --backupDirComplete " + backupDirComplete + " --backupDir " + str( backupDir) @@ -1075,7 +1075,7 @@ class BackupManager: json_data = json.dumps(data) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data = {'remoteRestoreStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) @@ -1122,7 +1122,7 @@ class BackupManager: "complete": 0} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data = {'remoteTransferStatus': 0, 'error_message': str(msg), "status": "None", "complete": 0} json_data = json.dumps(data) return HttpResponse(json_data) @@ -1168,7 +1168,7 @@ class BackupManager: json_data = json.dumps(data) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data = {'cancelStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) diff --git a/backup/models.py b/backup/models.py index e037c96f7..0d4fdfc55 100755 --- a/backup/models.py +++ b/backup/models.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals + from django.db import models diff --git a/backup/pluginManager.py b/backup/pluginManager.py index 95373eacb..7f8a5b50d 100755 --- a/backup/pluginManager.py +++ b/backup/pluginManager.py @@ -1,4 +1,4 @@ -from signals import * +from .signals import * from plogical.pluginManagerGlobal import pluginManagerGlobal class pluginManager: diff --git a/backup/tests.py b/backup/tests.py index 5982e6bcd..f067dcaac 100755 --- a/backup/tests.py +++ b/backup/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/backup/urls.py b/backup/urls.py index 47d79639b..0a7164ba2 100755 --- a/backup/urls.py +++ b/backup/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^$', views.loadBackupHome, name='loadBackupHome'), diff --git a/backup/views.py b/backup/views.py index e237e1094..ef8842283 100755 --- a/backup/views.py +++ b/backup/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + # Create your views here. import json @@ -61,7 +61,7 @@ def submitBackupCreation(request): return coreResult - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) @@ -337,5 +337,5 @@ def localInitiate(request): if os.path.exists(randomFile): wm = BackupManager() return wm.submitBackupCreation(1, json.loads(request.body)) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) diff --git a/baseTemplate/admin.py b/baseTemplate/admin.py index 13be29d96..4c33e0ec3 100755 --- a/baseTemplate/admin.py +++ b/baseTemplate/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/baseTemplate/apps.py b/baseTemplate/apps.py index 5b384a5e9..f5ce2e6d1 100755 --- a/baseTemplate/apps.py +++ b/baseTemplate/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/baseTemplate/models.py b/baseTemplate/models.py index cef15e16d..876f66dcb 100755 --- a/baseTemplate/models.py +++ b/baseTemplate/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html index f87a70cbe..c73ceeaf2 100755 --- a/baseTemplate/templates/baseTemplate/index.html +++ b/baseTemplate/templates/baseTemplate/index.html @@ -410,6 +410,9 @@
  • {% trans "List Websites" %}
  • +
  • {% trans "List Child Domains" %} +
  • {% trans "Modify Website" %}
  • diff --git a/baseTemplate/tests.py b/baseTemplate/tests.py index 5982e6bcd..f067dcaac 100755 --- a/baseTemplate/tests.py +++ b/baseTemplate/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/baseTemplate/urls.py b/baseTemplate/urls.py index 7af0f42b6..31a0ed8c5 100755 --- a/baseTemplate/urls.py +++ b/baseTemplate/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^$', views.renderBase, name='index'), diff --git a/baseTemplate/views.py b/baseTemplate/views.py index 21ee65a91..1e8518247 100755 --- a/baseTemplate/views.py +++ b/baseTemplate/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render,redirect from django.http import HttpResponse @@ -199,7 +199,7 @@ def upgradeStatus(request): return HttpResponse(final_json) - except BaseException,msg: + except BaseException as msg: final_dic = {'upgradeStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -217,6 +217,6 @@ def upgradeVersion(request): vers.build = latest['build'] vers.save() return HttpResponse("Version upgrade OK.") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse(str(msg)) \ No newline at end of file diff --git a/cli/cliLogger.py b/cli/cliLogger.py index c5c25a554..b2fd928f2 100755 --- a/cli/cliLogger.py +++ b/cli/cliLogger.py @@ -20,9 +20,9 @@ class cliLogger: def readLastNFiles(numberOfLines,fileName): try: - lastFewLines = subprocess.check_output(["tail", "-n",str(numberOfLines),fileName]) + lastFewLines = subprocess.check_output(["tail", "-n",str(numberOfLines),fileName]).decode("utf-8") return lastFewLines - except subprocess.CalledProcessError,msg: + except subprocess.CalledProcessError as msg: return "File was empty" diff --git a/cli/cyberPanel.py b/cli/cyberPanel.py index f33a7fbca..1d92f5042 100755 --- a/cli/cyberPanel.py +++ b/cli/cyberPanel.py @@ -1,11 +1,11 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os,sys sys.path.append('/usr/local/CyberCP') import django os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") django.setup() from inspect import stack -from cliLogger import cliLogger as logger +from cli.cliLogger import cliLogger as logger import json from plogical.virtualHostUtilities import virtualHostUtilities import re @@ -17,7 +17,7 @@ import requests from loginSystem.models import Administrator from packages.models import Package from plogical.mysqlUtilities import mysqlUtilities -from cliParser import cliParser +from cli.cliParser import cliParser from plogical.vhost import vhost from plogical.mailUtilities import mailUtilities from plogical.ftpUtilities import FTPUtilities @@ -33,7 +33,7 @@ class cyberPanel: data = json.dumps({'success': operationStatus, 'errorMessage': errorMessage }) - print data + print(data) ## Website Functions @@ -51,7 +51,7 @@ class cyberPanel: else: self.printStatus(0, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -68,7 +68,7 @@ class cyberPanel: else: self.printStatus(0, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -77,9 +77,9 @@ class cyberPanel: vhost.deleteVirtualHostConfigurations(domainName) self.printStatus(1, 'None') - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def deleteChild(self, childDomain): try: @@ -91,9 +91,9 @@ class cyberPanel: else: self.printStatus(0, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def listWebsitesJson(self): try: @@ -122,11 +122,11 @@ class cyberPanel: json_data = json_data + ']' final_json = json.dumps(json_data) - print final_json + print(final_json) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def listWebsitesPretty(self): try: @@ -146,11 +146,11 @@ class cyberPanel: else: state = "Active" table.add_row([items.id, items.domain, ipAddress, items.package.packageName, items.admin.userName, state, items.adminEmail]) - print table + print(table) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def changePHP(self, virtualHostName, phpVersion): try: @@ -167,7 +167,7 @@ class cyberPanel: else: self.printStatus(0, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -186,7 +186,7 @@ class cyberPanel: self.printStatus(1, 'None') - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -218,11 +218,11 @@ class cyberPanel: json_data = json_data + ']' final_json = json.dumps(json_data) - print final_json + print(final_json) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def listDNSPretty(self, virtualHostName): try: @@ -237,11 +237,11 @@ class cyberPanel: else: content = items.content table.add_row([items.id, items.type, items.name, content, items.prio, items.ttl]) - print table + print(table) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def listDNSZonesJson(self): try: @@ -264,11 +264,11 @@ class cyberPanel: json_data = json_data + ']' final_json = json.dumps(json_data) - print final_json + print(final_json) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def listDNSZonesPretty(self): try: @@ -280,18 +280,18 @@ class cyberPanel: for items in records: table.add_row([items.id, items.name]) - print table + print(table) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def createDNSZone(self, virtualHostName, owner): try: admin = Administrator.objects.get(userName=owner) DNS.dnsTemplate(virtualHostName, admin) self.printStatus(1, 'None') - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -300,7 +300,7 @@ class cyberPanel: zone = DNS.getZoneObject(virtualHostName) DNS.createDNSRecord(zone, name, recordType, value, int(priority), int(ttl)) self.printStatus(1, 'None') - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -308,7 +308,7 @@ class cyberPanel: try: DNS.deleteDNSZone(virtualHostName) self.printStatus(1, 'None') - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -316,7 +316,7 @@ class cyberPanel: try: DNS.deleteDNSRecord(recordID) self.printStatus(1, 'None') - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -326,13 +326,13 @@ class cyberPanel: try: backupLogPath = "/usr/local/lscp/logs/backup_log."+time.strftime("%I-%M-%S-%a-%b-%Y") - print 'Backup logs to be generated in %s' % (backupLogPath) + print('Backup logs to be generated in %s' % (backupLogPath)) backupSchedule.createLocalBackup(virtualHostName, backupLogPath) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def restoreBackup(self, fileName): try: @@ -351,19 +351,19 @@ class cyberPanel: data = json.loads(r.text) if data['abort'] == 1 and data['running'] == "Error": - print 'Failed to restore backup, Error message : ' + data['status'] + '\n' + print('Failed to restore backup, Error message : ' + data['status'] + '\n') break elif data['abort'] == 1 and data['running'] == "Completed": - print '\n\n' - print 'Backup restore completed.\n' + print('\n\n') + print('Backup restore completed.\n') break else: - print 'Waiting for restore to complete. Current status: ' + data['status'] + print('Waiting for restore to complete. Current status: ' + data['status']) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) ## Packages @@ -380,7 +380,7 @@ class cyberPanel: self.printStatus(1, 'None') - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -391,7 +391,7 @@ class cyberPanel: delPack.delete() self.printStatus(1, 'None') - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -422,11 +422,11 @@ class cyberPanel: json_data = json_data + ']' final_json = json.dumps(json_data) - print final_json + print(final_json) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def listPackagesPretty(self): try: @@ -438,11 +438,11 @@ class cyberPanel: for items in records: table.add_row([items.packageName, items.allowedDomains, items.diskSpace, items.bandwidth, items.ftpAccounts, items.dataBases, items.emailAccounts]) - print table + print(table) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) ## Database functions @@ -455,7 +455,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -468,7 +468,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -494,11 +494,11 @@ class cyberPanel: json_data = json_data + ']' final_json = json.dumps(json_data) - print final_json + print(final_json) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def listDatabasesPretty(self, virtualHostName): try: @@ -510,11 +510,11 @@ class cyberPanel: for items in records: table.add_row([items.id, items.dbName, items.dbUser]) - print table + print(table) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) ## Email functions @@ -526,7 +526,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -538,7 +538,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -550,7 +550,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -575,11 +575,11 @@ class cyberPanel: json_data = json_data + ']' final_json = json.dumps(json_data) - print final_json + print(final_json) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def listEmailsPretty(self, virtualHostName): try: @@ -591,11 +591,11 @@ class cyberPanel: for items in records: table.add_row([items.email]) - print table + print(table) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) ## FTP Functions @@ -612,7 +612,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -624,7 +624,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -636,7 +636,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -662,11 +662,11 @@ class cyberPanel: json_data = json_data + ']' final_json = json.dumps(json_data) - print final_json + print(final_json) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) def listFTPPretty(self, virtualHostName): try: @@ -678,11 +678,11 @@ class cyberPanel: for items in records: table.add_row([items.id, items.user, items.dir]) - print table + print(table) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) - print 0 + print(0) ## FTP Functions @@ -709,7 +709,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -733,7 +733,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -757,7 +757,7 @@ class cyberPanel: self.printStatus(1, 'None') else: self.printStatus(1, result[1]) - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -786,7 +786,7 @@ class cyberPanel: ProcessUtilities.restartLitespeed() self.printStatus(1, 'None') - except BaseException, msg: + except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) self.printStatus(0, str(msg)) @@ -803,23 +803,23 @@ def main(): completeCommandExample = 'cyberpanel createWebsite --package Detault --owner admin --domainName cyberpanel.net --email support@cyberpanel.net --php 5.6' if not args.package: - print "\n\nPlease enter the package name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the package name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.owner: - print "\n\nPlease enter the owner name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the owner name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.domainName: - print "\n\nPlease enter the domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the domain name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.email: - print "\n\nPlease enter the email. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the email. For example:\n\n" + completeCommandExample + "\n\n") return if not args.php: - print "\n\nPlease enter the PHP version such as 5.6 for PHP version 5.6. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the PHP version such as 5.6 for PHP version 5.6. For example:\n\n" + completeCommandExample + "\n\n") return if args.ssl: @@ -843,7 +843,7 @@ def main(): completeCommandExample = 'cyberpanel deleteWebsite --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter the domain to delete. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the domain to delete. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.deleteWebsite(args.domainName) @@ -853,19 +853,19 @@ def main(): ' --owner admin --php 5.6' if not args.masterDomain: - print "\n\nPlease enter Master domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter Master domain. For example:\n\n" + completeCommandExample + "\n\n") return if not args.childDomain: - print "\n\nPlease enter the Child Domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the Child Domain. For example:\n\n" + completeCommandExample + "\n\n") return if not args.owner: - print "\n\nPlease enter owner for this domain DNS records. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter owner for this domain DNS records. For example:\n\n" + completeCommandExample + "\n\n") return if not args.php: - print "\n\nPlease enter required PHP version. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter required PHP version. For example:\n\n" + completeCommandExample + "\n\n") return if args.ssl: @@ -889,7 +889,7 @@ def main(): completeCommandExample = 'cyberpanel deleteChild --childDomain cyberpanel.net' if not args.childDomain: - print "\n\nPlease enter the child domain to delete. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the child domain to delete. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.deleteChild(args.childDomain) @@ -903,11 +903,11 @@ def main(): completeCommandExample = 'cyberpanel changePHP --domainName cyberpanel.net --php 5.6' if not args.domainName: - print "\n\nPlease enter Domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter Domain. For example:\n\n" + completeCommandExample + "\n\n") return if not args.php: - print "\n\nPlease enter required PHP version. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter required PHP version. For example:\n\n" + completeCommandExample + "\n\n") return @@ -917,11 +917,11 @@ def main(): completeCommandExample = 'cyberpanel changePackage --domainName cyberpanel.net --packageName CLI' if not args.domainName: - print "\n\nPlease enter the Domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the Domain. For example:\n\n" + completeCommandExample + "\n\n") return if not args.packageName: - print "\n\nPlease enter the package name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the package name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.changePackage(args.domainName, args.packageName) @@ -933,7 +933,7 @@ def main(): completeCommandExample = 'cyberpanel listDNSJson --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.listDNSJson(args.domainName) @@ -942,7 +942,7 @@ def main(): completeCommandExample = 'cyberpanel listDNSPretty --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.listDNSPretty(args.domainName) @@ -954,11 +954,11 @@ def main(): completeCommandExample = 'cyberpanel createDNSZone --owner admin --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n") return if not args.owner: - print "\n\nPlease enter the owner name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the owner name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.createDNSZone(args.domainName, args.owner) @@ -966,7 +966,7 @@ def main(): completeCommandExample = 'cyberpanel deleteDNSZone --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.deleteDNSZone(args.domainName) @@ -975,27 +975,27 @@ def main(): ' --recordType A --value 192.168.100.1 --priority 0 --ttl 3600' if not args.domainName: - print "\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n") return if not args.name: - print "\n\nPlease enter the record name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the record name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.recordType: - print "\n\nPlease enter the record type. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the record type. For example:\n\n" + completeCommandExample + "\n\n") return if not args.value: - print "\n\nPlease enter the record value. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the record value. For example:\n\n" + completeCommandExample + "\n\n") return if not args.priority: - print "\n\nPlease enter the priority. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the priority. For example:\n\n" + completeCommandExample + "\n\n") return if not args.ttl: - print "\n\nPlease enter the ttl. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the ttl. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.createDNSRecord(args.domainName, args.name, args.recordType, args.value, args.priority, args.ttl) @@ -1003,7 +1003,7 @@ def main(): completeCommandExample = 'cyberpanel deleteDNSRecord --recordID 200' if not args.recordID: - print "\n\nPlease enter the record ID to be deleted, you can find record ID by listing the current DNS records. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the record ID to be deleted, you can find record ID by listing the current DNS records. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.deleteDNSRecord(args.recordID) @@ -1015,7 +1015,7 @@ def main(): completeCommandExample = 'cyberpanel createBackup --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the domain. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.createBackup(args.domainName) @@ -1024,7 +1024,7 @@ def main(): completeCommandExample = 'cyberpanel restoreBackup --fileName /home/talkshosting.com/backup/backup-talksho-01-30-53-Fri-Jun-2018.tar.gz' if not args.fileName: - print "\n\nPlease enter the file name or complete path to file. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the file name or complete path to file. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.restoreBackup(args.fileName) @@ -1037,33 +1037,33 @@ def main(): ' --dataBases 100 --ftpAccounts 100 --allowedDomains 100' if not args.owner: - print "\n\nPlease enter the owner name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the owner name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.packageName: - print "\n\nPlease enter the package name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the package name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.diskSpace: - print "\n\nPlease enter value for Disk Space. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter value for Disk Space. For example:\n\n" + completeCommandExample + "\n\n") return if not args.bandwidth: - print "\n\nPlease enter value for Bandwidth. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter value for Bandwidth. For example:\n\n" + completeCommandExample + "\n\n") return if not args.emailAccounts: - print "\n\nPlease enter value for Email accounts. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter value for Email accounts. For example:\n\n" + completeCommandExample + "\n\n") return if not args.dataBases: - print "\n\nPlease enter value for Databases. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter value for Databases. For example:\n\n" + completeCommandExample + "\n\n") return if not args.ftpAccounts: - print "\n\nPlease enter value for Ftp accounts. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter value for Ftp accounts. For example:\n\n" + completeCommandExample + "\n\n") return if not args.allowedDomains: - print "\n\nPlease enter value for Allowed Child Domains. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter value for Allowed Child Domains. For example:\n\n" + completeCommandExample + "\n\n") return @@ -1073,7 +1073,7 @@ def main(): elif args.function == "deletePackage": completeCommandExample = 'cyberpanel deletePackage --packageName CLI' if not args.packageName: - print "\n\nPlease enter the package name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the package name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.deletePackage(args.packageName) @@ -1090,24 +1090,24 @@ def main(): '--dbUsername cyberpanel --dbPassword cyberpanel' if not args.databaseWebsite: - print "\n\nPlease enter database website. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter database website. For example:\n\n" + completeCommandExample + "\n\n") return if not args.dbName: - print "\n\nPlease enter the database name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the database name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.dbUsername: - print "\n\nPlease enter the database username. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the database username. For example:\n\n" + completeCommandExample + "\n\n") return if not args.dbPassword: - print "\n\nPlease enter the password for database. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the password for database. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.createDatabase(args.dbName, args.dbUsername, args.dbPassword, args.databaseWebsite) elif args.function == "deleteDatabase": completeCommandExample = 'cyberpanel deleteDatabase --dbName cyberpanel' if not args.dbName: - print "\n\nPlease enter the database name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the database name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.deleteDatabase(args.dbName) @@ -1116,14 +1116,14 @@ def main(): completeCommandExample = 'cyberpanel listDatabasesJson --databaseWebsite cyberpanel.net' if not args.databaseWebsite: - print "\n\nPlease enter database website. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter database website. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.listDatabasesJson(args.databaseWebsite) elif args.function == "listDatabasesPretty": completeCommandExample = 'cyberpanel listDatabasesPretty --databaseWebsite cyberpanel.net' if not args.databaseWebsite: - print "\n\nPlease enter database website. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter database website. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.listDatabasesPretty(args.databaseWebsite) @@ -1136,14 +1136,14 @@ def main(): '--password cyberpanel' if not args.domainName: - print "\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.userName: - print "\n\nPlease enter the user name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the user name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.password: - print "\n\nPlease enter the password for database. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the password for database. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.createEmail(args.domainName, args.userName, args.password) @@ -1151,7 +1151,7 @@ def main(): completeCommandExample = 'cyberpanel deleteEmail --email cyberpanel@cyberpanel.net' if not args.email: - print "\n\nPlease enter the email. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the email. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.deleteEmail(args.email) @@ -1160,11 +1160,11 @@ def main(): completeCommandExample = 'cyberpanel changeEmailPassword --email cyberpanel@cyberpanel.net --password cyberpanel' if not args.email: - print "\n\nPlease enter email. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter email. For example:\n\n" + completeCommandExample + "\n\n") return if not args.password: - print "\n\nPlease enter the password. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the password. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.changeEmailPassword(args.email, args.password) @@ -1172,7 +1172,7 @@ def main(): completeCommandExample = 'cyberpanel listEmailsJson --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter domain name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.listEmailsJson(args.domainName) @@ -1180,7 +1180,7 @@ def main(): completeCommandExample = 'cyberpanel listEmailsPretty --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter domain name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.listEmailsPretty(args.domainName) @@ -1193,18 +1193,18 @@ def main(): '--password cyberpanel --owner admin' if not args.domainName: - print "\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.userName: - print "\n\nPlease enter the user name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the user name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.password: - print "\n\nPlease enter the password for database. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the password for database. For example:\n\n" + completeCommandExample + "\n\n") return if not args.owner: - print "\n\nPlease enter the owner name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the owner name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.createFTPAccount(args.domainName, args.userName, args.password, args.owner) @@ -1212,7 +1212,7 @@ def main(): completeCommandExample = 'cyberpanel deleteFTPAccount --userName cyberpanel' if not args.userName: - print "\n\nPlease enter the user name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the user name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.deleteFTPAccount(args.userName) @@ -1221,11 +1221,11 @@ def main(): completeCommandExample = 'cyberpanel changeFTPPassword --userName cyberpanel --password cyberpanel' if not args.userName: - print "\n\nPlease enter the user name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the user name. For example:\n\n" + completeCommandExample + "\n\n") return if not args.password: - print "\n\nPlease enter the password for database. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter the password for database. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.changeFTPPassword(args.userName, args.password) @@ -1233,7 +1233,7 @@ def main(): completeCommandExample = 'cyberpanel listFTPJson --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter domain name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.listFTPJson(args.domainName) @@ -1241,7 +1241,7 @@ def main(): completeCommandExample = 'cyberpanel listFTPPretty --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter domain name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.listFTPPretty(args.domainName) @@ -1251,7 +1251,7 @@ def main(): completeCommandExample = 'cyberpanel issueSSL --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.issueSSL(args.domainName) @@ -1259,7 +1259,7 @@ def main(): completeCommandExample = 'cyberpanel hostNameSSL --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.issueSSLForHostName(args.domainName) @@ -1268,7 +1268,7 @@ def main(): completeCommandExample = 'cyberpanel mailServerSSL --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.issueSSLForMailServer(args.domainName) @@ -1277,7 +1277,7 @@ def main(): completeCommandExample = 'cyberpanel issueSelfSignedSSL --domainName cyberpanel.net' if not args.domainName: - print "\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n" + print("\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n") return cyberpanel.issueSelfSignedSSL(args.domainName) diff --git a/cloudAPI/admin.py b/cloudAPI/admin.py index 13be29d96..4c33e0ec3 100755 --- a/cloudAPI/admin.py +++ b/cloudAPI/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/cloudAPI/apps.py b/cloudAPI/apps.py index 504e7eea9..ede1e3740 100755 --- a/cloudAPI/apps.py +++ b/cloudAPI/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/cloudAPI/cloudManager.py b/cloudAPI/cloudManager.py index 6f6b5cfb1..1cb8eb780 100755 --- a/cloudAPI/cloudManager.py +++ b/cloudAPI/cloudManager.py @@ -40,14 +40,14 @@ class CloudManager: else: return 0, self.ajaxPre(0, 'Invalid login information.') - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchWebsites(self): try: wm = WebsiteManager() return wm.getFurtherAccounts(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitWebsiteDeletion(self, request): @@ -55,7 +55,7 @@ class CloudManager: request.session['userID'] = self.admin.pk wm = WebsiteManager() return wm.submitWebsiteDeletion(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitWebsiteCreation(self): @@ -82,25 +82,25 @@ class CloudManager: token=token ) newAdmin.save() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) admin = Administrator.objects.get(userName=UserAccountName) admin.token = token admin.password = password admin.save() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) wm = WebsiteManager() return wm.submitWebsiteCreation(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchWebsiteDataJSON(self): try: wm = WebsiteManager() return wm.fetchWebsiteDataJSON(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchWebsiteData(self): @@ -128,7 +128,7 @@ class CloudManager: ## bw usage calculation try: - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " findDomainBW --virtualHostName " + self.data[ 'domainName'] + " --bandwidth " + str( website.package.bandwidth) @@ -160,70 +160,70 @@ class CloudManager: final_json = json.dumps(Data) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchModifyData(self): try: wm = WebsiteManager() return wm.submitWebsiteModify(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def saveModifications(self): try: wm = WebsiteManager() return wm.saveWebsiteChanges(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitDBCreation(self): try: dm = DatabaseManager() return dm.submitDBCreation(self.admin.pk, self.data, 1) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchDatabases(self): try: dm = DatabaseManager() return dm.fetchDatabases(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitDatabaseDeletion(self): try: dm = DatabaseManager() return dm.submitDatabaseDeletion(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def changePassword(self): try: dm = DatabaseManager() return dm.changePassword(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getCurrentRecordsForDomain(self): try: dm = DNSManager() return dm.getCurrentRecordsForDomain(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteDNSRecord(self): try: dm = DNSManager() return dm.deleteDNSRecord(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def addDNSRecord(self): try: dm = DNSManager() return dm.addDNSRecord(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitEmailCreation(self, request): @@ -231,7 +231,7 @@ class CloudManager: request.session['userID'] = self.admin.pk msm = MailServerManager(request) return msm.submitEmailCreation() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getEmailsForDomain(self, request): @@ -239,7 +239,7 @@ class CloudManager: request.session['userID'] = self.admin.pk msm = MailServerManager(request) return msm.getEmailsForDomain() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitEmailDeletion(self, request): @@ -247,7 +247,7 @@ class CloudManager: request.session['userID'] = self.admin.pk msm = MailServerManager(request) return msm.submitEmailDeletion() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitPasswordChange(self, request): @@ -255,7 +255,7 @@ class CloudManager: request.session['userID'] = self.admin.pk msm = MailServerManager(request) return msm.submitPasswordChange() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchCurrentForwardings(self, request): @@ -263,7 +263,7 @@ class CloudManager: request.session['userID'] = self.admin.pk msm = MailServerManager(request) return msm.fetchCurrentForwardings() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitForwardDeletion(self, request): @@ -271,7 +271,7 @@ class CloudManager: request.session['userID'] = self.admin.pk msm = MailServerManager(request) return msm.submitForwardDeletion() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitEmailForwardingCreation(self, request): @@ -279,7 +279,7 @@ class CloudManager: request.session['userID'] = self.admin.pk msm = MailServerManager(request) return msm.submitEmailForwardingCreation() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchDKIMKeys(self, request): @@ -287,7 +287,7 @@ class CloudManager: request.session['userID'] = self.admin.pk msm = MailServerManager(request) return msm.fetchDKIMKeys() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def generateDKIMKeys(self, request): @@ -295,7 +295,7 @@ class CloudManager: request.session['userID'] = self.admin.pk msm = MailServerManager(request) return msm.generateDKIMKeys() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitFTPCreation(self, request): @@ -303,7 +303,7 @@ class CloudManager: request.session['userID'] = self.admin.pk fm = FTPManager(request) return fm.submitFTPCreation() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getAllFTPAccounts(self, request): @@ -311,7 +311,7 @@ class CloudManager: request.session['userID'] = self.admin.pk fm = FTPManager(request) return fm.getAllFTPAccounts() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitFTPDelete(self, request): @@ -319,7 +319,7 @@ class CloudManager: request.session['userID'] = self.admin.pk fm = FTPManager(request) return fm.submitFTPDelete() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def changeFTPPassword(self, request): @@ -327,14 +327,14 @@ class CloudManager: request.session['userID'] = self.admin.pk fm = FTPManager(request) return fm.changePassword() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def issueSSL(self, request): try: request.session['userID'] = self.admin.pk return issueSSL(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def statusFunc(self): @@ -365,7 +365,7 @@ class CloudManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'abort': 0, 'installationProgress': "0", 'errorMessage': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -374,35 +374,35 @@ class CloudManager: try: wm = WebsiteManager() return wm.submitDomainCreation(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchDomains(self): try: wm = WebsiteManager() return wm.fetchDomains(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitDomainDeletion(self): try: wm = WebsiteManager() return wm.submitDomainDeletion(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def changeOpenBasedir(self): try: wm = WebsiteManager() return wm.changeOpenBasedir(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def changePHP(self): try: wm = WebsiteManager() return wm.changePHP(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def backupStatusFunc(self): @@ -410,7 +410,7 @@ class CloudManager: bm = BackupManager() return bm.backupStatus(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'abort': 0, 'installationProgress': "0", 'errorMessage': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -419,21 +419,21 @@ class CloudManager: try: bm = BackupManager() return bm.submitBackupCreation(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getCurrentBackups(self): try: bm = BackupManager() return bm.getCurrentBackups(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteBackup(self): try: bm = BackupManager() return bm.deleteBackup(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchACLs(self): @@ -466,14 +466,14 @@ class CloudManager: final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitUserCreation(self, request): try: request.session['userID'] = self.admin.pk return um.submitUserCreation(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchUsers(self): @@ -505,21 +505,21 @@ class CloudManager: final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitUserDeletion(self, request): try: request.session['userID'] = self.admin.pk return um.submitUserDeletion(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def saveModificationsUser(self, request): try: request.session['userID'] = self.admin.pk return um.saveModifications(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def userWithResellerPriv(self): @@ -544,28 +544,28 @@ class CloudManager: json_data = json_data + ']' final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def saveResellerChanges(self, request): try: request.session['userID'] = self.admin.pk return um.saveResellerChanges(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def changeACLFunc(self, request): try: request.session['userID'] = self.admin.pk return um.changeACLFunc(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def createACLFunc(self, request): try: request.session['userID'] = self.admin.pk return um.createACLFunc(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def findAllACLs(self, request): @@ -593,28 +593,28 @@ class CloudManager: json_data = json_data + ']' final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteACLFunc(self, request): try: request.session['userID'] = self.admin.pk return um.deleteACLFunc(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchACLDetails(self, request): try: request.session['userID'] = self.admin.pk return um.fetchACLDetails(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitACLModifications(self, request): try: request.session['userID'] = self.admin.pk return um.submitACLModifications(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitPackage(self, request): @@ -622,7 +622,7 @@ class CloudManager: request.session['userID'] = self.admin.pk pm = PackagesManager(request) return pm.submitPackage() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchPackages(self, request): @@ -658,7 +658,7 @@ class CloudManager: json_data = json_data + ']' final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitPackageDelete(self, request): @@ -666,7 +666,7 @@ class CloudManager: request.session['userID'] = self.admin.pk pm = PackagesManager(request) return pm.submitDelete() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitPackageModify(self, request): @@ -674,21 +674,21 @@ class CloudManager: request.session['userID'] = self.admin.pk pm = PackagesManager(request) return pm.saveChanges() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getDataFromLogFile(self, request): try: wm = WebsiteManager() return wm.getDataFromLogFile(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchErrorLogs(self, request): try: wm = WebsiteManager() return wm.fetchErrorLogs(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitApplicationInstall(self, request): @@ -703,7 +703,7 @@ class CloudManager: elif self.data['selectedApplication'] == 'Joomla': return wm.installJoomla(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def obtainServer(self, request): @@ -712,63 +712,63 @@ class CloudManager: data_ret = {'status': 1, 'serverStatus': ProcessUtilities.decideServer()} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getSSHConfigs(self): try: fm = FirewallManager() return fm.getSSHConfigs(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def saveSSHConfigs(self): try: fm = FirewallManager() return fm.saveSSHConfigs(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteSSHKey(self): try: fm = FirewallManager() return fm.deleteSSHKey(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def addSSHKey(self): try: fm = FirewallManager() return fm.addSSHKey(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getCurrentRules(self): try: fm = FirewallManager() return fm.getCurrentRules(self.admin.pk) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def addRule(self): try: fm = FirewallManager() return fm.addRule(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteRule(self): try: fm = FirewallManager() return fm.deleteRule(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getLogsFromFile(self, request): try: request.session['userID'] = self.admin.pk return getLogsFromFile(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def serverSSL(self, request): @@ -778,7 +778,7 @@ class CloudManager: return obtainHostNameSSL(request) else: return obtainMailServerSSL(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def setupManager(self, request): @@ -796,7 +796,7 @@ class CloudManager: proc = httpProc(request, None) return proc.ajax(1, None, data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchManagerTokens(self, request): @@ -805,7 +805,7 @@ class CloudManager: ham = HAManager(request, self.data, 'fetchManagerTokens') return ham.fetchManagerTokens() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def addWorker(self, request): @@ -814,7 +814,7 @@ class CloudManager: ham = HAManager(request, self.data, 'fetchManagerTokens') return ham.addWorker() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchSSHKey(self, request): @@ -830,14 +830,14 @@ class CloudManager: } json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def putSSHkeyFunc(self, request): try: fm = FirewallManager(request) return fm.addSSHKey(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def leaveSwarm(self, request): @@ -845,7 +845,7 @@ class CloudManager: request.session['userID'] = self.admin.pk ham = HAManager(request, self.data, 'leaveSwarm') return ham.leaveSwarm() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def setUpDataNode(self, request): @@ -853,7 +853,7 @@ class CloudManager: request.session['userID'] = self.admin.pk ham = HAManager(request, self.data, 'setUpDataNode') return ham.setUpDataNode() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitEditCluster(self, request): @@ -861,7 +861,7 @@ class CloudManager: request.session['userID'] = self.admin.pk ham = HAManager(request, self.data, 'submitEditCluster') return ham.submitEditCluster() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def connectAccount(self, request): @@ -869,7 +869,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'connectAccount') return s3.connectAccount() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchBuckets(self, request): @@ -877,7 +877,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchBuckets') return s3.fetchBuckets() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def createPlan(self, request): @@ -885,7 +885,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'createPlan') return s3.createPlan() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchBackupPlans(self, request): @@ -893,7 +893,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchBackupPlans') return s3.fetchBackupPlans() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deletePlan(self, request): @@ -901,7 +901,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'deletePlan') return s3.deletePlan() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchWebsitesInPlan(self, request): @@ -909,7 +909,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchWebsitesInPlan') return s3.fetchWebsitesInPlan() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteDomainFromPlan(self, request): @@ -917,7 +917,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'deleteDomainFromPlan') return s3.deleteDomainFromPlan() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def savePlanChanges(self, request): @@ -925,7 +925,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'savePlanChanges') return s3.savePlanChanges() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchBackupLogs(self, request): @@ -933,7 +933,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchBackupLogs') return s3.fetchBackupLogs() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def forceRunAWSBackup(self, request): @@ -942,14 +942,14 @@ class CloudManager: s3 = S3Backups(request, self.data, 'forceRunAWSBackup') s3.start() return self.ajaxPre(1, None) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def systemStatus(self, request): try: return topProcessesStatus(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) @@ -957,7 +957,7 @@ class CloudManager: try: request.session['userID'] = self.admin.pk return killProcess(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) @@ -966,7 +966,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'connectAccountDO') return s3.connectAccountDO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchBucketsDO(self, request): @@ -974,7 +974,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchBucketsDO') return s3.fetchBucketsDO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) @@ -983,7 +983,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'createPlanDO') return s3.createPlanDO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchBackupPlansDO(self, request): @@ -991,7 +991,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchBackupPlansDO') return s3.fetchBackupPlansDO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deletePlanDO(self, request): @@ -999,7 +999,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'deletePlanDO') return s3.deletePlanDO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchWebsitesInPlanDO(self, request): @@ -1007,7 +1007,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchWebsitesInPlanDO') return s3.fetchWebsitesInPlanDO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchBackupLogsDO(self, request): @@ -1015,7 +1015,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchBackupLogsDO') return s3.fetchBackupLogsDO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteDomainFromPlanDO(self, request): @@ -1023,7 +1023,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'deleteDomainFromPlanDO') return s3.deleteDomainFromPlanDO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def savePlanChangesDO(self, request): @@ -1031,7 +1031,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'savePlanChangesDO') return s3.savePlanChangesDO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def forceRunAWSBackupDO(self, request): @@ -1040,7 +1040,7 @@ class CloudManager: s3 = S3Backups(request, self.data, 'forceRunAWSBackupDO') s3.start() return self.ajaxPre(1, None) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def showStatus(self, request): @@ -1055,7 +1055,7 @@ class CloudManager: finalData = json.dumps(finalData) return HttpResponse(finalData) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchRam(self, request): @@ -1088,7 +1088,7 @@ class CloudManager: finalData = json.dumps(finalData) return HttpResponse(finalData) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def applyMySQLChanges(self, request): @@ -1106,7 +1106,7 @@ class CloudManager: else: return self.ajaxPre(1, None) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def restartMySQL(self, request): @@ -1121,7 +1121,7 @@ class CloudManager: finalData = json.dumps(finalData) return HttpResponse(finalData) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchDatabasesMYSQL(self, request): @@ -1136,7 +1136,7 @@ class CloudManager: finalData = json.dumps(finalData) return HttpResponse(finalData) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchTables(self, request): @@ -1151,7 +1151,7 @@ class CloudManager: finalData = json.dumps(finalData) return HttpResponse(finalData) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteTable(self, request): @@ -1166,7 +1166,7 @@ class CloudManager: finalData = json.dumps(finalData) return HttpResponse(finalData) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchTableData(self, request): @@ -1181,7 +1181,7 @@ class CloudManager: finalData = json.dumps(finalData) return HttpResponse(finalData) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchStructure(self, request): @@ -1196,7 +1196,7 @@ class CloudManager: finalData = json.dumps(finalData) return HttpResponse(finalData) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def addMINIONode(self, request): @@ -1204,7 +1204,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'addMINIONode') return s3.addMINIONode() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchMINIONodes(self, request): @@ -1212,7 +1212,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchMINIONodes') return s3.fetchMINIONodes() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteMINIONode(self, request): @@ -1220,7 +1220,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'deleteMINIONode') return s3.deleteMINIONode() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def createPlanMINIO(self, request): @@ -1228,7 +1228,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'createPlanMINIO') return s3.createPlanMINIO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchBackupPlansMINIO(self, request): @@ -1236,7 +1236,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchBackupPlansMINIO') return s3.fetchBackupPlansMINIO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) @@ -1245,7 +1245,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'deletePlanMINIO') return s3.deletePlanMINIO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def savePlanChangesMINIO(self, request): @@ -1253,7 +1253,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'savePlanChangesMINIO') return s3.savePlanChangesMINIO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def forceRunAWSBackupMINIO(self, request): @@ -1262,7 +1262,7 @@ class CloudManager: s3 = S3Backups(request, self.data, 'forceRunAWSBackupMINIO') s3.start() return self.ajaxPre(1, None) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchWebsitesInPlanMINIO(self, request): @@ -1270,7 +1270,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchWebsitesInPlanMINIO') return s3.fetchWebsitesInPlanMINIO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchBackupLogsMINIO(self, request): @@ -1278,7 +1278,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'fetchBackupLogsMINIO') return s3.fetchBackupLogsMINIO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteDomainFromPlanMINIO(self, request): @@ -1286,7 +1286,7 @@ class CloudManager: request.session['userID'] = self.admin.pk s3 = S3Backups(request, self.data, 'deleteDomainFromPlanMINIO') return s3.deleteDomainFromPlanMINIO() - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitWebsiteStatus(self, request): @@ -1294,7 +1294,7 @@ class CloudManager: request.session['userID'] = self.admin.pk wm = WebsiteManager() return wm.submitWebsiteStatus(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitChangePHP(self, request): @@ -1302,7 +1302,7 @@ class CloudManager: request.session['userID'] = self.admin.pk wm = WebsiteManager() return wm.changePHP(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getSwitchStatus(self, request): @@ -1310,7 +1310,7 @@ class CloudManager: request.session['userID'] = self.admin.pk wm = WebsiteManager() return wm.getSwitchStatus(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) @@ -1319,7 +1319,7 @@ class CloudManager: request.session['userID'] = self.admin.pk wm = WebsiteManager() return wm.switchServer(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def tuneSettings(self, request): @@ -1327,42 +1327,42 @@ class CloudManager: request.session['userID'] = self.admin.pk wm = WebsiteManager() return wm.tuneSettings(self.admin.pk, self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getCurrentPHPConfig(self, request): try: request.session['userID'] = self.admin.pk return PHPManager.getCurrentPHPConfig(self.data['phpSelection']) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def savePHPConfigBasic(self, request): try: request.session['userID'] = self.admin.pk return PHPManager.savePHPConfigBasic(self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchPHPSettingsAdvance(self, request): try: request.session['userID'] = self.admin.pk return PHPManager.fetchPHPSettingsAdvance(self.data['phpSelection']) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def savePHPConfigAdvance(self, request): try: request.session['userID'] = self.admin.pk return PHPManager.savePHPConfigAdvance(self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchPHPExtensions(self, request): try: request.session['userID'] = self.admin.pk return PHPManager.fetchPHPExtensions(self.data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitExtensionRequest(self, request): @@ -1370,14 +1370,14 @@ class CloudManager: request.session['userID'] = self.admin.pk submitExtensionRequest(request) return self.ajaxPre(1, 'None') - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getRequestStatus(self, request): try: request.session['userID'] = self.admin.pk return getRequestStatusApache(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getContainerizationStatus(self, request): @@ -1394,7 +1394,7 @@ class CloudManager: finalData = json.dumps(finalData) return HttpResponse(finalData) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def submitContainerInstall(self, request): @@ -1414,33 +1414,33 @@ class CloudManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def switchTOLSWSStatus(self, request): try: request.session['userID'] = self.admin.pk return switchTOLSWSStatus(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def fetchWebsiteLimits(self, request): try: request.session['userID'] = self.admin.pk return fetchWebsiteLimits(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def saveWebsiteLimits(self, request): try: request.session['userID'] = self.admin.pk return saveWebsiteLimits(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def getUsageData(self, request): try: request.session['userID'] = self.admin.pk return getUsageData(request) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) \ No newline at end of file diff --git a/cloudAPI/models.py b/cloudAPI/models.py index 1dfab7604..4e6a8e76d 100755 --- a/cloudAPI/models.py +++ b/cloudAPI/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/cloudAPI/tests.py b/cloudAPI/tests.py index 5982e6bcd..f067dcaac 100755 --- a/cloudAPI/tests.py +++ b/cloudAPI/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/cloudAPI/urls.py b/cloudAPI/urls.py index 94a9b975c..2c9619e7b 100755 --- a/cloudAPI/urls.py +++ b/cloudAPI/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^$', views.router, name='router'), diff --git a/cloudAPI/views.py b/cloudAPI/views.py index 40df5120d..c8b98dcfe 100755 --- a/cloudAPI/views.py +++ b/cloudAPI/views.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals -from cloudManager import CloudManager + +from .cloudManager import CloudManager import json from loginSystem.models import Administrator from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging @@ -307,6 +307,6 @@ def router(request): else: return cm.ajaxPre(0, 'This function is not available in your version of CyberPanel.') - except BaseException, msg: + except BaseException as msg: cm = CloudManager(None) return cm.ajaxPre(0, str(msg)) diff --git a/containerization/admin.py b/containerization/admin.py index 13be29d96..4c33e0ec3 100755 --- a/containerization/admin.py +++ b/containerization/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/containerization/apps.py b/containerization/apps.py index 466ee5897..309e75399 100755 --- a/containerization/apps.py +++ b/containerization/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/containerization/container.py b/containerization/container.py index 63bbc2242..cd731ccce 100755 --- a/containerization/container.py +++ b/containerization/container.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import sys sys.path.append('/usr/local/CyberCP') import plogical.CyberCPLogFileWriter as logging @@ -18,12 +18,12 @@ class Container: length = len(Container.users) for items in Container.users: if (counter + 1) == length: - print items + ' ' + Container.packages[counter] + print(items + ' ' + Container.packages[counter]) else: - print items + ' ' + Container.packages[counter] + ' ' + print(items + ' ' + Container.packages[counter] + ' ') counter = counter + 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) @staticmethod @@ -33,12 +33,12 @@ class Container: length = len(Container.users) for items in Container.packages: if (counter + 1) == length: - print items + print(items) else: - print items + '\n' + print(items + '\n') counter = counter + 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) @staticmethod @@ -47,10 +47,10 @@ class Container: counter = 0 for items in Container.users: if items == user: - print Container.packages[counter] + print(Container.packages[counter]) return counter = counter + 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) @staticmethod @@ -59,10 +59,10 @@ class Container: counter = 0 for items in Container.packages: if items == package: - print Container.users[counter] + print(Container.users[counter]) return counter = counter + 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) @staticmethod @@ -88,7 +88,7 @@ class Container: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Packages successfully installed.[200]\n", 1) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1) def main(): diff --git a/containerization/containerManager.py b/containerization/containerManager.py index d419b9435..252b810fc 100755 --- a/containerization/containerManager.py +++ b/containerization/containerManager.py @@ -43,7 +43,7 @@ class ContainerManager(multi.Thread): self.addTrafficController() elif self.function == 'removeLimits': self.removeLimits() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [ContainerManager.run]') @staticmethod @@ -78,7 +78,7 @@ class ContainerManager(multi.Thread): ioConf = ioConf.replace('{net_cls}', str(net_cls)) return ioConf - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -124,11 +124,11 @@ class ContainerManager(multi.Thread): 1) return 0 - execPath = "/usr/local/CyberCP/bin/python2 /usr/local/CyberCP/containerization/container.py" + execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/containerization/container.py" execPath = execPath + " --function submitContainerInstall" ProcessUtilities.outputExecutioner(execPath) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1) def restartServices(self): diff --git a/containerization/models.py b/containerization/models.py index ae33028e0..2d6cc3aef 100755 --- a/containerization/models.py +++ b/containerization/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models from websiteFunctions.models import Websites diff --git a/containerization/tests.py b/containerization/tests.py index 5982e6bcd..f067dcaac 100755 --- a/containerization/tests.py +++ b/containerization/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/containerization/urls.py b/containerization/urls.py index 6fb3ac761..dafc7e031 100755 --- a/containerization/urls.py +++ b/containerization/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^$', views.cHome, name='cHome'), diff --git a/containerization/views.py b/containerization/views.py index a82414868..8b51e43ae 100755 --- a/containerization/views.py +++ b/containerization/views.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import HttpResponse, redirect from loginSystem.views import loadLoginPage -from containerManager import ContainerManager +from .containerManager import ContainerManager import json from websiteFunctions.models import Websites from .models import ContainerLimits @@ -42,7 +42,7 @@ def submitContainerInstall(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -117,7 +117,7 @@ def fetchWebsiteLimits(request): json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -264,7 +264,7 @@ def saveWebsiteLimits(request): json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -333,7 +333,7 @@ def getUsageData(request): finalData['writeRate'] = 0 except: command = "top -b -n 1 -u " + website.externalApp + " | awk 'NR>7 { sum += $9; } END { print sum; }'" - output = str(subprocess.check_output(command, shell=True)) + output = str(subprocess.check_output(command, shell=True).decode("utf-8")) finalData = {} finalData['status'] = 1 @@ -345,7 +345,7 @@ def getUsageData(request): final_json = json.dumps(finalData) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg), 'cpu': 0, 'memory':0} json_data = json.dumps(data_ret) return HttpResponse(json_data) \ No newline at end of file diff --git a/cyberpanel.sh b/cyberpanel.sh index d7d2ef9cf..442bb9384 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -1,7 +1,8 @@ #!/bin/bash #CyberPanel installer script for Ubuntu 18.04 and CentOS 7.X - +DEV="OFF" +BRANCH="stable" POSTFIX_VARIABLE="ON" POWERDNS_VARIABLE="ON" PUREFTPD_VARIABLE="ON" @@ -19,6 +20,101 @@ ADMIN_PASS="1234567" MEMCACHED="ON" REDIS="ON" TOTAL_RAM=$(free -m | awk '/Mem\:/ { print $2 }') +CENTOS_8="False" +WATCHDOG="OFF" + +watchdog_setup() { +if [[ $WATCHDOG == "ON" ]] ; then +wget -O /etc/cyberpanel/watchdog.sh https://$DOWNLOAD_SERVER/misc/watchdog.sh +chmod +x /etc/cyberpanel/watchdog.sh +ln -s /etc/cyberpanel/watchdog.sh /usr/local/bin/watchdog +pid=$(ps aux | grep "watchdog lsws" | grep -v grep | awk '{print $2}') + if [[ "$pid" == "" ]] ; then + nohup watchdog lsws > /dev/null 2>&1 & + fi +echo -e "Checking MariaDB ..." +pid=$(ps aux | grep "watchdog mariadb" | grep -v grep | awk '{print $2}') + if [[ "$pid" == "" ]] ; then + nohup watchdog mariadb > /dev/null 2>&1 & + fi + + if [[ $SERVER_OS == "CentOS" ]] ; then + echo "nohup watchdog lsws > /dev/null 2>&1 & + nohup watchdog mariadb > /dev/null 2>&1 &" >> /etc/rc.d/rc.local + else + echo "nohup watchdog lsws > /dev/null 2>&1 & + nohup watchdog mariadb > /dev/null 2>&1 &" >> /etc/rc.local + fi +echo -e "\n Setting up WatchDog..." +fi +} + +webadmin_passwd() { +if [[ $VERSION == "OLS" ]] ; then +php_command="admin_php" +else +php_command="admin_php5" +fi + +WEBADMIN_PASS=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 ; echo '') +TEMP=`/usr/local/lsws/admin/fcgi-bin/${php_command} /usr/local/lsws/admin/misc/htpasswd.php ${WEBADMIN_PASS}` +echo "" > /usr/local/lsws/admin/conf/htpasswd +echo "admin:$TEMP" > /usr/local/lsws/admin/conf/htpasswd +echo ${WEBADMIN_PASS} > /etc/cyberpanel/webadmin_passwd +} + +check_virtualization() { +echo -e "Checking virtualization type..." +if hostnamectl | grep "Virtualization: lxc" ; then +echo -e "\nLXC detected..." +echo -e "CyberPanel does not support LXC" +echo -e "Exiting..." +exit +fi +} + +license_validation() { +CURRENT_DIR=$(pwd) + +if [ -f /root/cyberpanel-tmp ] ; then +rm -rf /root/cyberpanel-tmp +fi + +mkdir /root/cyberpanel-tmp +cd /root/cyberpanel-tmp +wget -q https://$DOWNLOAD_SERVER/litespeed/lsws-$LSWS_STABLE_VER-ent-x86_64-linux.tar.gz +tar xzvf lsws-$LSWS_STABLE_VER-ent-x86_64-linux.tar.gz > /dev/null +cd /root/cyberpanel-tmp/lsws-$LSWS_STABLE_VER/conf +if [[ $LICENSE_KEY == "TRIAL" ]] ; then +wget -q http://license.litespeedtech.com/reseller/trial.key +sed -i "s|writeSerial = open('lsws-5.4.2/serial.no', 'w')|command = 'wget -q --output-document=./lsws-$LSWS_STABLE_VER/trial.key http://license.litespeedtech.com/reseller/trial.key'|g" $CURRENT_DIR/installCyberPanel.py +sed -i 's|writeSerial.writelines(self.serial)|subprocess.call(command, shell=True)|g' $CURRENT_DIR/installCyberPanel.py +sed -i 's|writeSerial.close()||g' $CURRENT_DIR/installCyberPanel.py +else +echo $LICENSE_KEY > serial.no +fi + +cd /root/cyberpanel-tmp/lsws-$LSWS_STABLE_VER/bin + +if [[ $LICENSE_KEY == "TRIAL" ]] ; then + if ./lshttpd -V |& grep "ERROR" ; then + echo -e "\n\nIt apeears to have some issue with license , please check above result..." + exit + fi + LICENSE_KEY="1111-2222-3333-4444" +else + if ./lshttpd -r |& grep "ERROR" ; then + ./lshttpd -r + echo -e "\n\nIt apeears to have some issue with license , please check above result..." + exit + fi +fi +echo -e "License seems valid..." +cd /root/cyberpanel-tmp +rm -rf lsws-$LSWS_STABLE_VER* +cd $CURRENT_DIR +rm -rf /root/cyberpanel-tmp +} special_change(){ sed -i 's|cyberpanel.sh|'$DOWNLOAD_SERVER'|g' install.py @@ -27,6 +123,35 @@ sed -i 's|git clone https://github.com/usmannasir/cyberpanel|echo downloaded|g' #change to CDN first, regardless country sed -i 's|http://|https://|g' install.py +if ! grep -q "1.1.1.1" /etc/resolv.conf ; then +echo -e "\nnameserver 1.1.1.1" >> /etc/resolv.conf +fi +if ! grep -q "8.8.8.8" /etc/resolv.conf ; then +echo -e "\nnameserver 8.8.8.8" >> /etc/resolv.conf +fi +cp /etc/resolv.conf /etc/resolv.conf-tmp + +line1="$(grep -n "f.write('nameserver 8.8.8.8')" installCyberPanel.py | head -n 1 | cut -d: -f1)" +sed -i "${line1}i\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ subprocess.call(command, shell=True)" installCyberPanel.py +sed -i "${line1}i\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ command = 'cat /etc/resolv.conf-tmp > /etc/resolv.conf'" installCyberPanel.py + +LATEST_URL="https://update.litespeedtech.com/ws/latest.php" +#LATEST_URL="https://cyberpanel.sh/latest.php" +curl --silent -o /tmp/lsws_latest $LATEST_URL 2>/dev/null +LSWS_STABLE_LINE=`cat /tmp/lsws_latest | grep LSWS_STABLE` +LSWS_STABLE_VER=`expr "$LSWS_STABLE_LINE" : '.*LSWS_STABLE=\(.*\) BUILD .*'` + +if [[ $PROVIDER == "Alibaba Cloud" ]] && [[ $SERVER_OS == "Ubuntu" ]] ; then + mkdir /root/.config + mkdir /root/.config/pip + cat << EOF > /root/.config/pip/pip.conf +[global] +index-url = https://mirrors.aliyun.com/pypi/simple/ +EOF + echo -e "\nSet to Aliyun pip repo..." +fi +#seems Alibaba cloud , other than CN , also requires change on ubuntu. + if [[ $SERVER_COUNTRY == "CN" ]] ; then #line1="$(grep -n "github.com/usmannasir/cyberpanel" install.py | head -n 1 | cut -d: -f1)" #line2=$((line1 - 1)) @@ -37,15 +162,18 @@ if [[ $SERVER_COUNTRY == "CN" ]] ; then sed -i 's|wget https://rpms.litespeedtech.com/debian/|wget --no-check-certificate https://rpms.litespeedtech.com/debian/|g' install.py sed -i 's|https://repo.powerdns.com/repo-files/centos-auth-42.repo|https://'$DOWNLOAD_SERVER'/powerdns/powerdns.repo|g' installCyberPanel.py sed -i 's|https://www.rainloop.net/repository/webmail/rainloop-community-latest.zip|https://'$DOWNLOAD_SERVER'/misc/rainloop-community-latest.zip|g' install.py -sed -i 's|cmd.append("rpm")|command = '"'"'curl -o /etc/yum.repos.d/litespeed.repo https://'$DOWNLOAD_SERVER'/litespeed/litespeed.repo'"'"'|g' install.py -sed -i 's|cmd.append("-ivh")|cmd = shlex.split(command)|g' install.py -sed -i 's|cmd.append("https://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm")||g' install.py + +sed -i 's|rpm -ivh https://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm|curl -o /etc/yum.repos.d/litespeed.repo https://'$DOWNLOAD_SERVER'/litespeed/litespeed.repo|g' install.py + + +sed -i 's|https://copr.fedorainfracloud.org/coprs/copart/restic/repo/epel-7/copart-restic-epel-7.repo|https://'$DOWNLOAD_SERVER'/restic/restic.repo|g' install.py + sed -i 's|yum -y install https://cyberpanel.sh/gf-release-latest.gf.el7.noarch.rpm|wget -O /etc/yum.repos.d/gf.repo https://'$DOWNLOAD_SERVER'/gf-plus/gf.repo|g' install.py sed -i 's|dovecot-2.3-latest|dovecot-2.3-latest-mirror|g' install.py sed -i 's|git clone https://github.com/usmannasir/cyberpanel|wget https://cyberpanel.sh/cyberpanel-git.tar.gz \&\& tar xzvf cyberpanel-git.tar.gz|g' install.py sed -i 's|https://repo.dovecot.org/ce-2.3-latest/centos/$releasever/RPMS/$basearch|https://'$DOWNLOAD_SERVER'/dovecot/|g' install.py sed -i 's|'$DOWNLOAD_SERVER'|cyberpanel.sh|g' install.py - +sed -i 's|https://www.litespeedtech.com/packages/5.0/lsws-5.4.2-ent-x86_64-linux.tar.gz|https://'$DOWNLOAD_SERVER'/litespeed/lsws-'$LSWS_STABLE_VER'-ent-x86_64-linux.tar.gz|g' installCyberPanel.py # global change for CN , regardless provider and system if [[ $SERVER_OS == "CentOS" ]] ; then @@ -59,10 +187,11 @@ gpgcheck = 1" > MariaDB.repo #above to set mariadb db to Tsinghua repo cd $DIR sed -i 's|https://www.litespeedtech.com/packages/5.0/lsws-5.3.5-ent-x86_64-linux.tar.gz|https://cyberpanel.sh/packages/5.0/lsws-5.3.5-ent-x86_64-linux.tar.gz|g' installCyberPanel.py - mkdir /root/.pip - cat << EOF > /root/.pip/pip.conf + mkdir /root/.config + mkdir /root/.config/pip + cat << EOF > /root/.config/pip/pip.conf [global] -index-url = https://mirrors.aliyun.com/pypi/simple/ +index-url = https://mirrors.aliyun.com/pypi/simple/ EOF echo -e "\nSet to Aliyun pip repo..." cat << EOF > composer.sh @@ -94,7 +223,7 @@ echo '{ "repositories": { "packagist": { "type": "composer", - "url": "https://packagist.phpcomposer.com" + "url": "https://mirrors.aliyun.com/composer/" } } } @@ -108,9 +237,11 @@ EOF echo $'\n89.208.248.38 rpms.litespeedtech.com\n' >> /etc/hosts echo -e "Mirror server set..." pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ - cat << EOF > /root/.pip/pip.conf + mkdir /root/.config + mkdir /root/.config/pip + cat << EOF > /root/.config/pip/pip.conf [global] -index-url = https://mirrors.aliyun.com/pypi/simple/ +index-url = https://mirrors.aliyun.com/pypi/simple/ EOF echo -e "\nSet to Aliyun pip repo..." if [[ $PROVIDER == "Tencent Cloud" ]] ; then @@ -246,18 +377,23 @@ TOTAL_SWAP=$(free -m | awk '/^Swap:/ { print $2 }') SET_SWAP=$((TOTAL_RAM - TOTAL_SWAP)) SWAP_FILE=/cyberpanel.swap -if [[ ! -f $SWAP_FILE ]] ; then +if [ ! -f $SWAP_FILE ] ; then if [[ $TOTAL_SWAP -gt $TOTAL_RAM ]] || [[ $TOTAL_SWAP -eq $TOTAL_RAM ]] ; then echo "SWAP check..." else - fallocate --length ${SET_SWAP}MiB $SWAP_FILE - chmod 600 $SWAP_FILE - mkswap $SWAP_FILE - swapon $SWAP_FILE - echo "${SWAP_FILE} swap swap sw 0 0" | sudo tee -a /etc/fstab - sysctl vm.swappiness=10 - echo "vm.swappiness = 10" >> /etc/sysctl.conf - echo "SWAP set..." + if [[ $SET_SWAP -gt "2049" ]] ; then + SET_SWAP="2048" + else + echo "Checking SWAP..." + fi + fallocate --length ${SET_SWAP}MiB $SWAP_FILE + chmod 600 $SWAP_FILE + mkswap $SWAP_FILE + swapon $SWAP_FILE + echo "${SWAP_FILE} swap swap sw 0 0" | sudo tee -a /etc/fstab + sysctl vm.swappiness=10 + echo "vm.swappiness = 10" >> /etc/sysctl.conf + echo "SWAP set..." fi fi } @@ -272,45 +408,74 @@ if [[ $SERVER_OS == "CentOS" ]] ; then rpm --import http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7 rpm --import https://$DOWNLOAD_SERVER/gf-plus/RPM-GPG-KEY-gf.el7 rpm --import https://repo.dovecot.org/DOVECOT-REPO-GPG + rpm --import https://copr-be.cloud.fedoraproject.org/results/copart/restic/pubkey.gpg + yum clean all + yum update -y yum autoremove epel-release -y rm -f /etc/yum.repos.d/epel.repo rm -f /etc/yum.repos.d/epel.repo.rpmsave - yum clean all - yum update -y yum install epel-release -y - yum install -y wget htop telnet curl which bc telnet htop libevent-devel gcc python-devel libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel python-pip git + + if [[ $CENTOS_8 == "False" ]] ; then + yum install -y wget strace htop net-tools telnet curl which bc telnet htop libevent-devel gcc python-devel libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel python-pip git + fi + if [[ $CENTOS_8 == "True" ]] ; then + yum install -y wget strace htop net-tools telnet curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel mariadb-devel curl-devel git platform-python-devel tar + dnf --enablerepo=PowerTools install gpgme-devel -y + fi + +if [[ $DEV == "ON" ]] ; then + if [[ $CENTOS_8 == "False" ]] ; then + yum -y install yum-utils + yum -y groupinstall development + yum -y install https://centos7.iuscommunity.org/ius-release.rpm + yum -y install python36u python36u-pip python36u-devel + fi + if [[ $CENTOS_8 == "True" ]] ; then + dnf install python3 -y + fi + pip3.6 install virtualenv + fi fi if [[ $SERVER_OS == "Ubuntu" ]] ; then apt update -y DEBIAN_FRONTEND=noninteractive apt upgrade -y DEBIAN_FRONTEND=noninteracitve apt install -y htop telnet python-mysqldb python-dev libcurl4-gnutls-dev libgnutls28-dev libgcrypt20-dev libattr1 libattr1-dev liblzma-dev libgpgme-dev libmariadbclient-dev libcurl4-gnutls-dev libssl-dev nghttp2 libnghttp2-dev idn2 libidn2-dev libidn2-0-dev librtmp-dev libpsl-dev nettle-dev libgnutls28-dev libldap2-dev libgssapi-krb5-2 libk5crypto3 libkrb5-dev libcomerr2 libldap2-dev python-gpg python python-minimal python-setuptools virtualenv python-dev python-pip git + if [[ $DEV == "ON" ]] ; then + DEBIAN_FRONTEND=noninteractive apt install -y python3-pip + DEBIAN_FRONTEND=noninteractive apt install -y build-essential libssl-dev libffi-dev python3-dev + DEBIAN_FRONTEND=noninteractive apt install -y python3-venv + fi fi } memcached_installation() { if [[ $SERVER_OS == "CentOS" ]] ; then - yum install -y lsphp73-memcached lsphp72-memcached lsphp71-memcached lsphp70-memcached lsphp56-pecl-memcached lsphp55-pecl-memcached lsphp54-pecl-memcached + yum install -y lsphp74-memcached lsphp73-memcached lsphp72-memcached lsphp71-memcached lsphp70-memcached lsphp56-pecl-memcached lsphp55-pecl-memcached lsphp54-pecl-memcached if [[ $TOTAL_RAM -eq "2048" ]] || [[ $TOTAL_RAM -gt "2048" ]] ; then yum groupinstall "Development Tools" -y yum install autoconf automake zlib-devel openssl-devel expat-devel pcre-devel libmemcached-devel cyrus-sasl* -y wget https://$DOWNLOAD_SERVER/litespeed/lsmcd.tar.gz tar xzvf lsmcd.tar.gz - cd lsmcd + DIR=$(pwd) + cd $DIR/lsmcd ./fixtimestamp.sh ./configure CFLAGS=" -O3" CXXFLAGS=" -O3" make make install systemctl enable lsmcd systemctl start lsmcd + cd $DIR else yum install -y memcached + sed -i 's|OPTIONS=""|OPTIONS="-l 127.0.0.1 -U 0"|g' /etc/sysconfig/memcached systemctl enable memcached systemctl start memcached fi fi if [[ $SERVER_OS == "Ubuntu" ]] ; then - DEBIAN_FRONTEND=noninteractive apt install -y lsphp73-memcached lsphp72-memcached lsphp71-memcached lsphp70-memcached + DEBIAN_FRONTEND=noninteractive apt install -y lsphp74-memcached lsphp73-memcached lsphp72-memcached lsphp71-memcached lsphp70-memcached if [[ $TOTAL_RAM -eq "2048" ]] || [[ $TOTAL_RAM -gt "2048" ]] ; then DEBIAN_FRONTEND=noninteractive apt install build-essential zlib1g-dev libexpat1-dev openssl libssl-dev libsasl2-dev libpcre3-dev git -y wget https://$DOWNLOAD/litespeed/lsmcd.tar.gz @@ -343,10 +508,10 @@ fi redis_installation() { if [[ $SERVER_OS == "CentOS" ]] ; then - yum install -y lsphp73-redis lsphp72-redis lsphp71-redis lsphp70-redis lsphp56-redis lsphp55-redis lsphp54-redis redis + yum install -y lsphp74-redis lsphp73-redis lsphp72-redis lsphp71-redis lsphp70-redis lsphp56-redis lsphp55-redis lsphp54-redis redis fi if [[ $SERVER_OS == "Ubuntu" ]] ; then - DEBIAN_FRONTEND=noninteractive apt install -y lsphp73-redis lsphp72-redis lsphp71-redis lsphp70-redis redis + DEBIAN_FRONTEND=noninteractive apt install -y lsphp74-redis lsphp73-redis lsphp72-redis lsphp71-redis lsphp70-redis redis fi if ifconfig -a | grep inet6 ; then @@ -371,23 +536,30 @@ if ps -aux | grep "redis" | grep -v grep ; then fi } -check_provider() -{ -if [ "$(cat /sys/devices/virtual/dmi/id/product_uuid | cut -c 1-3)" = 'EC2' ] && [ -d /home/ubuntu ]; then - PROVIDER='Amazon Web Service' -elif [ "$(dmidecode -s bios-vendor)" = 'Google' ];then - PROVIDER='Google Cloud Platform' -elif [ "$(dmidecode -s bios-vendor)" = 'DigitalOcean' ];then - PROVIDER='Digital Ocean' -elif [ "$(dmidecode -s system-product-name | cut -c 1-7)" = 'Alibaba' ];then - PROVIDER='Alibaba Cloud' -elif [ "$(dmidecode -s system-manufacturer)" = 'Microsoft Corporation' ];then - PROVIDER='Microsoft Azure' -elif [[ -d /usr/local/qcloud ]]; then - PROVIDER='Tencent Cloud' +check_provider() { + +if hash dmidecode > /dev/null 2>&1 ; then + if [ "$(dmidecode -s bios-vendor)" = 'Google' ] ; then + PROVIDER='Google Cloud Platform' + elif [ "$(dmidecode -s bios-vendor)" = 'DigitalOcean' ] ; then + PROVIDER='Digital Ocean' + elif [ "$(dmidecode -s system-product-name | cut -c 1-7)" = 'Alibaba' ] ; then + PROVIDER='Alibaba Cloud' + elif [ "$(dmidecode -s system-manufacturer)" = 'Microsoft Corporation' ] ; then + PROVIDER='Microsoft Azure' + elif [ -d /usr/local/qcloud ] ; then + PROVIDER='Tencent Cloud' + else + PROVIDER='undefined' + fi else - PROVIDER='undefined' + PROVIDER='undefined' fi + +if [ "$(cat /sys/devices/virtual/dmi/id/product_uuid | cut -c 1-3)" = 'EC2' ] && [ -d /home/ubuntu ]; then + PROVIDER='Amazon Web Service' +fi + } @@ -400,18 +572,23 @@ if echo $OUTPUT | grep -q "CentOS Linux 7" ; then elif echo $OUTPUT | grep -q "CloudLinux 7" ; then echo -e "\nDetecting CloudLinux 7.X...\n" SERVER_OS="CentOS" +elif echo $OUTPUT | grep -q "CentOS Linux 8" ; then + echo -e "\nDetecting CentOS 8.X...\n" + SERVER_OS="CentOS" + CENTOS_8="True" elif echo $OUTPUT | grep -q "Ubuntu 18.04" ; then echo -e "\nDetecting Ubuntu 18.04...\n" SERVER_OS="Ubuntu" else + cat /etc/*release echo -e "\nUnable to detect your OS...\n" - echo -e "\nCyberPanel is supported on Ubuntu 18.04, CentOS 7.x and CloudLinux 7.x...\n" + echo -e "\nCyberPanel is supported on Ubuntu 18.04, CentOS 7.x, CentOS 8.x and CloudLinux 7.x...\n" exit 1 fi } check_root() { -echo -e "Checking root privileges...\n" +echo -e "\nChecking root privileges...\n" if [[ $(id -u) != 0 ]] > /dev/null; then echo -e "You must use root account to do this" echo -e "or run following command: (do NOT miss the quotes)" @@ -477,9 +654,9 @@ echo -e "\n This will install everything default , which is OpenLiteSpeed and no license_input() { VERSION="ENT" -SERIAL_NO="--ent ent --serial " echo -e "\nPlease note that your server has \e[31m$TOTAL_RAM\e[39m RAM" echo -e "If you are using \e[31mFree Start\e[39m license, It will not start due to \e[31m2GB RAM limit\e[39m.\n" +echo -e "If you do not have any license, you can also use trial license (if server has not used trial license before), type \e[31mTRIAL\e[39m\n" printf "%s" "Please input your serial number for LiteSpeed WebServer Enterprise:" read LICENSE_KEY @@ -502,23 +679,26 @@ TMP2=$(echo $LICENSE_KEY | cut -c10) TMP3=$(echo $LICENSE_KEY | cut -c15) if [[ $TMP == "-" ]] && [[ $TMP2 == "-" ]] && [[ $TMP3 == "-" ]] && [[ $KEY_SIZE == "19" ]] ; then - echo -e "License key set..." + echo -e "\nLicense key set..." +elif [[ $LICENSE_KEY == "trial" ]] || [[ $LICENSE_KEY == "TRIAL" ]] || [[ $LICENSE_KEY == "Trial" ]] ; then + echo -e "\nTrial license set..." + LICENSE_KEY="TRIAL" else echo -e "\nLicense key seems incorrect, please verify\n" echo -e "\nIf you are copying/pasting, please make sure you didn't paste blank space...\n" exit -fi +fi } interactive_mode() { echo -e " CyberPanel Installer v$CP_VER1$CP_VER2 1. Install CyberPanel. - + 2. Addons and Miscellaneous - + 3. Exit. - + " read -p " Please enter the number[1-3]: " num echo "" @@ -548,14 +728,14 @@ fi echo -e " CyberPanel Addons v$CP_VER1$CP_VER2 1. Install Memcached extension and backend - + 2. Install Redis extension and backend - + 3. Return to main page. - + 4. Exit " - + echo && read -p "Please enter the number[1-4]: " num case "$num" in 1) @@ -584,16 +764,16 @@ DISK=$(df -h | awk '$NF=="/"{printf "%d/%dGB (%s)\n", $3,$2,$5}') #clear echo -e " CyberPanel Installer v$CP_VER1$CP_VER2 - RAM check : $RAM - + RAM check : $RAM + Disk check : $DISK (Minimal \e[31m10GB\e[39m free space) 1. Install CyberPanel with \e[31mOpenLiteSpeed\e[39m. - + 2. Install Cyberpanel with \e[31mLiteSpeed Enterprise\e[39m. - + 3. Exit. - + " read -p " Please enter the number[1-3]: " num echo "" @@ -613,7 +793,7 @@ case "$num" in ;; esac -< /dev/null; then + /usr/local/CyberPanel/bin/python install.py $SERVER_IP $SERIAL_NO $LICENSE_KEY --postfix $POSTFIX_VARIABLE --powerdns $POWERDNS_VARIABLE --ftp $PUREFTPD_VARIABLE + + if grep "CyberPanel installation successfully completed" /var/log/installLogs.txt > /dev/null; then echo -e "\nCyberPanel installation sucessfully completed..." else echo -e "Oops, something went wrong..." @@ -746,12 +983,13 @@ fi } pip_virtualenv() { - +if [[ $DEV == "OFF" ]] ; then if [[ $SERVER_COUNTRY == "CN" ]] ; then - mkdir /root/.pip -cat << EOF > /root/.pip/pip.conf + mkdir /root/.config + mkdir /root/.config/pip + cat << EOF > /root/.config/pip/pip.conf [global] -index-url = https://mirrors.aliyun.com/pypi/simple/ +index-url = https://mirrors.aliyun.com/pypi/simple/ EOF fi @@ -767,6 +1005,23 @@ rm -rf requirements.txt wget -O requirements.txt https://raw.githubusercontent.com/usmannasir/cyberpanel/1.8.0/requirments.txt pip install --ignore-installed -r requirements.txt virtualenv --system-site-packages /usr/local/CyberPanel +fi + +if [[ $DEV == "ON" ]] ; then + #install dev branch + #wget https://raw.githubusercontent.com/usmannasir/cyberpanel/$BRANCH_NAME/requirments.txt + cd /usr/local/ + virtualenv -p /usr/bin/python3 CyberPanel + source /usr/local/CyberPanel/bin/activate + wget -O requirements.txt https://raw.githubusercontent.com/usmannasir/cyberpanel/$BRANCH_NAME/requirments.txt + pip3.6 install --ignore-installed -r requirements.txt + cd - +fi + +if [ -f requirements.txt ] && [ -d cyberpanel ] ; then + rm -rf cyberpanel + rm -f requirements.txt +fi if [[ $SERVER_COUNTRY == "CN" ]] ; then wget https://cyberpanel.sh/cyberpanel-git.tar.gz @@ -774,13 +1029,20 @@ if [[ $SERVER_COUNTRY == "CN" ]] ; then cp -r cyberpanel /usr/local/cyberpanel cd cyberpanel/install else + if [[ $DEV == "ON" ]] ; then + git clone https://github.com/usmannasir/cyberpanel + cd cyberpanel + git checkout $BRANCH_NAME + cd - + cp -r cyberpanel /usr/local/cyberpanel + cd cyberpanel/install + else git clone https://github.com/usmannasir/cyberpanel cp -r cyberpanel /usr/local/cyberpanel cd cyberpanel/install + fi fi - curl https://cyberpanel.sh/?version - } after_install() { @@ -794,13 +1056,33 @@ fi chmod 1733 /var/lib/php/session -if grep "CyberPanel installation successfully completed" /var/log/installLogs.txt > /dev/null; then +if grep "\[ERROR\] We are not able to run ./install.sh return code: 1. Fatal error, see /var/log/installLogs.txt for full details" /var/log/installLogs.txt > /dev/null; then + cd ${DIR}/cyberpanel/install/lsws-* + ./install.sh + echo -e "\n\n\nIt seems LiteSpeed Enterprise has failed to install, please check your license key is valid" + echo -e "\nIf this license key has been used before, you may need to go to store to release it first." + exit +fi -for version in $(ls /usr/local/lsws | grep lsphp); + +if grep "CyberPanel installation successfully completed" /var/log/installLogs.txt > /dev/null; then + +if [[ $DEV == "ON" ]] ; then +virtualenv -p /usr/bin/python3 /usr/local/CyberCP +source /usr/local/CyberCP/bin/activate +wget -O requirements.txt https://raw.githubusercontent.com/usmannasir/cyberpanel/$BRANCH_NAME/requirments.txt +pip3.6 install --ignore-installed -r requirements.txt +systemctl restart lscpd +fi + +for version in $(ls /usr/local/lsws | grep lsphp); do php_ini=$(find /usr/local/lsws/$version/ -name php.ini) version2=${version:5:2} version2=$(awk "BEGIN { print "${version2}/10" }") + if [[ $version2 = "7" ]] ; then + version2="7.0" + fi if [[ $SERVER_OS == "CentOS" ]] ; then yum remove -y $version-mysql yum install -y $version-mysqlnd @@ -808,7 +1090,7 @@ for version in $(ls /usr/local/lsws | grep lsphp); if [[ ! -d /usr/local/lsws/$version/tmp ]] ; then mkdir /usr/local/lsws/$version/tmp fi - /usr/local/lsws/${version}/bin/pecl channel-update pecl.php.net; + /usr/local/lsws/${version}/bin/pecl channel-update pecl.php.net; /usr/local/lsws/${version}/bin/pear config-set temp_dir /usr/local/lsws/${version}/tmp /usr/local/lsws/${version}/bin/pecl install timezonedb echo "extension=timezonedb.so" > /usr/local/lsws/${version}/etc/php.d/20-timezone.ini @@ -816,7 +1098,7 @@ for version in $(ls /usr/local/lsws | grep lsphp); sed -i 's|mail.add_x_header = On|mail.add_x_header = Off|g' $php_ini sed -i 's|;session.save_path = "/tmp"|session.save_path = "/var/lib/php/session"|g' $php_ini fi - + if [[ $SERVER_OS == "Ubuntu" ]] ; then if [[ ! -d /usr/local/lsws/cyberpanel-tmp ]] ; then echo "yes" > /etc/pure-ftpd/conf/ChrootEveryone @@ -824,9 +1106,9 @@ for version in $(ls /usr/local/lsws | grep lsphp); DEBIAN_FRONTEND=noninteractive apt install libmagickwand-dev pkg-config build-essential -y mkdir /usr/local/lsws/cyberpanel-tmp cd /usr/local/lsws/cyberpanel-tmp - wget https://pecl.php.net/get/timezonedb-2019.3.tgz - tar xzvf timezonedb-2019.3.tgz - cd timezonedb-2019.3 + wget -O timezonedb.tgz https://pecl.php.net/get/timezonedb + tar xzvf timezonedb.tgz + cd timezonedb-* fi /usr/local/lsws/${version}/bin/phpize ./configure --with-php-config=/usr/local/lsws/${version}/bin/php-config${version2} @@ -836,9 +1118,7 @@ for version in $(ls /usr/local/lsws | grep lsphp); make clean fi done -sed -i 's|maxConnections 2000|maxConnections 20000|g' /usr/local/lsws/conf/httpd_config.conf -sed -i 's|maxSSLConnections 1000|maxSSLConnections 10000|g' /usr/local/lsws/conf/httpd_config.conf -/usr/local/lsws/bin/lswsctrl restart + rm -rf /etc/profile.d/cyberpanel* curl --silent -o /etc/profile.d/cyberpanel.sh https://cyberpanel.sh/?banner 2>/dev/null chmod +x /etc/profile.d/cyberpanel.sh @@ -847,22 +1127,46 @@ DISK2=$(df -h | awk '$NF=="/"{printf "%d/%dGB (%s)\n", $3,$2,$5}') ELAPSED="$(($SECONDS / 3600)) hrs $((($SECONDS / 60) % 60)) min $(($SECONDS % 60)) sec" MYSQLPASSWD=$(cat /etc/cyberpanel/mysqlPassword) echo "$ADMIN_PASS" > /etc/cyberpanel/adminPass -/usr/local/CyberPanel/bin/python2 /usr/local/CyberCP/plogical/adminPass.py --password $ADMIN_PASS +/usr/local/CyberPanel/bin/python /usr/local/CyberCP/plogical/adminPass.py --password $ADMIN_PASS +mkdir -p /etc/opendkim systemctl restart lscpd systemctl restart lsws -echo "/usr/local/CyberPanel/bin/python2 /usr/local/CyberCP/plogical/adminPass.py --password \$@" > /usr/bin/adminPass +echo "/usr/local/CyberPanel/bin/python /usr/local/CyberCP/plogical/adminPass.py --password \$@" > /usr/bin/adminPass echo "systemctl restart lscpd" >> /usr/bin/adminPass chmod +x /usr/bin/adminPass if [[ $VERSION = "OLS" ]] ; then WORD="OpenLiteSpeed" +# sed -i 's|maxConnections 10000|maxConnections 100000|g' /usr/local/lsws/conf/httpd_config.conf +# OLS_LATEST=$(curl https://openlitespeed.org/packages/release) +# wget https://openlitespeed.org/packages/openlitespeed-$OLS_LATEST.tgz +# tar xzvf openlitespeed-$OLS_LATEST.tgz +# cd openlitespeed +# ./install.sh + /usr/local/lsws/bin/lswsctrl stop + /usr/local/lsws/bin/lswsctrl start +# rm -f openlitespeed-$OLS_LATEST.tgz +# rm -rf openlitespeed +# cd .. fi if [[ $VERSION = "ENT" ]] ; then WORD="LiteSpeed Enterprise" if [[ $SERVER_COUNTRY != "CN" ]] ; then - LSWS_VER=$(curl -s http://update.litespeedtech.com/ws/latest.php | grep LSWS | sed 's/LSWS=//' | head -n 1) - /usr/local/lsws/admin/misc/lsup.sh -f -v ${LSWS_VER} + /usr/local/lsws/admin/misc/lsup.sh -f -v $LSWS_STABLE_VER fi fi + +systemctl status lsws 2>&1>/dev/null +if [[ $? == "0" ]] ; then + echo "LSWS service is running..." +else + systemctl stop lsws + systemctl start lsws +fi + +webadmin_passwd + +watchdog_setup + clear echo "###################################################################" echo " CyberPanel Successfully Installed " @@ -875,9 +1179,9 @@ echo " Installation time : $ELAPSED " echo " " echo " Visit: https://$SERVER_IP:8090 " echo " Panel username: admin " -echo " Panel password: $ADMIN_PASS " -#echo " Mysql username: root " -#echo " Mysql password: $MYSQLPASSWD " +echo " Panel password: $ADMIN_PASS " +echo " WebAdmin console username: admin " +echo " WebAdmin console password: $WEBADMIN_PASS " echo " " echo " Please change your default admin password " echo " If you need to reset your panel password, please run: " @@ -908,7 +1212,7 @@ fi if [[ $SERVER_COUNTRY = CN ]] ; then if [[ $PROVIDER == "Tencent Cloud" ]] ; then if [[ $SERVER_OS == "Ubuntu" ]] ; then - rm -f /etc/apt/sources.list + rm -f /etc/apt/sources.list mv /etc/apt/sources.list-backup /etc/apt/sources.list echo > "nameserver 127.0.0.53 options edns0" /run/systemd/resolve/stub-resolv.conf @@ -921,9 +1225,18 @@ options edns0" /etc/resolv.conf if [[ $VERSION = "ENT" ]] ; then sed -i 's|https://www.litespeedtech.com/packages/5.0/lsws-5.3.5-ent-x86_64-linux.tar.gz|https://cyberpanel.sh/packages/5.0/lsws-5.3.5-ent-x86_64-linux.tar.gz|g' /usr/local/CyberCP/install/installCyberPanel.py sed -i 's|https://www.litespeedtech.com/packages/5.0/lsws-5.3.8-ent-x86_64-linux.tar.gz|https://cyberpanel.sh/packages/5.0/lsws-5.3.8-ent-x86_64-linux.tar.gz|g' /usr/local/CyberCP/serverStatus/serverStatusUtil.py + sed -i 's|https://www.litespeedtech.com/packages/5.0/lsws-5.3.8-ent-x86_64-linux.tar.gz|https://'$DOWNLOAD_SERVER'/litespeed/lsws-'$LSWS_STABLE_VER'-ent-x86_64-linux.tar.gz|g' /usr/local/CyberCP/serverStatus/serverStatusUtil.py echo -e "If you have install LiteSpeed Enterprise, please run \e[31m/usr/local/lsws/admin/misc/lsup.sh\033[39m to update it to latest." fi fi + +sed -i 's|lsws-5.3.8|lsws-'$LSWS_STABLE_VER'|g' /usr/local/CyberCP/serverStatus/serverStatusUtil.py +sed -i 's|lsws-5.4.2|lsws-'$LSWS_STABLE_VER'|g' /usr/local/CyberCP/serverStatus/serverStatusUtil.py +sed -i 's|lsws-5.3.5|lsws-'$LSWS_STABLE_VER'|g' /usr/local/CyberCP/serverStatus/serverStatusUtil.py + +sed -i 's|NoAnonymous no|NoAnonymous yes|g' /etc/pure-ftpd/pure-ftpd.conf + + if [[ $SILENT != "ON" ]] ; then printf "%s" "Would you like to restart your server now? [y/N]: " read TMP_YN @@ -953,10 +1266,15 @@ TMP=$(echo $VERSION | cut -c5) TMP2=$(echo $VERSION | cut -c10) TMP3=$(echo $VERSION | cut -c15) if [[ $VERSION == "OLS" || $VERSION == "ols" ]] ; then - VERSION=OLS + VERSION="OLS" echo -e "\nSet to OpenLiteSpeed..." +elif [[ $VERSION == "Trial" ]] || [[ $VERSION == "TRIAL" ]] || [[ $VERSION == "trial" ]] ; then + VERSION="ENT" + LICENSE_KEY="TRIAL" + echo -e "\nLiteSpeed Enterprise trial license set..." elif [[ $TMP == "-" ]] && [[ $TMP2 == "-" ]] && [[ $TMP3 == "-" ]] && [[ $KEY_SIZE == "19" ]] ; then LICENSE_KEY=$VERSION + VERSION="ENT" echo -e "\nLiteSpeed Enterprise license key set..." else echo -e "\nCan not recognize the input value \e[31m$VERSION\e[39m " @@ -975,7 +1293,6 @@ elif [[ $ADMIN_PASS == "r" ]] ; then echo -e "\nAdmin password will be set to \e[31m$ADMIN_PASS\e[39m" echo $ADMIN_PASS else - echo -e "\nManual input password..." echo -e "\nAdmin password will be set to \e[31m$ADMIN_PASS\e[39m" fi } @@ -985,6 +1302,11 @@ if [ $# -eq 0 ] ; then else if [[ $1 == "help" ]] ; then show_help + exit + elif [[ $1 == "dev" ]] ; then + DEV="ON" + DEV_ARG="ON" + SILENT="OFF" elif [[ $1 == "default" ]] ; then echo -e "\nThis will start default installation...\n" SILENT="ON" @@ -1045,7 +1367,7 @@ fi -SERVER_IP=$(curl --silent --max-time 5 -4 https://cyberpanel.sh/?ip) +SERVER_IP=$(curl --silent --max-time 10 -4 https://cyberpanel.sh/?ip) if [[ $SERVER_IP =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo -e "Valid IP detected..." else @@ -1065,10 +1387,11 @@ fi if [[ $SERVER_COUNTRY == "CN" ]] ; then DOWNLOAD_SERVER="cyberpanel.sh" else -DOWNLOAD_SERVER="cyberpanelsh.b-cdn.net" +DOWNLOAD_SERVER="cdn.cyberpanel.sh" fi check_OS +check_virtualization check_root check_panel check_process @@ -1092,5 +1415,3 @@ pip_virtualenv system_tweak main_install - - diff --git a/databases/admin.py b/databases/admin.py index 742c34400..1db91e378 100755 --- a/databases/admin.py +++ b/databases/admin.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin -import models +from . import models # Register your models here. diff --git a/databases/apps.py b/databases/apps.py index d0b728055..1e9ba9649 100755 --- a/databases/apps.py +++ b/databases/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/databases/databaseManager.py b/databases/databaseManager.py index 721129317..52ec9aad3 100755 --- a/databases/databaseManager.py +++ b/databases/databaseManager.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os.path import sys import django @@ -22,13 +22,13 @@ class DatabaseManager: def loadDatabaseHome(self, request = None, userID = None): try: return render(request, 'databases/index.html') - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def phpMyAdmin(self, request = None, userID = None): try: return render(request, 'databases/phpMyAdmin.html') - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def createDatabase(self, request = None, userID = None): @@ -40,7 +40,7 @@ class DatabaseManager: websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'databases/createDatabase.html', {'websitesList': websitesName}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def submitDBCreation(self, userID = None, data = None, rAPI = None): @@ -76,7 +76,7 @@ class DatabaseManager: data_ret = {'status': 0, 'createDBStatus': 0, 'error_message': result[1]} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'createDBStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -91,7 +91,7 @@ class DatabaseManager: websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'databases/deleteDatabase.html', {'websitesList': websitesName}) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse(str(msg)) @@ -132,7 +132,7 @@ class DatabaseManager: final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) final_json = json.dumps({'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}) return HttpResponse(final_json) @@ -163,7 +163,7 @@ class DatabaseManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'deleteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -177,7 +177,7 @@ class DatabaseManager: websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'databases/listDataBases.html', {'websiteList': websitesName}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def changePassword(self, userID = None, data = None): @@ -210,7 +210,7 @@ class DatabaseManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'changePasswordStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -238,10 +238,10 @@ class DatabaseManager: for db in webs.databases_set.all(): mysqlUtilities.allowGlobalUserAccess(admin.userName, db.dbName) - print "1," + finalUserPassword + print("1," + finalUserPassword) - except BaseException, msg: - print "0," + str(msg) + except BaseException as msg: + print("0," + str(msg)) def main(): diff --git a/databases/models.py b/databases/models.py index 73fc909c4..c6c117d81 100755 --- a/databases/models.py +++ b/databases/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models from websiteFunctions.models import Websites @@ -7,6 +7,6 @@ from websiteFunctions.models import Websites # Create your models here. class Databases(models.Model): - website = models.ForeignKey(Websites) + website = models.ForeignKey(Websites, on_delete=models.CASCADE) dbName = models.CharField(max_length=50,unique=True) dbUser = models.CharField(max_length=50) diff --git a/databases/pluginManager.py b/databases/pluginManager.py index 81e7d9f71..1e89c0872 100755 --- a/databases/pluginManager.py +++ b/databases/pluginManager.py @@ -1,4 +1,4 @@ -from signals import * +from .signals import * from plogical.pluginManagerGlobal import pluginManagerGlobal class pluginManager: diff --git a/databases/tests.py b/databases/tests.py index 0a0cddb81..70b95a818 100755 --- a/databases/tests.py +++ b/databases/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase import json diff --git a/databases/urls.py b/databases/urls.py index 3ef288986..64633b886 100755 --- a/databases/urls.py +++ b/databases/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^$', views.loadDatabaseHome, name='loadDatabaseHome'), diff --git a/databases/views.py b/databases/views.py index 853198776..3b8eeb493 100755 --- a/databases/views.py +++ b/databases/views.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import redirect, HttpResponse from loginSystem.views import loadLoginPage -from databaseManager import DatabaseManager -from pluginManager import pluginManager +from .databaseManager import DatabaseManager +from .pluginManager import pluginManager import json from plogical.processUtilities import ProcessUtilities from loginSystem.models import Administrator @@ -134,7 +134,7 @@ def setupPHPMYAdminSession(request): userID = request.session['userID'] admin = Administrator.objects.get(id = userID) - execPath = "/usr/local/CyberCP/bin/python2 /usr/local/CyberCP/databases/databaseManager.py" + execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/databases/databaseManager.py" execPath = execPath + " generatePHPMYAdminData --userID " + str(userID) output = ProcessUtilities.outputExecutioner(execPath) @@ -151,7 +151,7 @@ def setupPHPMYAdminSession(request): return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'createDBStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) diff --git a/dns/admin.py b/dns/admin.py index 9962ad720..d799d78c4 100755 --- a/dns/admin.py +++ b/dns/admin.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals -import models + +from . import models from django.contrib import admin admin.site.register(models.Domains) diff --git a/dns/apps.py b/dns/apps.py index 7974ec10b..84a08ccdd 100755 --- a/dns/apps.py +++ b/dns/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/dns/dnsManager.py b/dns/dnsManager.py index 180a705ca..dee0e03b2 100755 --- a/dns/dnsManager.py +++ b/dns/dnsManager.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os.path import sys import django @@ -11,7 +11,7 @@ import json from plogical.dnsUtilities import DNS from loginSystem.models import Administrator import os -from models import Domains,Records +from .models import Domains,Records from re import match,I,M from plogical.mailUtilities import mailUtilities from plogical.acl import ACLManager @@ -24,7 +24,7 @@ class DNSManager: try: admin = Administrator.objects.get(pk=userID) return render(request, 'dns/index.html', {"type": admin.type}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def createNameserver(self, request = None, userID = None): @@ -40,7 +40,7 @@ class DNSManager: else: return render(request, "dns/createNameServer.html", {"status": 0}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def NSCreation(self, userID = None, data = None): @@ -94,7 +94,7 @@ class DNSManager: return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'NSCreation': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -109,7 +109,7 @@ class DNSManager: return render(request, 'dns/createDNSZone.html', {"status": 1}) else: return render(request, 'dns/createDNSZone.html', {"status": 0}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def zoneCreation(self, userID = None, data = None): @@ -142,7 +142,7 @@ class DNSManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'zoneCreation': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -161,7 +161,7 @@ class DNSManager: return render(request, 'dns/addDeleteDNSRecords.html', {"domainsList": domainsList, "status": 1}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def getCurrentRecordsForDomain(self, userID = None, data = None): @@ -233,7 +233,7 @@ class DNSManager: final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -406,7 +406,7 @@ class DNSManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'add_status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -436,7 +436,7 @@ class DNSManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'delete_status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -456,7 +456,7 @@ class DNSManager: return render(request, 'dns/deleteDNSZone.html', {"domainsList": domainsList, "status": 1}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def submitZoneDeletion(self, userID = None, data = None): @@ -486,7 +486,7 @@ class DNSManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'delete_status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -529,7 +529,7 @@ class DNSManager: return render(request, 'dns/configureDefaultNameServers.html', data) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) @@ -568,7 +568,7 @@ class DNSManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) \ No newline at end of file diff --git a/dns/models.py b/dns/models.py index c8b4e27ba..c926566db 100755 --- a/dns/models.py +++ b/dns/models.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals + from django.db import models from loginSystem.models import Administrator diff --git a/dns/pluginManager.py b/dns/pluginManager.py index 17e477533..9d52edeb9 100755 --- a/dns/pluginManager.py +++ b/dns/pluginManager.py @@ -1,4 +1,4 @@ -from signals import * +from .signals import * from plogical.pluginManagerGlobal import pluginManagerGlobal class pluginManager: diff --git a/dns/tests.py b/dns/tests.py index 5982e6bcd..f067dcaac 100755 --- a/dns/tests.py +++ b/dns/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/dns/urls.py b/dns/urls.py index e1ffd4b66..3f6059006 100755 --- a/dns/urls.py +++ b/dns/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^$', views.loadDNSHome, name='dnsHome'), diff --git a/dns/views.py b/dns/views.py index 9c2608ae6..b391ab16f 100755 --- a/dns/views.py +++ b/dns/views.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import redirect from loginSystem.views import loadLoginPage -from dnsManager import DNSManager -from pluginManager import pluginManager +from .dnsManager import DNSManager +from .pluginManager import pluginManager import json # Create your views here. diff --git a/dockerManager/admin.py b/dockerManager/admin.py index 13be29d96..4c33e0ec3 100755 --- a/dockerManager/admin.py +++ b/dockerManager/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/dockerManager/apps.py b/dockerManager/apps.py index b8b50bdb2..428bfbf77 100755 --- a/dockerManager/apps.py +++ b/dockerManager/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/dockerManager/container.py b/dockerManager/container.py index 6a5606848..65fb3d787 100755 --- a/dockerManager/container.py +++ b/dockerManager/container.py @@ -1,5 +1,5 @@ -#!/usr/local/CyberCP/bin/python2 -from __future__ import division +#!/usr/local/CyberCP/bin/python + import os import os.path import sys @@ -57,7 +57,7 @@ class ContainerManager(multi.Thread): elif self.function == 'restartGunicorn': command = 'sudo systemctl restart gunicorn.socket' ProcessUtilities.executioner(command) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + ' [ContainerManager.run]') @staticmethod @@ -68,7 +68,7 @@ class ContainerManager(multi.Thread): return 0 else: return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -82,12 +82,12 @@ class ContainerManager(multi.Thread): writeToFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w') writeToFile.close() - execPath = "/usr/local/CyberCP/bin/python2 /usr/local/CyberCP/dockerManager/dockerInstall.py" + execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/dockerManager/dockerInstall.py" ProcessUtilities.executioner(execPath) time.sleep(2) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1) def createContainer(self, request=None, userID=None, data=None): @@ -123,7 +123,7 @@ class ContainerManager(multi.Thread): for item in inspectImage['Config']['Env']: if '=' in item: splitedItem = item.split('=', 1) - print splitedItem + print(splitedItem) envList[splitedItem[0]] = splitedItem[1] else: envList[item] = "" @@ -142,7 +142,7 @@ class ContainerManager(multi.Thread): return render(request, 'dockerManager/runContainer.html', Data) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def loadContainerHome(self, request=None, userID=None, data=None): @@ -239,7 +239,7 @@ class ContainerManager(multi.Thread): "unlistedContainers": unlistedContainers, "adminNames": adminNames, "showUnlistedContainer": showUnlistedContainer}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def getContainerLogs(self, userID=None, data=None): @@ -255,14 +255,14 @@ class ContainerManager(multi.Thread): dockerAPI = docker.APIClient() container = client.containers.get(name) - logs = container.logs() + logs = container.logs().decode("utf-8") data_ret = {'containerLogStatus': 1, 'containerLog': logs, 'error_message': "None"} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'containerLogStatus': 0, 'containerLog': 'Error', 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -290,7 +290,7 @@ class ContainerManager(multi.Thread): # Formatting envList for usage envDict = {} - for key, value in envList.iteritems(): + for key, value in envList.items(): if (value['name'] != '') or (value['value'] != ''): envDict[value['name']] = value['value'] @@ -304,7 +304,7 @@ class ContainerManager(multi.Thread): portConfig[item] = data[item] volumes = {} - for index, volume in volList.iteritems(): + for index, volume in volList.items(): volumes[volume['src']] = {'bind': volume['dest'], 'mode': 'rw'} @@ -325,7 +325,7 @@ class ContainerManager(multi.Thread): container = client.containers.create(**containerArgs) except Exception as err: if "port is already allocated" in err: # We need to delete container if port is not available - print "Deleting container" + print("Deleting container") container.remove(force=True) data_ret = {'createContainerStatus': 0, 'error_message': str(err)} json_data = json.dumps(data_ret) @@ -348,7 +348,7 @@ class ContainerManager(multi.Thread): return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'createContainerStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -376,7 +376,7 @@ class ContainerManager(multi.Thread): try: image = client.images.pull(image, tag=tag) - print image.id + print(image.id) except docker.errors.APIError as msg: data_ret = {'installImageStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) @@ -387,7 +387,7 @@ class ContainerManager(multi.Thread): return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'installImageStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -457,7 +457,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: if called: return str(msg) else: @@ -477,7 +477,7 @@ class ContainerManager(multi.Thread): final_dic = {'listContainerStatus': 1, 'error_message': "None", "data": json_data} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: dic = {'listContainerStatus': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -551,7 +551,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'containerActionStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -581,7 +581,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'containerStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -611,7 +611,7 @@ class ContainerManager(multi.Thread): response['Content-Disposition'] = 'attachment; filename="' + name + '.tar"' return response - except BaseException, msg: + except BaseException as msg: data_ret = {'containerStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -647,7 +647,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'containerTopStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -688,7 +688,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'assignContainerStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -714,7 +714,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - print json.dumps(matches) + print(json.dumps(matches)) for image in matches: if "/" in image['name']: @@ -726,7 +726,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'searchImageStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -763,7 +763,7 @@ class ContainerManager(multi.Thread): getTag = tag.split(":") if len(getTag) == 2: tags.append(getTag[1]) - print tags + print(tags) if name in names: images[name]['tags'].extend(tags) else: @@ -776,7 +776,7 @@ class ContainerManager(multi.Thread): return render(request, 'dockerManager/images.html', {"images": images, "test": ''}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def manageImages(self, request=None, userID=None, data=None): @@ -810,7 +810,7 @@ class ContainerManager(multi.Thread): return render(request, 'dockerManager/manageImages.html', {"images": images}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def getImageHistory(self, userID=None, data=None): @@ -836,7 +836,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'imageHistoryStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -857,7 +857,7 @@ class ContainerManager(multi.Thread): action = client.images.prune() else: action = client.images.remove(name) - print action + print(action) except docker.errors.APIError as err: data_ret = {'removeImageStatus': 0, 'error_message': str(err)} json_data = json.dumps(data_ret) @@ -871,7 +871,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'removeImageStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -917,7 +917,7 @@ class ContainerManager(multi.Thread): con.save() return 0 - except BaseException, msg: + except BaseException as msg: return str(msg) def saveContainerSettings(self, userID=None, data=None): @@ -967,12 +967,12 @@ class ContainerManager(multi.Thread): if 'envConfirmation' in data and data['envConfirmation']: # Formatting envList for usage envDict = {} - for key, value in envList.iteritems(): + for key, value in envList.items(): if (value['name'] != '') or (value['value'] != ''): envDict[value['name']] = value['value'] volumes = {} - for index, volume in volList.iteritems(): + for index, volume in volList.items(): if volume['src'] == '' or volume['dest'] == '': continue volumes[volume['src']] = {'bind': volume['dest'], @@ -1003,7 +1003,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'saveSettingsStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1053,7 +1053,7 @@ class ContainerManager(multi.Thread): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'recreateContainerStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1073,7 +1073,7 @@ class ContainerManager(multi.Thread): else: image2 = "library/" + image - print image + print(image) registryData = requests.get('https://registry.hub.docker.com/v2/repositories/' + image2 + '/tags', {'page': page}).json() @@ -1084,7 +1084,7 @@ class ContainerManager(multi.Thread): data_ret = {'getTagsStatus': 1, 'list': tagList, 'next': registryData['next'], 'error_message': None} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'getTagsStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) \ No newline at end of file diff --git a/dockerManager/decorators.py b/dockerManager/decorators.py index bd06190c7..74645d2de 100755 --- a/dockerManager/decorators.py +++ b/dockerManager/decorators.py @@ -38,7 +38,7 @@ def preDockerRun(function): try: client = docker.from_env() client.ping() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) if isPost: data_ret = {'status': 0, 'error_message': 'Docker daemon not running or not responsive'} diff --git a/dockerManager/dockerInstall.py b/dockerManager/dockerInstall.py index 66d6ce51f..8b5220169 100755 --- a/dockerManager/dockerInstall.py +++ b/dockerManager/dockerInstall.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import sys sys.path.append('/usr/local/CyberCP') import plogical.CyberCPLogFileWriter as logging @@ -39,7 +39,7 @@ class DockerInstall: time.sleep(2) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1) DockerInstall.submitInstallDocker() \ No newline at end of file diff --git a/dockerManager/models.py b/dockerManager/models.py index 75d7328bc..f1b895c95 100755 --- a/dockerManager/models.py +++ b/dockerManager/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models from loginSystem.models import Administrator @@ -8,7 +8,7 @@ from loginSystem.models import Administrator class Containers(models.Model): name = models.CharField(max_length=50,unique=True) cid = models.CharField(max_length=64, default='') - admin = models.ForeignKey(Administrator) + admin = models.ForeignKey(Administrator, on_delete=models.CASCADE) image = models.CharField(max_length=50, default='unknown') tag = models.CharField(max_length=50, default='unknown') memory = models.IntegerField(default=0) diff --git a/dockerManager/pluginManager.py b/dockerManager/pluginManager.py index 60a64e7ca..26dca3274 100755 --- a/dockerManager/pluginManager.py +++ b/dockerManager/pluginManager.py @@ -1,4 +1,4 @@ -from signals import * +from .signals import * from plogical.pluginManagerGlobal import pluginManagerGlobal class pluginManager: diff --git a/dockerManager/tests.py b/dockerManager/tests.py index 5982e6bcd..f067dcaac 100755 --- a/dockerManager/tests.py +++ b/dockerManager/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/dockerManager/urls.py b/dockerManager/urls.py index 0bb5ca064..64209963e 100755 --- a/dockerManager/urls.py +++ b/dockerManager/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^$', views.loadDockerHome, name='dockerHome'), diff --git a/dockerManager/views.py b/dockerManager/views.py index fed61d06b..976b27206 100755 --- a/dockerManager/views.py +++ b/dockerManager/views.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render, redirect, HttpResponse from loginSystem.models import Administrator from loginSystem.views import loadLoginPage from .container import ContainerManager -from decorators import preDockerRun +from .decorators import preDockerRun from plogical.acl import ACLManager import json @@ -48,7 +48,7 @@ def installDocker(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) diff --git a/emailMarketing/admin.py b/emailMarketing/admin.py index 13be29d96..4c33e0ec3 100755 --- a/emailMarketing/admin.py +++ b/emailMarketing/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/emailMarketing/apps.py b/emailMarketing/apps.py index dafe02fc4..6de896393 100755 --- a/emailMarketing/apps.py +++ b/emailMarketing/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig @@ -7,4 +7,4 @@ from django.apps import AppConfig class EmailmarketingConfig(AppConfig): name = 'emailMarketing' def ready(self): - import signals + from . import signals diff --git a/emailMarketing/emailMarketing.py b/emailMarketing/emailMarketing.py index ba9d1b9a4..7d0a88548 100755 --- a/emailMarketing/emailMarketing.py +++ b/emailMarketing/emailMarketing.py @@ -1,17 +1,16 @@ -#!/usr/local/CyberCP/bin/python2 -from __future__ import absolute_import +#!/usr/local/CyberCP/bin/python + import os import time import csv import re import plogical.CyberCPLogFileWriter as logging -from emailMarketing.models import EmailMarketing, EmailLists, EmailsInList, EmailTemplate, EmailJobs, SMTPHosts +from .models import EmailMarketing, EmailLists, EmailsInList, EmailTemplate, EmailJobs, SMTPHosts from websiteFunctions.models import Websites import threading as multi import socket, smtplib import DNS from random import randint -import subprocess, shlex from plogical.processUtilities import ProcessUtilities class emailMarketing(multi.Thread): @@ -28,7 +27,7 @@ class emailMarketing(multi.Thread): self.verificationJob() elif self.function == 'startEmailJob': self.startEmailJob() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [emailMarketing.run]') def createEmailList(self): @@ -58,7 +57,7 @@ class emailMarketing(multi.Thread): newEmail.save() logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], str(counter) + ' emails read.') counter = counter + 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) continue elif self.extraArgs['path'].endswith('.txt'): @@ -69,7 +68,7 @@ class emailMarketing(multi.Thread): if re.match('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$', email) != None: try: getEmail = EmailsInList.objects.get(owner=newList, email=email) - except BaseException, msg: + except BaseException as msg: newEmail = EmailsInList(owner=newList, email=email, verificationStatus='NOT CHECKED', dateCreated=time.strftime("%I-%M-%S-%a-%b-%Y")) newEmail.save() @@ -78,7 +77,7 @@ class emailMarketing(multi.Thread): emails = emailsList.readline() logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], str(counter) + 'Successfully read all emails. [200]') - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], str(msg) +'. [404]') return 0 @@ -132,14 +131,14 @@ class emailMarketing(multi.Thread): logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, str(counter) + ' emails verified so far..') counter = counter + 1 - except BaseException, msg: + except BaseException as msg: items.verificationStatus = 'Verification Failed' items.save() counter = counter + 1 logging.CyberCPLogFileWriter.writeToFile(str(msg)) logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, str(counter) + ' emails successfully verified. [200]') - except BaseException, msg: + except BaseException as msg: verificationList = EmailLists.objects.get(listName=self.extraArgs['listName']) domain = verificationList.owner.domain tempStatusPath = '/home/cyberpanel/' + domain + "/" + self.extraArgs['listName'] @@ -235,7 +234,7 @@ class emailMarketing(multi.Thread): logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Successfully sent: ' + str(sent) + ' Failed: ' + str( failed)) - except BaseException, msg: + except BaseException as msg: failed = failed + 1 logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Successfully sent: ' + str( @@ -250,6 +249,6 @@ class emailMarketing(multi.Thread): logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Email job completed. [200]') - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], str(msg) + '. [404]') return 0 \ No newline at end of file diff --git a/emailMarketing/emailMarketingManager.py b/emailMarketing/emailMarketingManager.py index 53f2f8d56..41e98f006 100755 --- a/emailMarketing/emailMarketingManager.py +++ b/emailMarketing/emailMarketingManager.py @@ -6,12 +6,12 @@ from random import randint import time from .models import EmailMarketing, EmailLists, EmailsInList, EmailJobs from websiteFunctions.models import Websites -from emailMarketing import emailMarketing as EM +from .emailMarketing import emailMarketing as EM from math import ceil import smtplib from .models import SMTPHosts, EmailTemplate from loginSystem.models import Administrator -from emACL import emACL +from .emACL import emACL class EmailMarketingManager: @@ -30,7 +30,7 @@ class EmailMarketingManager: return ACLManager.loadError() return render(self.request, 'emailMarketing/emailMarketing.html') - except KeyError, msg: + except KeyError as msg: return redirect(loadLoginPage) def fetchUsers(self): @@ -74,7 +74,7 @@ class EmailMarketingManager: data_ret = {"status": 1, 'data': json_data} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -103,7 +103,7 @@ class EmailMarketingManager: data_ret = {"status": 1} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -123,7 +123,7 @@ class EmailMarketingManager: return ACLManager.loadError() return render(self.request, 'emailMarketing/createEmailList.html', {'domain': self.domain}) - except KeyError, msg: + except KeyError as msg: return redirect(loadLoginPage) def submitEmailList(self): @@ -157,7 +157,7 @@ class EmailMarketingManager: data_ret = {"status": 1, 'tempStatusPath': extraArgs['tempStatusPath']} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -178,7 +178,7 @@ class EmailMarketingManager: listNames = emACL.getEmailsLists(self.domain) return render(self.request, 'emailMarketing/manageLists.html', {'listNames': listNames, 'domain': self.domain}) - except KeyError, msg: + except KeyError as msg: return redirect(loadLoginPage) def fetchEmails(self): @@ -251,7 +251,7 @@ class EmailMarketingManager: data_ret = {"status": 1, 'data': json_data, 'pagination': pagination} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -281,7 +281,7 @@ class EmailMarketingManager: data_ret = {"status": 1} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -314,7 +314,7 @@ class EmailMarketingManager: data_ret = {"status": 1} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -344,7 +344,7 @@ class EmailMarketingManager: data_ret = {"status": 1} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -370,7 +370,7 @@ class EmailMarketingManager: for items in emailLists: listNames.append(items.listName) return render(self.request, 'emailMarketing/manageSMTPHosts.html', {'listNames': listNames, 'domain': self.domain}) - except KeyError, msg: + except KeyError as msg: return redirect(loadLoginPage) def saveSMTPHost(self): @@ -420,7 +420,7 @@ class EmailMarketingManager: data_ret = {"status": 1} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -463,7 +463,7 @@ class EmailMarketingManager: data_ret = {"status": 1, 'data': json_data} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -515,7 +515,7 @@ class EmailMarketingManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -529,7 +529,7 @@ class EmailMarketingManager: return ACLManager.loadErrorJson() return render(self.request, 'emailMarketing/composeMessages.html') - except KeyError, msg: + except KeyError as msg: return redirect(loadLoginPage) def saveEmailTemplate(self): @@ -557,7 +557,7 @@ class EmailMarketingManager: data_ret = {"status": 1} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -581,7 +581,7 @@ class EmailMarketingManager: Data['hostNames'] = hostNames Data['listNames'] = listNames return render(self.request, 'emailMarketing/sendEmails.html', Data) - except KeyError, msg: + except KeyError as msg: return redirect(loadLoginPage) def templatePreview(self): @@ -597,7 +597,7 @@ class EmailMarketingManager: return ACLManager.loadError() return HttpResponse(template.emailMessage) - except KeyError, msg: + except KeyError as msg: return redirect(loadLoginPage) def fetchJobs(self): @@ -647,7 +647,7 @@ class EmailMarketingManager: data_ret = {"status": 1, 'data': json_data} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -689,7 +689,7 @@ class EmailMarketingManager: data_ret = {"status": 1, 'tempStatusPath': extraArgs['tempStatusPath']} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -714,7 +714,7 @@ class EmailMarketingManager: data_ret = {"status": 1} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -734,7 +734,7 @@ class EmailMarketingManager: data_ret = {"status": 1} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) diff --git a/emailMarketing/models.py b/emailMarketing/models.py index cda9ff5aa..23acba869 100755 --- a/emailMarketing/models.py +++ b/emailMarketing/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models from websiteFunctions.models import Websites @@ -39,7 +39,7 @@ class EmailTemplate(models.Model): fromName = models.CharField(max_length=100) fromEmail = models.CharField(max_length=150) replyTo = models.CharField(max_length=150) - emailMessage = models.CharField(max_length=3000000) + emailMessage = models.TextField(max_length=65532) class EmailJobs(models.Model): owner = models.ForeignKey(EmailTemplate, on_delete=models.CASCADE) diff --git a/emailMarketing/tests.py b/emailMarketing/tests.py index 5982e6bcd..f067dcaac 100755 --- a/emailMarketing/tests.py +++ b/emailMarketing/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/emailMarketing/urls.py b/emailMarketing/urls.py index 45cf7606e..4d22a9206 100755 --- a/emailMarketing/urls.py +++ b/emailMarketing/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^$', views.emailMarketing, name='emailMarketing'), url(r'^fetchUsers$', views.fetchUsers, name='fetchUsers'), diff --git a/emailMarketing/views.py b/emailMarketing/views.py index 76be7dd8f..3aff6a5ff 100755 --- a/emailMarketing/views.py +++ b/emailMarketing/views.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import redirect from loginSystem.views import loadLoginPage -from emailMarketingManager import EmailMarketingManager +from .emailMarketingManager import EmailMarketingManager # Create your views here. diff --git a/emailPremium/admin.py b/emailPremium/admin.py index 13be29d96..4c33e0ec3 100755 --- a/emailPremium/admin.py +++ b/emailPremium/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/emailPremium/apps.py b/emailPremium/apps.py index 69075763f..a4bed0ef2 100755 --- a/emailPremium/apps.py +++ b/emailPremium/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/emailPremium/models.py b/emailPremium/models.py index 60e4ca5b6..7235a6161 100755 --- a/emailPremium/models.py +++ b/emailPremium/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models from mailServer.models import Domains, EUsers diff --git a/emailPremium/tests.py b/emailPremium/tests.py index 5982e6bcd..f067dcaac 100755 --- a/emailPremium/tests.py +++ b/emailPremium/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/emailPremium/urls.py b/emailPremium/urls.py index 2fde03c37..abb7ac027 100755 --- a/emailPremium/urls.py +++ b/emailPremium/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ diff --git a/emailPremium/views.py b/emailPremium/views.py index 1ba9a7ab7..b2aff0a39 100755 --- a/emailPremium/views.py +++ b/emailPremium/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render,redirect from django.http import HttpResponse @@ -13,7 +13,7 @@ import json from .models import DomainLimits, EmailLimits from math import ceil from postfixSenderPolicy.client import cacheClient -import thread +import _thread from plogical.mailUtilities import mailUtilities from plogical.virtualHostUtilities import virtualHostUtilities from random import randint @@ -67,12 +67,12 @@ def fetchPolicyServerStatus(request): return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) @@ -101,7 +101,7 @@ def savePolicyServerStatus(request): ## save configuration data - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py" execPath = execPath + " savePolicyServerStatus --install " + install output = ProcessUtilities.outputExecutioner(execPath) @@ -115,12 +115,12 @@ def savePolicyServerStatus(request): return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) @@ -174,7 +174,7 @@ def listDomains(request): return render(request,'emailPremium/listDomains.html',{"pagination":pagination, "installCheck": installCheck}) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse("See CyberCP main log file.") @@ -200,7 +200,7 @@ def getFurtherDomains(request): status = data['page'] pageNumber = int(status) - except BaseException, msg: + except BaseException as msg: status = str(msg) finalPageNumber = ((pageNumber * 10)) - 10 @@ -224,7 +224,7 @@ def getFurtherDomains(request): checker = 1 else: json_data = json_data +',' + json.dumps(dic) - except BaseException, msg: + except BaseException as msg: try: domain = Domains.objects.get(domainOwner=items) except: @@ -249,13 +249,13 @@ def getFurtherDomains(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException,msg: + except BaseException as msg: dic = {'listWebSiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: dic = {'listWebSiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -292,13 +292,13 @@ def enableDisableEmailLimits(request): json_data = json.dumps(dic) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: dic = {'statusa': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -385,13 +385,13 @@ def changeDomainLimit(request): json_data = json.dumps(dic) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: dic = {'statusa': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -435,7 +435,7 @@ def getFurtherEmail(request): checker = 1 else: json_data = json_data +',' + json.dumps(dic) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) json_data = json_data + ']' @@ -445,13 +445,13 @@ def getFurtherEmail(request): return HttpResponse(final_json) - except BaseException,msg: + except BaseException as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -484,12 +484,12 @@ def enableDisableIndividualEmailLimits(request): json_data = json.dumps(dic) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: dic = {'statusa': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -558,13 +558,13 @@ def getEmailStats(request): return HttpResponse(final_json) - except BaseException,msg: + except BaseException as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -597,12 +597,12 @@ def enableDisableIndividualEmailLogs(request): json_data = json.dumps(dic) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: dic = {'statusa': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -668,13 +668,13 @@ def changeDomainEmailLimitsIndividual(request): json_data = json.dumps(dic) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: dic = {'statusa': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -722,13 +722,13 @@ def getEmailLogs(request): return HttpResponse(final_json) - except BaseException,msg: + except BaseException as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -757,12 +757,12 @@ def flushEmailLogs(request): json_data = json.dumps(dic) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: dic = {'statusa': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -801,13 +801,13 @@ def installSpamAssassin(request): return ACLManager.loadErrorJson() try: - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py" execPath = execPath + " installSpamAssassin" ProcessUtilities.popenExecutioner(execPath) final_json = json.dumps({'status': 1, 'error_message': "None"}) return HttpResponse(final_json) - except BaseException,msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -827,7 +827,7 @@ def installStatusSpamAssassin(request): if installStatus.find("[200]")>-1: - execPath = "export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin && /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py" + execPath = "export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin && /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py" execPath = execPath + " configureSpamAssassin" output = ProcessUtilities.outputExecutioner(execPath) @@ -865,7 +865,7 @@ def installStatusSpamAssassin(request): 'requestStatus': installStatus, }) return HttpResponse(final_json) - except BaseException,msg: + except BaseException as msg: final_dic = {'abort':1,'installed':0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -942,7 +942,7 @@ def fetchSpamAssassinSettings(request): return HttpResponse(final_json) - except BaseException,msg: + except BaseException as msg: final_dic = {'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -997,7 +997,7 @@ def saveSpamAssassinConfigurations(request): ## save configuration data - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py" execPath = execPath + " saveSpamAssassinConfigs --tempConfigPath " + tempConfigPath output = ProcessUtilities.outputExecutioner(execPath) @@ -1011,12 +1011,12 @@ def saveSpamAssassinConfigurations(request): return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: data_ret = {'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) data_ret = {'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) diff --git a/examplePlugin/admin.py b/examplePlugin/admin.py index 13be29d96..4c33e0ec3 100755 --- a/examplePlugin/admin.py +++ b/examplePlugin/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/examplePlugin/apps.py b/examplePlugin/apps.py index daac439e9..dbda5f9af 100755 --- a/examplePlugin/apps.py +++ b/examplePlugin/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig @@ -8,4 +8,4 @@ class ExamplepluginConfig(AppConfig): name = 'examplePlugin' def ready(self): - import signals + from . import signals diff --git a/examplePlugin/models.py b/examplePlugin/models.py index 1dfab7604..4e6a8e76d 100755 --- a/examplePlugin/models.py +++ b/examplePlugin/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/examplePlugin/tests.py b/examplePlugin/tests.py index 5982e6bcd..f067dcaac 100755 --- a/examplePlugin/tests.py +++ b/examplePlugin/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/examplePlugin/urls.py b/examplePlugin/urls.py index 5c68f92d1..f0c4eea2e 100755 --- a/examplePlugin/urls.py +++ b/examplePlugin/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ diff --git a/examplePlugin/views.py b/examplePlugin/views.py index c8c4e619e..d0790aff2 100755 --- a/examplePlugin/views.py +++ b/examplePlugin/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render, HttpResponse diff --git a/filemanager/admin.py b/filemanager/admin.py index 13be29d96..4c33e0ec3 100755 --- a/filemanager/admin.py +++ b/filemanager/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/filemanager/apps.py b/filemanager/apps.py index 7e758eb48..3bc634ff0 100755 --- a/filemanager/apps.py +++ b/filemanager/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/filemanager/filemanager.py b/filemanager/filemanager.py index dc3286a05..ca00a322f 100755 --- a/filemanager/filemanager.py +++ b/filemanager/filemanager.py @@ -6,7 +6,7 @@ from plogical.processUtilities import ProcessUtilities from websiteFunctions.models import Websites from random import randint from django.core.files.storage import FileSystemStorage -import HTMLParser +import html.parser import os class FileManager: @@ -21,7 +21,7 @@ class FileManager: return HttpResponse(final_json) def returnPathEnclosed(self, path): - htmlParser = HTMLParser.HTMLParser() + htmlParser = html.parser.HTMLParser() path = htmlParser.unescape(path) return path return "'" + path + "'" @@ -55,7 +55,7 @@ class FileManager: for items in output: try: currentFile = items.split(' ') - currentFile = filter(lambda a: a != '', currentFile) + currentFile = [a for a in currentFile if a != ''] if currentFile[-1] == '.' or currentFile[-1] == '..' or currentFile[0] == 'total': continue @@ -72,13 +72,13 @@ class FileManager: finalData[str(counter)] = [currentFile[-1], currentFile[-1], lastModified, size, currentFile[0], dirCheck] counter = counter + 1 - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def list(self): @@ -97,7 +97,7 @@ class FileManager: for items in output: try: currentFile = items.split(' ') - currentFile = filter(lambda a: a != '', currentFile) + currentFile = [a for a in currentFile if a != ''] if currentFile[-1] == '.' or currentFile[-1] == '..' or currentFile[0] == 'total': continue @@ -119,7 +119,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def createNewFile(self): @@ -142,7 +142,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def createNewFolder(self): @@ -160,7 +160,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def deleteFolderOrFile(self): @@ -178,7 +178,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def copy(self): @@ -212,7 +212,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def move(self): @@ -238,7 +238,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def rename(self): @@ -261,7 +261,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def readFileContents(self): @@ -278,7 +278,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def writeFileContents(self): @@ -313,7 +313,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def upload(self): @@ -345,7 +345,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def extract(self): @@ -372,7 +372,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def compress(self): @@ -405,7 +405,7 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) def changePermissions(self): @@ -429,5 +429,5 @@ class FileManager: json_data = json.dumps(finalData) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: return self.ajaxPre(0, str(msg)) \ No newline at end of file diff --git a/filemanager/models.py b/filemanager/models.py index 1dfab7604..4e6a8e76d 100755 --- a/filemanager/models.py +++ b/filemanager/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/filemanager/tests.py b/filemanager/tests.py index 5982e6bcd..f067dcaac 100755 --- a/filemanager/tests.py +++ b/filemanager/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/filemanager/urls.py b/filemanager/urls.py index 25a64655f..114469614 100755 --- a/filemanager/urls.py +++ b/filemanager/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^upload$',views.upload, name='upload'), diff --git a/filemanager/views.py b/filemanager/views.py index ec447d593..5170b8151 100755 --- a/filemanager/views.py +++ b/filemanager/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render,redirect from loginSystem.models import Administrator @@ -70,7 +70,7 @@ def changePermissions(request): return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) data_ret = {'permissionsChanged': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) @@ -145,7 +145,7 @@ def controller(request): return fm.changePermissions() - except BaseException, msg: + except BaseException as msg: fm = FM(request, None) return fm.ajaxPre(0, str(msg)) diff --git a/firewall/admin.py b/firewall/admin.py index eba54e2af..ae4fb368a 100755 --- a/firewall/admin.py +++ b/firewall/admin.py @@ -1,4 +1,4 @@ from django.contrib import admin -import models +from . import models # Register your models here. admin.site.register(models.FirewallRules) \ No newline at end of file diff --git a/firewall/firewallManager.py b/firewall/firewallManager.py index 8da1bc374..6bd0102cf 100755 --- a/firewall/firewallManager.py +++ b/firewall/firewallManager.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os import os.path import sys @@ -35,7 +35,7 @@ class FirewallManager: return ACLManager.loadError() return render(request, 'firewall/index.html') - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def firewallHome(self, request = None, userID = None): @@ -48,7 +48,7 @@ class FirewallManager: return ACLManager.loadError() return render(request, 'firewall/firewall.html') - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def getCurrentRules(self, userID = None): @@ -84,7 +84,7 @@ class FirewallManager: final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -113,7 +113,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'add_status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -143,7 +143,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'delete_status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -171,7 +171,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'reload_status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -199,7 +199,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'start_status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -227,7 +227,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'stop_status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -242,7 +242,7 @@ class FirewallManager: else: return ACLManager.loadErrorJson() - command = 'sudo systemctl status firewalld' + command = 'systemctl status firewalld' status = ProcessUtilities.outputExecutioner(command) if status.find("dead") > -1: @@ -254,7 +254,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -269,7 +269,7 @@ class FirewallManager: return ACLManager.loadError() return render(request, 'firewall/secureSSH.html') - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def getSSHConfigs(self, userID = None, data = None): @@ -348,7 +348,7 @@ class FirewallManager: final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -371,7 +371,7 @@ class FirewallManager: else: rootLogin = "0" - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/firewallUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/firewallUtilities.py" execPath = execPath + " saveSSHConfigs --type " + str(type) + " --sshPort " + sshPort + " --rootLogin " + rootLogin output = ProcessUtilities.outputExecutioner(execPath) @@ -399,7 +399,7 @@ class FirewallManager: FirewallUtilities.addRule('tcp', sshPort, "0.0.0.0/0") command = 'firewall-cmd --permanent --remove-service=ssh' ProcessUtilities.executioner(command) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) final_dic = {'status': 1, 'saveStatus': 1} @@ -410,7 +410,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0 ,'saveStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -426,7 +426,7 @@ class FirewallManager: key = data['key'] - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/firewallUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/firewallUtilities.py" execPath = execPath + " deleteSSHKey --key '" + key + "'" output = ProcessUtilities.outputExecutioner(execPath) @@ -440,7 +440,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'delete_status': 0, 'error_mssage': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -462,7 +462,7 @@ class FirewallManager: writeToFile.write(key) writeToFile.close() - execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/firewallUtilities.py" + execPath = "sudo /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/firewallUtilities.py" execPath = execPath + " addSSHKey --tempPath " + tempPath output = ProcessUtilities.outputExecutioner(execPath) @@ -476,7 +476,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'add_status': 0, 'error_mssage': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -508,7 +508,7 @@ class FirewallManager: modSecInstalled = 1 return render(request, 'firewall/modSecurity.html', {'modSecInstalled': modSecInstalled, 'OLS': OLS}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def installModSec(self, userID = None, data = None): @@ -520,7 +520,7 @@ class FirewallManager: else: return ACLManager.loadErrorJson('installModSec', 0) - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" execPath = execPath + " installModSec" ProcessUtilities.popenExecutioner(execPath) @@ -530,7 +530,7 @@ class FirewallManager: final_json = json.dumps({'installModSec': 1, 'error_message': "None"}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'installModSec': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -543,7 +543,7 @@ class FirewallManager: if installStatus.find("[200]") > -1: - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" execPath = execPath + " installModSecConfigs" @@ -585,7 +585,7 @@ class FirewallManager: }) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'abort': 1, 'installed': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -726,7 +726,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -789,7 +789,7 @@ class FirewallManager: ## save configuration data - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" execPath = execPath + " saveModSecConfigs --tempConfigPath " + tempConfigPath @@ -844,7 +844,7 @@ class FirewallManager: ## save configuration data - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" execPath = execPath + " saveModSecConfigs --tempConfigPath " + tempConfigPath @@ -859,7 +859,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -891,7 +891,7 @@ class FirewallManager: return render(request, 'firewall/modSecurityRules.html', {'modSecInstalled': modSecInstalled}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def fetchModSecRules(self, userID = None, data = None): @@ -945,7 +945,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'modSecInstalled': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) @@ -970,7 +970,7 @@ class FirewallManager: ## save configuration data - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" execPath = execPath + " saveModSecRules" output = ProcessUtilities.outputExecutioner(execPath) @@ -983,7 +983,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1016,7 +1016,7 @@ class FirewallManager: return render(request, 'firewall/modSecurityRulesPacks.html', {'modSecInstalled': modSecInstalled}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(msg) def getOWASPAndComodoStatus(self, userID = None, data = None): @@ -1096,7 +1096,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'modSecInstalled': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1115,7 +1115,7 @@ class FirewallManager: if ProcessUtilities.decideServer() == ProcessUtilities.OLS: - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" execPath = execPath + " " + packName output = ProcessUtilities.outputExecutioner(execPath) @@ -1133,7 +1133,7 @@ class FirewallManager: final_json = json.dumps({'installStatus': 0, 'error_message': "OWASP will be available later.", }) return HttpResponse(final_json) - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" execPath = execPath + " " + packName output = ProcessUtilities.outputExecutioner(execPath) @@ -1146,7 +1146,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'installStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1250,7 +1250,7 @@ class FirewallManager: final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1273,7 +1273,7 @@ class FirewallManager: else: functionName = 'enableRuleFile' - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py" execPath = execPath + " " + functionName + ' --packName ' + packName + ' --fileName ' + fileName @@ -1288,7 +1288,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1312,7 +1312,7 @@ class FirewallManager: except subprocess.CalledProcessError: csfInstalled = 0 return render(self.request,'firewall/csf.html', {'csfInstalled' : csfInstalled}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def installCSF(self): @@ -1325,7 +1325,12 @@ class FirewallManager: else: return ACLManager.loadErrorJson('installStatus', 0) - execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/csf.py" + if os.path.exists('/usr/local/CyberCP/bin/python3'): + final_dic = {'installStatus': 0, 'error_message': 'CSF is not yet supported on Python 3'} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + + execPath = "sudo /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/csf.py" execPath = execPath + " installCSF" ProcessUtilities.popenExecutioner(execPath) @@ -1336,7 +1341,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: final_dic = {'installStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1379,7 +1384,7 @@ class FirewallManager: }) return HttpResponse(final_json) - except BaseException,msg: + except BaseException as msg: final_dic = {'abort':1, 'installed':0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1394,7 +1399,7 @@ class FirewallManager: else: return ACLManager.loadErrorJson('installStatus', 0) - execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/csf.py" + execPath = "sudo /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/csf.py" execPath = execPath + " removeCSF" ProcessUtilities.popenExecutioner(execPath) @@ -1404,7 +1409,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: final_dic = {'installStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1433,7 +1438,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: final_dic = {'fetchStatus': 0, 'error_message': 'CSF is not installed.'} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1453,7 +1458,7 @@ class FirewallManager: controller = data['controller'] status = data['status'] - execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/csf.py" + execPath = "sudo /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/csf.py" execPath = execPath + " changeStatus --controller " + controller + " --status " + status output = ProcessUtilities.outputExecutioner(execPath) @@ -1466,7 +1471,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1494,7 +1499,7 @@ class FirewallManager: writeToFile.write(ports) writeToFile.close() - execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/csf.py" + execPath = "sudo /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/csf.py" execPath = execPath + " modifyPorts --protocol " + protocol + " --ports " + portsPath output = ProcessUtilities.outputExecutioner(execPath) @@ -1507,7 +1512,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1537,7 +1542,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) diff --git a/firewall/pluginManager.py b/firewall/pluginManager.py index ccb002950..463afbd78 100755 --- a/firewall/pluginManager.py +++ b/firewall/pluginManager.py @@ -1,4 +1,4 @@ -from signals import * +from .signals import * from plogical.pluginManagerGlobal import pluginManagerGlobal class pluginManager: diff --git a/firewall/urls.py b/firewall/urls.py index 7c004d075..bdbfec1d4 100755 --- a/firewall/urls.py +++ b/firewall/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^securityHome', views.securityHome, name='securityHome'), diff --git a/firewall/views.py b/firewall/views.py index 4d7bf4d58..7c9e68cd4 100755 --- a/firewall/views.py +++ b/firewall/views.py @@ -1,8 +1,8 @@ from django.shortcuts import redirect import json from loginSystem.views import loadLoginPage -from firewallManager import FirewallManager -from pluginManager import pluginManager +from .firewallManager import FirewallManager +from .pluginManager import pluginManager # Create your views here. diff --git a/ftp/admin.py b/ftp/admin.py index d54be6ff8..496994814 100755 --- a/ftp/admin.py +++ b/ftp/admin.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin -import models +from . import models # Register your models here. diff --git a/ftp/apps.py b/ftp/apps.py index 07ececb09..9ec4a66a2 100755 --- a/ftp/apps.py +++ b/ftp/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/ftp/ftpManager.py b/ftp/ftpManager.py index 64a0ebe68..bdb028ae2 100755 --- a/ftp/ftpManager.py +++ b/ftp/ftpManager.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os.path import sys import django @@ -8,7 +8,7 @@ django.setup() import json from django.shortcuts import render,redirect from django.http import HttpResponse -from models import Users +from .models import Users from loginSystem.models import Administrator import plogical.CyberCPLogFileWriter as logging from loginSystem.views import loadLoginPage @@ -47,7 +47,7 @@ class FTPManager: return render(self.request, 'ftp/createFTPAccount.html', {'websiteList': websitesName, 'admin': admin.userName, "status": 1}) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse(str(msg)) @@ -100,7 +100,7 @@ class FTPManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'creatFTPStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -120,7 +120,7 @@ class FTPManager: websitesName = ACLManager.findAllSites(currentACL, userID) return render(self.request, 'ftp/deleteFTPAccount.html', {'websiteList': websitesName, "status": 1}) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse(str(msg)) @@ -161,7 +161,7 @@ class FTPManager: final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: data_ret = {'fetchStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -188,7 +188,7 @@ class FTPManager: final_json = json.dumps({'status': 1, 'deleteStatus': 1, 'error_message': "None"}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'deleteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -207,7 +207,7 @@ class FTPManager: websitesName = ACLManager.findAllSites(currentACL, userID) return render(self.request, 'ftp/listFTPAccounts.html', {'websiteList': websitesName, "status": 1}) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse(str(msg)) @@ -252,7 +252,7 @@ class FTPManager: final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -282,7 +282,7 @@ class FTPManager: data_ret = {'status': 1, 'changePasswordStatus': 1, 'error_message': "None"} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'changePasswordStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) \ No newline at end of file diff --git a/ftp/pluginManager.py b/ftp/pluginManager.py index 275c1f7a5..baacfe757 100755 --- a/ftp/pluginManager.py +++ b/ftp/pluginManager.py @@ -1,4 +1,4 @@ -from signals import * +from .signals import * from plogical.pluginManagerGlobal import pluginManagerGlobal class pluginManager: diff --git a/ftp/tests.py b/ftp/tests.py index ecc405fcc..e2464a559 100755 --- a/ftp/tests.py +++ b/ftp/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase import json diff --git a/ftp/urls.py b/ftp/urls.py index 46205a645..170bc36e2 100755 --- a/ftp/urls.py +++ b/ftp/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^$', views.loadFTPHome, name='loadFTPHome'), diff --git a/ftp/views.py b/ftp/views.py index 7ee5c996b..0eaf41284 100755 --- a/ftp/views.py +++ b/ftp/views.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import redirect -from ftpManager import FTPManager +from .ftpManager import FTPManager from loginSystem.views import loadLoginPage -from pluginManager import pluginManager +from .pluginManager import pluginManager # Create your views here. def loadFTPHome(request): diff --git a/highAvailability/admin.py b/highAvailability/admin.py index 13be29d96..4c33e0ec3 100755 --- a/highAvailability/admin.py +++ b/highAvailability/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/highAvailability/apps.py b/highAvailability/apps.py index 1b1e13f4d..ae2d91b77 100755 --- a/highAvailability/apps.py +++ b/highAvailability/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/highAvailability/haManager.py b/highAvailability/haManager.py index e83acc336..077ada262 100755 --- a/highAvailability/haManager.py +++ b/highAvailability/haManager.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os.path import sys import django @@ -30,7 +30,7 @@ class HAManager(multi.Thread): self.setupNode() elif self.function == 'addManager': self.setupNode() - except BaseException, msg: + except BaseException as msg: logging.writeToFile( str(msg) + ' [HAManager.run]') def setupNode(self): @@ -72,7 +72,7 @@ class HAManager(multi.Thread): mesg = 'Node successfully configured. [200]' logging.statusWriter(self.data['tempStatusPath'], mesg) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) logging.statusWriter(self.data['tempStatusPath'], str(msg) + '. [404]') @@ -99,14 +99,14 @@ class HAManager(multi.Thread): workerToken = '' command = "sudo docker swarm join-token manager" - output = subprocess.check_output(shlex.split(command)).splitlines() + output = subprocess.check_output(shlex.split(command)).decode("utf-8").splitlines() for items in output: if items.find('--token') > -1: managerToken = items.split(' ')[-2] command = "sudo docker swarm join-token worker" - output = subprocess.check_output(shlex.split(command)).splitlines() + output = subprocess.check_output(shlex.split(command)).decode("utf-8").splitlines() for items in output: if items.find('--token') > -1: @@ -118,7 +118,7 @@ class HAManager(multi.Thread): return proc.ajax(1, None, data) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, None, str(msg)) @@ -142,7 +142,7 @@ class HAManager(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, None, str(msg)) @@ -163,11 +163,11 @@ class HAManager(multi.Thread): result = subprocess.call(command, shell=True) if result != 0: logging.writeToFile(command + ' Failed.') - except BaseException, msg: + except BaseException as msg: logging.writeToFile(command + 'Failed.') return 0 - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) def setUpDataNode(self): @@ -194,7 +194,7 @@ class HAManager(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -227,7 +227,7 @@ class HAManager(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) diff --git a/highAvailability/models.py b/highAvailability/models.py index 1dfab7604..4e6a8e76d 100755 --- a/highAvailability/models.py +++ b/highAvailability/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/highAvailability/tests.py b/highAvailability/tests.py index 5982e6bcd..f067dcaac 100755 --- a/highAvailability/tests.py +++ b/highAvailability/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/highAvailability/views.py b/highAvailability/views.py index e784a0bd2..e2a525da4 100755 --- a/highAvailability/views.py +++ b/highAvailability/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render diff --git a/install/firewallUtilities.py b/install/firewallUtilities.py index b4bfacd54..8884eae16 100755 --- a/install/firewallUtilities.py +++ b/install/firewallUtilities.py @@ -13,10 +13,10 @@ class FirewallUtilities: inst.preFlightsChecks.stdOut("Failed to apply rule: " + command + " Error #" + str(res), 1) return 0 - except OSError, msg: + except OSError as msg: inst.preFlightsChecks.stdOut("Failed to apply rule: " + command + " Error: " + str(msg), 1) return 0 - except ValueError, msg: + except ValueError as msg: inst.preFlightsChecks.stdOut("Failed to apply rule: " + command + " Error: " + str(msg), 1) return 0 diff --git a/install/install.py b/install/install.py index e745b08b5..b055d18bf 100755 --- a/install/install.py +++ b/install/install.py @@ -13,8 +13,6 @@ import socket from os.path import * from stat import * import stat -from os import urandom -from random import choice char_set = {'small': 'abcdefghijklmnopqrstuvwxyz', 'nums': '0123456789', @@ -23,34 +21,9 @@ char_set = {'small': 'abcdefghijklmnopqrstuvwxyz', def generate_pass(length=14): - """Function to generate a password""" - - password = [] - - while len(password) < length: - key = choice(char_set.keys()) - a_char = urandom(1) - if a_char in char_set[key]: - if check_prev_char(password, char_set[key]): - continue - else: - password.append(a_char) - return ''.join(password) - - -def check_prev_char(password, current_char_set): - """Function to ensure that there are no consecutive - UPPERCASE/lowercase/numbers/special-characters.""" - - index = len(password) - if index == 0: - return False - else: - prev_char = password[index - 1] - if prev_char in current_char_set: - return True - else: - return False + chars = string.ascii_uppercase + string.ascii_lowercase + string.digits + size = length + return ''.join(random.choice(chars) for x in range(size)) # There can not be peace without first a great suffering. @@ -59,6 +32,7 @@ def check_prev_char(password, current_char_set): centos = 0 ubuntu = 1 +cent8 = 2 def get_distro(): @@ -75,6 +49,11 @@ def get_distro(): distro_file = "/etc/os-release" distro = centos + data = open('/etc/redhat-release', 'r').read() + + if data.find('CentOS Linux release 8') > -1: + return cent8 + else: logging.InstallLog.writeToFile("Can't find linux release file - fatal error") preFlightsChecks.stdOut("Can't find linux release file - fatal error") @@ -124,11 +103,11 @@ class preFlightsChecks: @staticmethod def stdOut(message, log=0, do_exit=0, code=os.EX_OK): print("\n\n") - print ("[" + time.strftime( - "%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n") - print("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] " + message + "\n") - print ("[" + time.strftime( - "%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n") + print(("[" + time.strftime( + "%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n")) + print(("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] " + message + "\n")) + print(("[" + time.strftime( + "%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n")) if log: logging.InstallLog.writeToFile(message) @@ -140,7 +119,7 @@ class preFlightsChecks: try: ## On OpenVZ there is an issue using .tempdisk for /tmp as it breaks network on container after reboot. - if subprocess.check_output('systemd-detect-virt').find("openvz") > -1: + if subprocess.check_output('systemd-detect-virt').decode("utf-8").find("openvz") > -1: varTmp = "/var/tmp /tmp none bind 0 0\n" @@ -201,7 +180,7 @@ class preFlightsChecks: writeToFile.writelines(varTmp) writeToFile.close() - except BaseException, msg: + except BaseException as msg: preFlightsChecks.stdOut('[ERROR] ' + str(msg)) return 0 @@ -248,7 +227,7 @@ class preFlightsChecks: def checkIfSeLinuxDisabled(self): try: command = "sestatus" - output = subprocess.check_output(shlex.split(command)) + output = subprocess.check_output(shlex.split(command)).decode("utf-8") if output.find("disabled") > -1 or output.find("permissive") > -1: logging.InstallLog.writeToFile("SELinux Check OK. [checkIfSeLinuxDisabled]") @@ -260,23 +239,23 @@ class preFlightsChecks: preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") os._exit(0) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + "[checkIfSeLinuxDisabled]") logging.InstallLog.writeToFile('[ERROR] ' + "SELinux Check OK. [checkIfSeLinuxDisabled]") preFlightsChecks.stdOut('[ERROR] ' + "SELinux Check OK.") return 1 def checkPythonVersion(self): - if sys.version_info[0] == 2 and sys.version_info[1] == 7: + if sys.version_info[0] == 3: return 1 else: - preFlightsChecks.stdOut("You are running Unsupported python version, please install python 2.7") + preFlightsChecks.stdOut("You are running Unsupported python version, please install python 3.x") os._exit(0) def setup_account_cyberpanel(self): try: - if self.distro == centos: + if self.distro == centos or self.distro == cent8: command = "yum install sudo -y" preFlightsChecks.call(command, self.distro, command, command, @@ -285,21 +264,6 @@ class preFlightsChecks: ## if self.distro == ubuntu: - # self.stdOut("Fix sudoers") - # try: - # fileName = '/etc/sudoers' - # data = open(fileName, 'r').readlines() - # - # writeDataToFile = open(fileName, 'w') - # for line in data: - # if line[:5] == '%sudo': - # writeDataToFile.write('%sudo ALL=(ALL:ALL) NOPASSWD: ALL\n') - # else: - # writeDataToFile.write(line) - # writeDataToFile.close() - # except IOError as err: - # self.stdOut("Error in fixing sudoers file: " + str(err), 1, 1, os.EX_OSERR) - self.stdOut("Add Cyberpanel user") command = 'adduser --disabled-login --gecos "" cyberpanel' preFlightsChecks.call(command, self.distro, command,command,1, 1, os.EX_OSERR) @@ -308,28 +272,6 @@ class preFlightsChecks: command = "useradd -s /bin/false cyberpanel" preFlightsChecks.call(command, self.distro, command,command,1, 1, os.EX_OSERR) - # ## - # - # command = "usermod -aG wheel cyberpanel" - # preFlightsChecks.call(command, self.distro, '[setup_account_cyberpanel]', - # 'add user cyberpanel', - # 1, 0, os.EX_OSERR) - - ############################### - - # path = "/etc/sudoers" - # - # data = open(path, 'r').readlines() - # - # writeToFile = open(path, 'w') - # - # for items in data: - # if items.find("wheel ALL=(ALL) NOPASSWD: ALL") > -1: - # writeToFile.writelines("%wheel ALL=(ALL) NOPASSWD: ALL") - # else: - # writeToFile.writelines(items) - # - # writeToFile.close() ############################### @@ -356,7 +298,7 @@ class preFlightsChecks: command = "mkdir -p /etc/letsencrypt/live/" preFlightsChecks.call(command, self.distro, command,command,1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile("[ERROR] setup_account_cyberpanel. " + str(msg)) def yum_update(self): @@ -381,9 +323,12 @@ class preFlightsChecks: preFlightsChecks.stdOut("[ERROR] Exception during CyberPanel install") os._exit(os.EX_SOFTWARE) - else: + elif self.distro == centos: command = 'rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm' preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + elif self.distro == cent8: + command = 'rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm' + preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) def enableEPELRepo(self): command = 'yum -y install epel-release' @@ -393,20 +338,23 @@ class preFlightsChecks: self.stdOut("Install pip") if self.distro == ubuntu: command = "apt-get -y install python-pip" - else: + preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + elif self.distro == centos: command = "yum -y install python-pip" + preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) - preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) def install_python_dev(self): self.stdOut("Install python development environment") if self.distro == centos: command = "yum -y install python-devel" - else: + preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + elif self.distro == ubuntu: command = "apt-get -y install python-dev" + preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + - preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) def install_gcc(self): self.stdOut("Install gcc") @@ -426,7 +374,7 @@ class preFlightsChecks: self.stdOut("Install MySQL python library") if self.distro == centos: - command = "yum -y install MySQL-python" + command = "yum install mariadb-devel gcc python36u-devel -y" else: command = "apt-get -y install libmysqlclient-dev" @@ -457,7 +405,7 @@ class preFlightsChecks: def install_psmisc(self): self.stdOut("Install psmisc") - if self.distro == centos: + if self.distro == centos or self.distro == cent8: command = "yum -y install psmisc" else: command = "apt-get -y install psmisc" @@ -548,18 +496,18 @@ class preFlightsChecks: logging.InstallLog.writeToFile("settings.py updated!") - self.setupVirtualEnv(self.distro) + #self.setupVirtualEnv(self.distro) ### Applying migrations - os.chdir("CyberCP") + os.chdir("/usr/local/CyberCP") - command = "/usr/local/CyberCP/bin/python2 manage.py makemigrations" + command = "/usr/local/CyberPanel/bin/python manage.py makemigrations" preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) ## - command = "/usr/local/CyberCP/bin/python2 manage.py migrate" + command = "/usr/local/CyberPanel/bin/python manage.py migrate" preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) if not os.path.exists("/usr/local/CyberCP/public"): @@ -700,28 +648,38 @@ class preFlightsChecks: command = 'chmod +x /usr/local/CyberCP/CLManager/CLPackages.py' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + clScripts = ['/usr/local/CyberCP/CLScript/panel_info.py', '/usr/local/CyberCP/CLScript/CloudLinuxPackages.py', + '/usr/local/CyberCP/CLScript/CloudLinuxUsers.py', + '/usr/local/CyberCP/CLScript/CloudLinuxDomains.py' + , '/usr/local/CyberCP/CLScript/CloudLinuxResellers.py', '/usr/local/CyberCP/CLScript/CloudLinuxAdmins.py', + '/usr/local/CyberCP/CLScript/CloudLinuxDB.py', '/usr/local/CyberCP/CLScript/UserInfo.py'] + + for items in clScripts: + command = 'chmod +x %s' % (items) + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + def install_unzip(self): self.stdOut("Install unzip") try: - if self.distro == centos: + if self.distro == centos or self.distro == cent8: command = 'yum -y install unzip' else: command = 'apt-get -y install unzip' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] '+ str(msg) + " [install_unzip]") def install_zip(self): self.stdOut("Install zip") try: - if self.distro == centos: + if self.distro == centos or self.distro == cent8: command = 'yum -y install zip' else: command = 'apt-get -y install zip' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_zip]") def download_install_phpmyadmin(self): @@ -730,8 +688,8 @@ class preFlightsChecks: if not os.path.exists("/usr/local/CyberCP/public"): os.mkdir("/usr/local/CyberCP/public") - command = 'wget -O /usr/local/CyberCP/public/phpmyadmin.zip https://%s/misc/phpmyadmin.zip' % ( - preFlightsChecks.cdn) + command = 'wget -O /usr/local/CyberCP/public/phpmyadmin.zip https://%s/misc/phpmyadmin.zip' % (preFlightsChecks.cdn) + preFlightsChecks.call(command, self.distro, '[download_install_phpmyadmin]', command, 1, 0, os.EX_OSERR) @@ -747,9 +705,10 @@ class preFlightsChecks: preFlightsChecks.call(command, self.distro, '[download_install_phpmyadmin]', command, 1, 0, os.EX_OSERR) + ## Write secret phrase - rString = ''.join([random.choice(string.ascii_letters + string.digits) for n in xrange(32)]) + rString = ''.join([random.choice(string.ascii_letters + string.digits) for n in range(32)]) data = open('/usr/local/CyberCP/public/phpmyadmin/config.sample.inc.php', 'r').readlines() @@ -772,7 +731,7 @@ class preFlightsChecks: preFlightsChecks.call(command, self.distro, '[chown -R lscpd:lscpd /usr/local/CyberCP/public/phpmyadmin]', 'chown -R lscpd:lscpd /usr/local/CyberCP/public/phpmyadmin', 1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [download_install_phpmyadmin]") return 0 @@ -800,15 +759,19 @@ enabled=1""" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) command = 'yum remove postfix -y' - else: + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + elif self.distro == ubuntu: command = 'apt-get -y remove postfix' + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + - preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) self.stdOut("Install dovecot - do the install") if self.distro == centos: command = 'yum install --enablerepo=gf-plus -y postfix3 postfix3-ldap postfix3-mysql postfix3-pcre' + elif self.distro == cent8: + command = 'dnf install postfix postfix-mysql -y' else: command = 'apt-get -y debconf-utils' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) @@ -825,7 +788,7 @@ enabled=1""" preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) - if self.distro == centos: + if self.distro == centos or self.distro == cent8: pass else: command = 'apt-get -y install dovecot-imapd dovecot-pop3d postfix-mysql' @@ -834,7 +797,7 @@ enabled=1""" ## - if self.distro == centos: + if self.distro == centos or self.distro == cent8: command = 'yum -y install dovecot dovecot-mysql' else: command = 'apt-get -y install dovecot-mysql' @@ -874,7 +837,7 @@ enabled=1""" except: pass - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_postfix_davecot]") return 0 @@ -1000,7 +963,7 @@ enabled=1""" logging.InstallLog.writeToFile("Authentication for Postfix and Dovecot set.") - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR]' + str(msg) + " [setup_email_Passwords]") return 0 @@ -1254,7 +1217,7 @@ enabled=1""" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) logging.InstallLog.writeToFile("Postfix and Dovecot configured") - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [setup_postfix_davecot_config]") return 0 @@ -1330,7 +1293,7 @@ imap_folder_list_limit = 0 writeToFile.close() - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [downoad_and_install_rainloop]") return 0 @@ -1345,9 +1308,9 @@ imap_folder_list_limit = 0 def removeUfw(self): try: preFlightsChecks.stdOut("Checking to see if ufw firewall is installed (will be removed)", 1) - status = subprocess.check_output(shlex.split('ufw status')) + status = subprocess.check_output(shlex.split('ufw status')).decode("utf-8") preFlightsChecks.stdOut("ufw current status: " + status + "...will be removed") - except BaseException, msg: + except BaseException as msg: preFlightsChecks.stdOut("[ERROR] Expected access to ufw not available, do not need to remove it", 1) return True try: @@ -1358,6 +1321,9 @@ imap_folder_list_limit = 0 return True def installFirewalld(self): + + if self.distro == cent8: + return 0 if self.distro == ubuntu: self.removeUfw() @@ -1372,7 +1338,7 @@ imap_folder_list_limit = 0 preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) ###### - if self.distro == centos: + if self.distro == centos or self.distro == cent8: # Not available in ubuntu command = 'systemctl restart dbus' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) @@ -1407,10 +1373,10 @@ imap_folder_list_limit = 0 preFlightsChecks.stdOut("FirewallD installed and configured!") - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [installFirewalld]") return 0 - except ValueError, msg: + except ValueError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [installFirewalld]") return 0 @@ -1428,7 +1394,7 @@ imap_folder_list_limit = 0 if self.distro == ubuntu: command = "apt-get -y install gcc g++ make autoconf rcs" else: - command = 'yum -y install gcc gcc-c++ make autoconf glibc rcs' + command = 'yum -y install gcc gcc-c++ make autoconf glibc' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) @@ -1436,8 +1402,7 @@ imap_folder_list_limit = 0 command = "apt-get -y install libpcre3 libpcre3-dev openssl libexpat1 libexpat1-dev libgeoip-dev" \ " zlib1g zlib1g-dev libudns-dev whichman curl" else: - command = 'yum -y install pcre-devel openssl-devel expat-devel geoip-devel zlib-devel udns-devel' \ - ' which curl' + command = 'yum -y install pcre-devel openssl-devel expat-devel geoip-devel zlib-devel udns-devel' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) @@ -1453,14 +1418,14 @@ imap_folder_list_limit = 0 except: pass - if self.distro == centos: + if self.distro == centos or self.distro == cent8: command = 'adduser lscpd -M -d /usr/local/lscp' else: command = 'useradd lscpd -M -d /usr/local/lscp' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - if self.distro == centos: + if self.distro == centos or self.distro == cent8: command = 'groupadd lscpd' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) # Added group in useradd for Ubuntu @@ -1480,12 +1445,10 @@ imap_folder_list_limit = 0 pass # self.setupComodoRules() - self.setupPort() - self.setupPythonWSGI() logging.InstallLog.writeToFile("LSCPD successfully installed!") - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [installLSCPD]") def setupComodoRules(self): @@ -1571,7 +1534,7 @@ imap_folder_list_limit = 0 return 1 - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile("[ERROR]" + str(msg)) return 0 @@ -1598,12 +1561,15 @@ imap_folder_list_limit = 0 os.chdir("wsgi-lsapi-1.4") - command = "python ./configure.py" + command = "/usr/local/CyberPanel/bin/python ./configure.py" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) command = "make" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + if not os.path.exists('/usr/local/CyberCP/bin/'): + os.mkdir('/usr/local/CyberCP/bin/') + command = "cp lswsgi /usr/local/CyberCP/bin/" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) @@ -1662,14 +1628,14 @@ imap_folder_list_limit = 0 ## command = 'systemctl start lscpd' - preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + #preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) preFlightsChecks.stdOut("LSCPD Daemon Set!") logging.InstallLog.writeToFile("LSCPD Daemon Set!") - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [setupLSCPDDaemon]") return 0 @@ -1680,21 +1646,21 @@ imap_folder_list_limit = 0 try: ## first install crontab - if self.distro == centos: + if self.distro == centos or self.distro == cent8: command = 'yum install cronie -y' else: command = 'apt-get -y install cron' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - if self.distro == centos: + if self.distro == centos or self.distro == cent8: command = 'systemctl enable crond' else: command = 'systemctl enable cron' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - if self.distro == centos: + if self.distro == centos or self.distro == cent8: command = 'systemctl start crond' else: command = 'systemctl start cron' @@ -1708,7 +1674,7 @@ imap_folder_list_limit = 0 cronFile.writelines("0 * * * * root /usr/local/CyberCP/postfixSenderPolicy/client.py hourlyCleanup" + "\n") cronFile.writelines("0 0 1 * * root /usr/local/CyberCP/postfixSenderPolicy/client.py monthlyCleanup" + "\n") cronFile.writelines("0 2 * * * root /usr/local/CyberCP/plogical/upgradeCritical.py" + "\n") - cronFile.writelines("0 2 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/renew.py\n") + cronFile.writelines("0 2 * * * root /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/renew.py\n") cronFile.close() command = 'chmod +x /usr/local/CyberCP/plogical/findBWUsage.py' @@ -1720,14 +1686,14 @@ imap_folder_list_limit = 0 command = 'chmod +x /usr/local/CyberCP/postfixSenderPolicy/client.py' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - if self.distro == centos: + if self.distro == centos or self.distro == cent8: command = 'systemctl restart crond.service' else: command = 'systemctl restart cron.service' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [setup_cron]") return 0 @@ -1741,20 +1707,20 @@ imap_folder_list_limit = 0 command = "ssh-keygen -f /root/.ssh/cyberpanel -t rsa -N ''" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_default_keys]") return 0 def install_rsync(self): try: - if self.distro == centos: + if self.distro == centos or self.distro == cent8: command = 'yum -y install rsync' else: command = 'apt-get -y install rsync' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_rsync]") return 0 @@ -1763,7 +1729,7 @@ imap_folder_list_limit = 0 import requests getVersion = requests.get('https://cyberpanel.net/version.txt') latest = getVersion.json() - except BaseException, msg: + except BaseException as msg: command = "pip uninstall --yes urllib3" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) @@ -1785,7 +1751,7 @@ imap_folder_list_limit = 0 print(" ") print(" ") - print(" Visit: https://" + self.ipAddr + ":8090 ") + print((" Visit: https://" + self.ipAddr + ":8090 ")) print(" Username: admin ") print(" Password: 1234567 ") @@ -1797,13 +1763,13 @@ imap_folder_list_limit = 0 pathToRemoveGarbageFile = os.path.join(self.server_root_path, "modules/mod_security.so") os.remove(pathToRemoveGarbageFile) - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [modSecPreReqs]") return 0 def installOpenDKIM(self): try: - if self.distro == centos: + if self.distro == centos or self.distro == cent8: command = 'yum -y install opendkim' else: command = 'apt-get -y install opendkim' @@ -1817,7 +1783,7 @@ imap_folder_list_limit = 0 command = 'mkdir -p /etc/opendkim/keys/' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [installOpenDKIM]") return 0 @@ -1881,7 +1847,7 @@ milter_default_action = accept preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [configureOpenDKIM]") return 0 @@ -1919,7 +1885,7 @@ milter_default_action = accept command = "./composer.sh" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [setupPHPAndComposer]") return 0 @@ -1933,8 +1899,7 @@ milter_default_action = accept return res # Though probably not used - @staticmethod - def setupVirtualEnv(distro): + def setupVirtualEnv(self, distro): try: ## @@ -1976,44 +1941,15 @@ milter_default_action = accept ## - command = "pip install virtualenv" - preFlightsChecks.call(command, distro, command, command, 1, 1, os.EX_OSERR) + os.chdir(self.cwd) - #### + command = "chmod +x venvsetup.sh" + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - command = "virtualenv --system-site-packages /usr/local/CyberCP" - preFlightsChecks.call(command, distro, command, command, 1, 1, os.EX_OSERR) + command = "./venvsetup.sh" + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - ## - - env_path = '/usr/local/CyberCP' - subprocess.call(['virtualenv', env_path]) - activate_this = os.path.join(env_path, 'bin', 'activate_this.py') - execfile(activate_this, dict(__file__=activate_this)) - - ## - - install_file = '/usr/local/CyberCP/requirments.txt' - if distro == ubuntu and get_Ubuntu_release() < 18.04: - install_file_new = '/usr/local/CyberCP/requirements.txt' - fd = open(install_file, 'r') - fd_new = open(install_file_new, 'w') - lines = fd.readlines() - for line in lines: - if line[:6] != 'pycurl' and line[:7] != 'pygpgme': - fd_new.write(line) - fd.close() - fd_new.close() - preFlightsChecks.stdOut("Install updated " + install_file_new, 1) - install_file = install_file_new - - command = "pip install --ignore-installed -r " + install_file - preFlightsChecks.call(command, distro, command, command, 1, 1, os.EX_OSERR) - - command = "virtualenv --system-site-packages /usr/local/CyberCP" - preFlightsChecks.call(command, distro, command, command, 1, 0, os.EX_OSERR) - - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [setupVirtualEnv]") return 0 @@ -2022,7 +1958,7 @@ milter_default_action = accept try: servicePath = '/home/cyberpanel/powerdns' - if state == 'Off': + if state == 'off': command = 'sudo systemctl stop pdns' subprocess.call(shlex.split(command)) @@ -2039,7 +1975,7 @@ milter_default_action = accept writeToFile = open(servicePath, 'w+') writeToFile.close() - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [enableDisableDNS]") return 0 @@ -2048,7 +1984,7 @@ milter_default_action = accept try: servicePath = '/home/cyberpanel/postfix' - if state == 'Off': + if state == 'off': command = 'sudo systemctl stop postfix' subprocess.call(shlex.split(command)) @@ -2065,7 +2001,7 @@ milter_default_action = accept writeToFile = open(servicePath, 'w+') writeToFile.close() - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [enableDisableEmail]") return 0 @@ -2074,7 +2010,7 @@ milter_default_action = accept try: servicePath = '/home/cyberpanel/pureftpd' - if state == 'Off': + if state == 'off': command = 'sudo systemctl stop ' + preFlightsChecks.pureFTPDServiceName(distro) subprocess.call(shlex.split(command)) @@ -2091,7 +2027,7 @@ milter_default_action = accept writeToFile = open(servicePath, 'w+') writeToFile.close() - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [enableDisableEmail]") return 0 @@ -2121,7 +2057,7 @@ milter_default_action = accept env_path = '/usr/local/CyberPanel/p3' subprocess.call(['virtualenv', env_path]) activate_this = os.path.join(env_path, 'bin', 'activate_this.py') - execfile(activate_this, dict(__file__=activate_this)) + exec(compile(open(activate_this, "rb").read(), activate_this, 'exec'), dict(__file__=activate_this)) command = "pip3 install --ignore-installed -r %s" % ('/usr/local/CyberCP/WebTerminal/requirments.txt') preFlightsChecks.call(command, distro, '[install python36]', @@ -2152,7 +2088,7 @@ milter_default_action = accept env_path = '/usr/local/CyberPanel/p3' subprocess.call(['virtualenv', env_path]) activate_this = os.path.join(env_path, 'bin', 'activate_this.py') - execfile(activate_this, dict(__file__=activate_this)) + exec(compile(open(activate_this, "rb").read(), activate_this, 'exec'), dict(__file__=activate_this)) command = "pip3 install --ignore-installed -r %s" % ('/usr/local/CyberCP/WebTerminal/requirments.txt') preFlightsChecks.call(command, distro, '[install python36]', @@ -2186,17 +2122,50 @@ milter_default_action = accept data = open(cronTab, 'r').read() if data.find('IncScheduler') == -1: - cronJob = '0 12 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n' + cronJob = '0 12 * * * root /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n' writeToFile = open(cronTab, 'a') writeToFile.writelines(cronJob) - cronJob = '0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n' + cronJob = '0 0 * * 0 root /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n' writeToFile.writelines(cronJob) writeToFile.close() except: pass + def installCLScripts(self): + try: + + CentOSPath = '/etc/redhat-release' + + if os.path.exists(CentOSPath): + command = 'mkdir -p /opt/cpvendor/etc/' + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + + content = """[integration_scripts] + +panel_info = /usr/local/CyberCP/CLScript/panel_info.py +packages = /usr/local/CyberCP/CLScript/CloudLinuxPackages.py +users = /usr/local/CyberCP/CLScript/CloudLinuxUsers.py +domains = /usr/local/CyberCP/CLScript/CloudLinuxDomains.py +resellers = /usr/local/CyberCP/CLScript/CloudLinuxResellers.py +admins = /usr/local/CyberCP/CLScript/CloudLinuxAdmins.py +db_info = /usr/local/CyberCP/CLScript/CloudLinuxDB.py + +[lvemanager_config] +ui_user_info =/usr/local/CyberCP/CLScript/UserInfo.py +base_path = /usr/local/lvemanager +run_service = 1 +service_port = 9000 +""" + + writeToFile = open('/opt/cpvendor/etc/integration.ini', 'w') + writeToFile.write(content) + writeToFile.close() + + except: + pass + def installAcme(self): command = 'wget -O - https://get.acme.sh | sh' subprocess.call(command, shell=True) @@ -2272,17 +2241,11 @@ def main(): checks.checkPythonVersion() checks.setup_account_cyberpanel() - if distro == centos: - checks.yum_update() checks.installCyberPanelRepo() - if distro == centos: - checks.enableEPELRepo() - checks.install_pip() - checks.install_python_dev() - checks.install_gcc() + #checks.install_gcc() if distro == centos: checks.install_python_setup_tools() - checks.install_python_mysql_library() + #checks.install_python_mysql_library() import installCyberPanel @@ -2300,7 +2263,7 @@ def main(): checks.setup_email_Passwords(installCyberPanel.InstallCyberPanel.mysqlPassword, mysql) checks.setup_postfix_davecot_config(mysql) else: - if args.postfix == 'On': + if args.postfix == 'ON': checks.install_postfix_davecot() checks.setup_email_Passwords(installCyberPanel.InstallCyberPanel.mysqlPassword, mysql) checks.setup_postfix_davecot_config(mysql) @@ -2313,7 +2276,6 @@ def main(): checks.install_default_keys() - checks.test_Requests() checks.download_install_CyberPanel(installCyberPanel.InstallCyberPanel.mysqlPassword, mysql) checks.downoad_and_install_raindloop() checks.download_install_phpmyadmin() @@ -2329,37 +2291,37 @@ def main(): checks.installOpenDKIM() checks.configureOpenDKIM() else: - if args.postfix == 'On': + if args.postfix == 'ON': checks.installOpenDKIM() checks.configureOpenDKIM() checks.modSecPreReqs() checks.installLSCPD() + checks.setupPort() + checks.setupPythonWSGI() checks.setupLSCPDDaemon() checks.fixCyberPanelPermissions() if args.postfix != None: - checks.enableDisableEmail(args.postfix) + checks.enableDisableEmail(args.postfix.lower()) else: preFlightsChecks.stdOut("Postfix will be installed and enabled.") - checks.enableDisableEmail('On') + checks.enableDisableEmail('on') if args.powerdns != None: - checks.enableDisableDNS(args.powerdns) + checks.enableDisableDNS(args.powerdns.lower()) else: preFlightsChecks.stdOut("PowerDNS will be installed and enabled.") - checks.enableDisableDNS('On') + checks.enableDisableDNS('on') if args.ftp != None: - checks.enableDisableFTP(args.ftp, distro) + checks.enableDisableFTP(args.ftp.lower(), distro) else: preFlightsChecks.stdOut("Pure-FTPD will be installed and enabled.") - checks.enableDisableFTP('On', distro) + checks.enableDisableFTP('on', distro) - checks.setUpFirstAccount() - # checks.p3(distro) + checks.installCLScripts() logging.InstallLog.writeToFile("CyberPanel installation successfully completed!") - #checks.installation_successfull() if __name__ == "__main__": diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 3201fe8bc..4f96f2a96 100755 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -11,6 +11,7 @@ import install #distros centos=0 ubuntu=1 +cent8=2 class InstallCyberPanel: @@ -35,10 +36,15 @@ class InstallCyberPanel: if self.ent == 0: if self.distro == ubuntu: command = "apt-get -y install openlitespeed" + install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + elif self.distro == centos: + command = 'yum install -y openlitespeed' + install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) else: command = 'yum install -y openlitespeed' + install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + - install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) else: try: try: @@ -86,7 +92,7 @@ class InstallCyberPanel: command = 'chown -R lsadm:lsadm ' + confPath install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [installLiteSpeed]") return 0 @@ -116,7 +122,7 @@ class InstallCyberPanel: writeDataToFile.close() InstallCyberPanel.stdOut("OpenLiteSpeed Configurations fixed!", 1) - except IOError, msg: + except IOError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [fix_ols_configs]") return 0 @@ -140,7 +146,7 @@ class InstallCyberPanel: InstallCyberPanel.stdOut("Default port is now 80 for OpenLiteSpeed!", 1) - except IOError, msg: + except IOError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [changePortTo80]") return 0 @@ -158,30 +164,32 @@ class InstallCyberPanel: if res != 0: InstallCyberPanel.stdOut("Failed to install PHP on Ubuntu.", 1, 1) - else: + elif self.distro == cent8 or self.distro == centos: command = 'yum -y groupinstall lsphp-all' - install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + + InstallCyberPanel.stdOut("LiteSpeed PHPs successfully installed!", 1) ## only php 71 - if self.distro == centos: + if self.distro == centos or self.distro == cent8: - command = 'yum install lsphp71 lsphp71-json lsphp71-xmlrpc lsphp71-xml lsphp71-tidy lsphp71-soap lsphp71-snmp ' \ + command = 'yum install lsphp71 lsphp71-json lsphp71-xmlrpc lsphp71-xml lsphp71-soap lsphp71-snmp ' \ 'lsphp71-recode lsphp71-pspell lsphp71-process lsphp71-pgsql lsphp71-pear lsphp71-pdo lsphp71-opcache ' \ 'lsphp71-odbc lsphp71-mysqlnd lsphp71-mcrypt lsphp71-mbstring lsphp71-ldap lsphp71-intl lsphp71-imap ' \ 'lsphp71-gmp lsphp71-gd lsphp71-enchant lsphp71-dba lsphp71-common lsphp71-bcmath -y' install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) ## only php 72 - command = 'yum install -y lsphp72 lsphp72-json lsphp72-xmlrpc lsphp72-xml lsphp72-tidy lsphp72-soap lsphp72-snmp ' \ + command = 'yum install -y lsphp72 lsphp72-json lsphp72-xmlrpc lsphp72-xml lsphp72-soap lsphp72-snmp ' \ 'lsphp72-recode lsphp72-pspell lsphp72-process lsphp72-pgsql lsphp72-pear lsphp72-pdo lsphp72-opcache ' \ 'lsphp72-odbc lsphp72-mysqlnd lsphp72-mcrypt lsphp72-mbstring lsphp72-ldap lsphp72-intl lsphp72-imap ' \ 'lsphp72-gmp lsphp72-gd lsphp72-enchant lsphp72-dba lsphp72-common lsphp72-bcmath' install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + ## only php 73 command = 'yum install -y lsphp73 lsphp73-json lsphp73-xmlrpc lsphp73-xml lsphp73-tidy lsphp73-soap lsphp73-snmp ' \ 'lsphp73-recode lsphp73-pspell lsphp73-process lsphp73-pgsql lsphp73-pear lsphp73-pdo lsphp73-opcache ' \ @@ -216,7 +224,7 @@ class InstallCyberPanel: InstallCyberPanel.stdOut("MariaDB repo set!", 1) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [setup_mariadb_repo]") return 0 @@ -291,8 +299,10 @@ class InstallCyberPanel: def startMariaDB(self): ############## Start mariadb ###################### - - command = "systemctl start mysql" + if self.distro == cent8 or self.distro == ubuntu: + command = 'systemctl start mariadb' + else: + command = "systemctl start mysql" install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) ############## Enable mariadb at system startup ###################### @@ -434,7 +444,7 @@ class InstallCyberPanel: InstallCyberPanel.stdOut("PureFTPD configured!", 1) - except IOError, msg: + except IOError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [installPureFTPDConfigurations]") return 0 @@ -472,13 +482,17 @@ class InstallCyberPanel: # "/etc/resolv.conf'", 1, 1, os.EX_OSERR) if self.distro == centos: - command = 'yum -y install epel-release' - install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) - command = 'curl -o /etc/yum.repos.d/powerdns-auth-42.repo ' \ 'https://repo.powerdns.com/repo-files/centos-auth-42.repo' install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + if self.distro == cent8: + command = 'dnf config-manager --set-enabled PowerTools' + install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + + command = 'curl -o /etc/yum.repos.d/powerdns-auth-master.repo https://repo.powerdns.com/repo-files/centos-auth-master.repo' + install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + if self.distro == ubuntu: command = "DEBIAN_FRONTEND=noninteractive apt-get -y install pdns-server pdns-backend-mysql" os.system(command) @@ -488,7 +502,7 @@ class InstallCyberPanel: install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [powerDNS]") def installPowerDNSConfigurations(self, mysqlPassword, mysql): @@ -497,7 +511,7 @@ class InstallCyberPanel: InstallCyberPanel.stdOut("Configuring PowerDNS..", 1) os.chdir(self.cwd) - if self.distro == centos: + if self.distro == centos or self.distro == cent8: dnsPath = "/etc/pdns/pdns.conf" else: dnsPath = "/etc/powerdns/pdns.conf" @@ -533,7 +547,7 @@ class InstallCyberPanel: InstallCyberPanel.stdOut("PowerDNS configured!", 1) - except IOError, msg: + except IOError as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [installPowerDNSConfigurations]") return 0 return 1 @@ -608,7 +622,7 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns installer.installPureFTPDConfigurations(mysql) installer.startPureFTPD() else: - if ftp == 'On': + if ftp == 'ON': installer.installPureFTPD() installer.installPureFTPDConfigurations(mysql) installer.startPureFTPD() @@ -618,7 +632,7 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns installer.installPowerDNSConfigurations(InstallCyberPanel.mysqlPassword, mysql) installer.startPowerDNS() else: - if dns == 'On': + if dns == 'ON': installer.installPowerDNS() installer.installPowerDNSConfigurations(InstallCyberPanel.mysqlPassword, mysql) installer.startPowerDNS() \ No newline at end of file diff --git a/install/mysqlUtilities.py b/install/mysqlUtilities.py index 546653787..9ed065680 100755 --- a/install/mysqlUtilities.py +++ b/install/mysqlUtilities.py @@ -41,5 +41,5 @@ class mysqlUtilities: return 0 return 1 - except BaseException, msg: + except BaseException as msg: return 0 \ No newline at end of file diff --git a/install/randomPassword.py b/install/randomPassword.py index 2eb292e45..9cfe205f5 100755 --- a/install/randomPassword.py +++ b/install/randomPassword.py @@ -1,38 +1,7 @@ -from os import urandom -from random import choice - -char_set = {'small': 'abcdefghijklmnopqrstuvwxyz', - 'nums': '0123456789', - 'big': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', - } - +import string +import random def generate_pass(length=14): - """Function to generate a password""" - - password = [] - - while len(password) < length: - key = choice(char_set.keys()) - a_char = urandom(1) - if a_char in char_set[key]: - if check_prev_char(password, char_set[key]): - continue - else: - password.append(a_char) - return ''.join(password) - - -def check_prev_char(password, current_char_set): - """Function to ensure that there are no consecutive - UPPERCASE/lowercase/numbers/special-characters.""" - - index = len(password) - if index == 0: - return False - else: - prev_char = password[index - 1] - if prev_char in current_char_set: - return True - else: - return False \ No newline at end of file + chars = string.ascii_uppercase + string.ascii_lowercase + string.digits + size = length + return ''.join(random.choice(chars) for x in range(size)) \ No newline at end of file diff --git a/install/unInstall.py b/install/unInstall.py index 5d14440c1..43838bb58 100755 --- a/install/unInstall.py +++ b/install/unInstall.py @@ -17,7 +17,7 @@ class unInstallCyberPanel: copyPath = "/etc/yum.repos.d/cyberpanel.repo" os.remove(copyPath) - except OSError,msg: + except OSError as msg: logging.InstallLog.writeToFile(str(msg)+ " [unInstallCyberPanelRepo]") def removeGunicorn(self): @@ -34,7 +34,7 @@ class unInstallCyberPanel: os.remove(conf) - except BaseException, msg: + except BaseException as msg: logging.InstallLog.writeToFile(str(msg) + " [removeGunicorn]") def removePostfixDovecot(self): @@ -50,10 +50,10 @@ class unInstallCyberPanel: shutil.rmtree("etc/dovecot") - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile(str(msg) + " [removePostfixDovecot]") return 0 - except ValueError, msg: + except ValueError as msg: logging.InstallLog.writeToFile(str(msg) + " [removePostfixDovecot]") return 0 @@ -72,10 +72,10 @@ class unInstallCyberPanel: os.remove("/etc/my.cnf") - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile(str(msg) + " [removeMysql]") return 0 - except ValueError, msg: + except ValueError as msg: logging.InstallLog.writeToFile(str(msg) + " [removeMysql]") return 0 @@ -92,10 +92,10 @@ class unInstallCyberPanel: shutil.rmtree("/usr/local/lsws") - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile(str(msg) + " [removeLiteSpeed]") return 0 - except ValueError, msg: + except ValueError as msg: logging.InstallLog.writeToFile(str(msg) + " [removeLiteSpeed]") return 0 return 1 @@ -107,10 +107,10 @@ class unInstallCyberPanel: os.remove("/usr/local/CyberCP2.tar.gz") shutil.rmtree("/etc/cyberpanel") - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile(str(msg) + " [removeCyberPanel]") return 0 - except ValueError, msg: + except ValueError as msg: logging.InstallLog.writeToFile(str(msg) + " [removeCyberPanel]") return 0 return 1 @@ -126,10 +126,10 @@ class unInstallCyberPanel: shutil.rmtree("/etc/pure-ftpd") - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile(str(msg) + " [removePureFTPD]") return 0 - except ValueError, msg: + except ValueError as msg: logging.InstallLog.writeToFile(str(msg) + " [removePureFTPD]") return 0 return 1 @@ -145,10 +145,10 @@ class unInstallCyberPanel: shutil.rmtree("/etc/pdns") - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile(str(msg) + " [removePowerDNS]") return 0 - except ValueError, msg: + except ValueError as msg: logging.InstallLog.writeToFile(str(msg) + " [removePowerDNS]") return 0 return 1 @@ -164,10 +164,10 @@ class unInstallCyberPanel: shutil.rmtree("/etc/pdns") - except OSError, msg: + except OSError as msg: logging.InstallLog.writeToFile(str(msg) + " [removePHP]") return 0 - except ValueError, msg: + except ValueError as msg: logging.InstallLog.writeToFile(str(msg) + " [removePHP]") return 0 return 1 diff --git a/install/venvsetup.sh b/install/venvsetup.sh new file mode 100644 index 000000000..b32d97fe7 --- /dev/null +++ b/install/venvsetup.sh @@ -0,0 +1,1290 @@ +#!/bin/bash + +#CyberPanel installer script for Ubuntu 18.04 and CentOS 7.X +DEV="OFF" +BRANCH="stable" +POSTFIX_VARIABLE="ON" +POWERDNS_VARIABLE="ON" +PUREFTPD_VARIABLE="ON" +PROVIDER="undefined" +SERIAL_NO="" +DIR=$(pwd) +TEMP=$(curl --silent https://cyberpanel.net/version.txt) +CP_VER1=${TEMP:12:3} +CP_VER2=${TEMP:25:1} +SERVER_OS="CentOS" +VERSION="OLS" +LICENSE_KEY="" +KEY_SIZE="" +ADMIN_PASS="1234567" +MEMCACHED="ON" +REDIS="ON" +TOTAL_RAM=$(free -m | awk '/Mem\:/ { print $2 }') + +license_validation() { +CURRENT_DIR=$(pwd) + +if [ -f /root/cyberpanel-tmp ] ; then +rm -rf /root/cyberpanel-tmp +fi + +mkdir /root/cyberpanel-tmp +cd /root/cyberpanel-tmp +wget -q https://$DOWNLOAD_SERVER/litespeed/lsws-$LSWS_STABLE_VER-ent-x86_64-linux.tar.gz +tar xzvf lsws-$LSWS_STABLE_VER-ent-x86_64-linux.tar.gz > /dev/null +cd /root/cyberpanel-tmp/lsws-$LSWS_STABLE_VER/conf +if [[ $LICENSE_KEY == "TRIAL" ]] ; then +wget -q http://license.litespeedtech.com/reseller/trial.key +sed -i "s|writeSerial = open('lsws-5.4.2/serial.no', 'w')|command = 'wget -q --output-document=./lsws-$LSWS_STABLE_VER/trial.key http://license.litespeedtech.com/reseller/trial.key'|g" $CURRENT_DIR/installCyberPanel.py +sed -i 's|writeSerial.writelines(self.serial)|subprocess.call(command, shell=True)|g' $CURRENT_DIR/installCyberPanel.py +sed -i 's|writeSerial.close()||g' $CURRENT_DIR/installCyberPanel.py +else +echo $LICENSE_KEY > serial.no +fi + +cd /root/cyberpanel-tmp/lsws-$LSWS_STABLE_VER/bin + +if [[ $LICENSE_KEY == "TRIAL" ]] ; then + if ./lshttpd -V |& grep "ERROR" ; then + echo -e "\n\nIt apeears to have some issue with license , please check above result..." + exit + fi + LICENSE_KEY="1111-2222-3333-4444" +else + if ./lshttpd -r |& grep "ERROR" ; then + ./lshttpd -r + echo -e "\n\nIt apeears to have some issue with license , please check above result..." + exit + fi +fi +echo -e "License seems valid..." +cd /root/cyberpanel-tmp +rm -rf lsws-$LSWS_STABLE_VER* +cd $CURRENT_DIR +rm -rf /root/cyberpanel-tmp +} + +special_change(){ +sed -i 's|cyberpanel.sh|'$DOWNLOAD_SERVER'|g' install.py +sed -i 's|mirror.cyberpanel.net|'$DOWNLOAD_SERVER'|g' install.py +sed -i 's|git clone https://github.com/usmannasir/cyberpanel|echo downloaded|g' install.py +#change to CDN first, regardless country +sed -i 's|http://|https://|g' install.py + +LATEST_URL="https://update.litespeedtech.com/ws/latest.php" +#LATEST_URL="https://cyberpanel.sh/latest.php" +curl --silent -o /tmp/lsws_latest $LATEST_URL 2>/dev/null +LSWS_STABLE_LINE=`cat /tmp/lsws_latest | grep LSWS_STABLE` +LSWS_STABLE_VER=`expr "$LSWS_STABLE_LINE" : '.*LSWS_STABLE=\(.*\) BUILD .*'` + +if [[ $SERVER_COUNTRY == "CN" ]] ; then +#line1="$(grep -n "github.com/usmannasir/cyberpanel" install.py | head -n 1 | cut -d: -f1)" +#line2=$((line1 - 1)) +#sed -i "${line2}i\ \ \ \ \ \ \ \ subprocess.call(command, shell=True)" install.py +#sed -i "${line2}i\ \ \ \ \ \ \ \ command = 'tar xzvf cyberpanel-git.tar.gz'" install.py +#sed -i "${line2}i\ \ \ \ \ \ \ \ subprocess.call(command, shell=True)" install.py +#sed -i "${line2}i\ \ \ \ \ \ \ \ command = 'wget cyberpanel.sh/cyberpanel-git.tar.gz'" install.py +sed -i 's|wget https://rpms.litespeedtech.com/debian/|wget --no-check-certificate https://rpms.litespeedtech.com/debian/|g' install.py +sed -i 's|https://repo.powerdns.com/repo-files/centos-auth-42.repo|https://'$DOWNLOAD_SERVER'/powerdns/powerdns.repo|g' installCyberPanel.py +sed -i 's|https://www.rainloop.net/repository/webmail/rainloop-community-latest.zip|https://'$DOWNLOAD_SERVER'/misc/rainloop-community-latest.zip|g' install.py + +sed -i 's|rpm -ivh https://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm|curl -o /etc/yum.repos.d/litespeed.repo https://'$DOWNLOAD_SERVER'/litespeed/litespeed.repo|g' install.py + + +sed -i 's|https://copr.fedorainfracloud.org/coprs/copart/restic/repo/epel-7/copart-restic-epel-7.repo|https://'$DOWNLOAD_SERVER'/restic/restic.repo|g' install.py + +sed -i 's|yum -y install https://cyberpanel.sh/gf-release-latest.gf.el7.noarch.rpm|wget -O /etc/yum.repos.d/gf.repo https://'$DOWNLOAD_SERVER'/gf-plus/gf.repo|g' install.py +sed -i 's|dovecot-2.3-latest|dovecot-2.3-latest-mirror|g' install.py +sed -i 's|git clone https://github.com/usmannasir/cyberpanel|wget https://cyberpanel.sh/cyberpanel-git.tar.gz \&\& tar xzvf cyberpanel-git.tar.gz|g' install.py +sed -i 's|https://repo.dovecot.org/ce-2.3-latest/centos/$releasever/RPMS/$basearch|https://'$DOWNLOAD_SERVER'/dovecot/|g' install.py +sed -i 's|'$DOWNLOAD_SERVER'|cyberpanel.sh|g' install.py +sed -i 's|https://www.litespeedtech.com/packages/5.0/lsws-5.4.2-ent-x86_64-linux.tar.gz|https://'$DOWNLOAD_SERVER'/litespeed/lsws-'$LSWS_STABLE_VER'-ent-x86_64-linux.tar.gz|g' installCyberPanel.py +# global change for CN , regardless provider and system + + if [[ $SERVER_OS == "CentOS" ]] ; then + DIR=$(pwd) + cd $DIR/mysql + echo "[mariadb-tsinghua] +name = MariaDB +baseurl = https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/10.1/centos7-amd64 +gpgkey = https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum//RPM-GPG-KEY-MariaDB +gpgcheck = 1" > MariaDB.repo +#above to set mariadb db to Tsinghua repo + cd $DIR + sed -i 's|https://www.litespeedtech.com/packages/5.0/lsws-5.3.5-ent-x86_64-linux.tar.gz|https://cyberpanel.sh/packages/5.0/lsws-5.3.5-ent-x86_64-linux.tar.gz|g' installCyberPanel.py + mkdir /root/.pip + cat << EOF > /root/.pip/pip.conf +[global] +index-url = https://mirrors.aliyun.com/pypi/simple/ +EOF + echo -e "\nSet to Aliyun pip repo..." + cat << EOF > composer.sh +#!/usr/bin/env bash +php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +php composer-setup.php +php -r "unlink('composer-setup.php');" +mv composer.phar /usr/bin/composer + +if [ ! -d /root/.config ]; then +mkdir /root/.config +fi + +if [ ! -d /root/.config/composer ]; then +mkdir /root/.config/composer +fi + +echo '{ + "bitbucket-oauth": {}, + "github-oauth": {}, + "gitlab-oauth": {}, + "gitlab-token": {}, + "http-basic": {} +} +' > /root/.config/composer/auth.json + +echo '{ + "config": {}, + "repositories": { + "packagist": { + "type": "composer", + "url": "https://mirrors.aliyun.com/composer/" + } + } +} +' > /root/.config/composer/config.json +composer clear-cache +EOF + fi + + + if [[ $SERVER_OS == "Ubuntu" ]] ; then + echo $'\n89.208.248.38 rpms.litespeedtech.com\n' >> /etc/hosts + echo -e "Mirror server set..." + pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ + cat << EOF > /root/.pip/pip.conf +[global] +index-url = https://mirrors.aliyun.com/pypi/simple/ +EOF + echo -e "\nSet to Aliyun pip repo..." + if [[ $PROVIDER == "Tencent Cloud" ]] ; then + #tencent cloud and ubuntu system + echo -e "\n Tencent Cloud detected ... bypass default repository" + cp /etc/apt/sources.list /etc/apt/sources.list-backup + #backup original sources list + cat << 'EOF' > /etc/apt/sources.list +deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse +deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse +deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse +deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse +deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse +deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse +deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse +deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse +deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse +deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse +EOF + DEBIAN_FRONTEND=noninteractive apt update -y + pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ + cat << EOF > composer.sh +#!/usr/bin/env bash +php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +php composer-setup.php +php -r "unlink('composer-setup.php');" +mv composer.phar /usr/bin/composer + +if [ ! -d /root/.config ]; then +mkdir /root/.config +fi + +if [ ! -d /root/.config/composer ]; then +mkdir /root/.config/composer +fi + +echo '{ + "bitbucket-oauth": {}, + "github-oauth": {}, + "gitlab-oauth": {}, + "gitlab-token": {}, + "http-basic": {} +} +' > /root/.config/composer/auth.json + +echo '{ + "config": {}, + "repositories": { + "packagist": { + "type": "composer", + "url": "https://mirrors.cloud.tencent.com/composer/" + } + } +} +' > /root/.config/composer/config.json +composer clear-cache +EOF + else + cat << EOF > composer.sh +#!/usr/bin/env bash +php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +php composer-setup.php +php -r "unlink('composer-setup.php');" +mv composer.phar /usr/bin/composer + +if [ ! -d /root/.config ]; then +mkdir /root/.config +fi + +if [ ! -d /root/.config/composer ]; then +mkdir /root/.config/composer +fi + +echo '{ + "bitbucket-oauth": {}, + "github-oauth": {}, + "gitlab-oauth": {}, + "gitlab-token": {}, + "http-basic": {} +} +' > /root/.config/composer/auth.json + +echo '{ + "config": {}, + "repositories": { + "packagist": { + "type": "composer", + "url": "https://packagist.phpcomposer.com" + } + } +} +' > /root/.config/composer/config.json +composer clear-cache +EOF + fi + fi +fi +} + + +system_tweak() { +if [[ $SERVER_OS == "CentOS" ]] ; then + setenforce 0 + sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config +fi + +if ! grep -q "pid_max" /etc/rc.local; then + if [[ $SERVER_OS == "CentOS" ]] ; then + echo "echo 1000000 > /proc/sys/kernel/pid_max +echo 1 > /sys/kernel/mm/ksm/run" >> /etc/rc.d/rc.local + chmod +x /etc/rc.d/rc.local + else + echo "echo 1000000 > /proc/sys/kernel/pid_max +echo 1 > /sys/kernel/mm/ksm/run" >> /etc/rc.local + chmod +x /etc/rc.local + fi + echo "fs.file-max = 65535" >> /etc/sysctl.conf + sysctl -p > /dev/null + echo "* soft nofile 65535 +* hard nofile 65535 +root soft nofile 65535 +root hard nofile 65535 +* soft nproc 65535 +* hard nproc 65535 +root soft nproc 65535 +root hard nproc 65535" >> /etc/security/limits.conf +fi + +#sed -i 's|#DefaultLimitNOFILE=|DefaultLimitNOFILE=65535|g' /etc/systemd/system.conf + + +TOTAL_SWAP=$(free -m | awk '/^Swap:/ { print $2 }') +SET_SWAP=$((TOTAL_RAM - TOTAL_SWAP)) +SWAP_FILE=/cyberpanel.swap + +if [ ! -f $SWAP_FILE ] ; then + if [[ $TOTAL_SWAP -gt $TOTAL_RAM ]] || [[ $TOTAL_SWAP -eq $TOTAL_RAM ]] ; then + echo "SWAP check..." + else + if [[ $SET_SWAP -gt "2049" ]] ; then + SET_SWAP="2048" + else + echo "Checking SWAP..." + fi + fallocate --length ${SET_SWAP}MiB $SWAP_FILE + chmod 600 $SWAP_FILE + mkswap $SWAP_FILE + swapon $SWAP_FILE + echo "${SWAP_FILE} swap swap sw 0 0" | sudo tee -a /etc/fstab + sysctl vm.swappiness=10 + echo "vm.swappiness = 10" >> /etc/sysctl.conf + echo "SWAP set..." + fi +fi +} + + +install_required() { +echo -e "\nInstalling necessary components..." +if [[ $SERVER_OS == "CentOS" ]] ; then + rpm --import https://$DOWNLOAD_SERVER/mariadb/RPM-GPG-KEY-MariaDB + rpm --import https://$DOWNLOAD_SERVER/litespeed/RPM-GPG-KEY-litespeed + rpm --import https://$DOWNLOAD_SERVER/powerdns/FD380FBB-pub.asc + rpm --import http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7 + rpm --import https://$DOWNLOAD_SERVER/gf-plus/RPM-GPG-KEY-gf.el7 + rpm --import https://repo.dovecot.org/DOVECOT-REPO-GPG + rpm --import https://copr-be.cloud.fedoraproject.org/results/copart/restic/pubkey.gpg + yum autoremove epel-release -y + rm -f /etc/yum.repos.d/epel.repo + rm -f /etc/yum.repos.d/epel.repo.rpmsave + yum clean all + yum update -y + yum install epel-release -y + yum install -y wget strace htop net-tools telnet curl which bc telnet htop libevent-devel gcc python-devel libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel python-pip git + if [[ $DEV == "ON" ]] ; then + yum -y install yum-utils + yum -y groupinstall development + yum -y install https://centos7.iuscommunity.org/ius-release.rpm + yum -y install python36u python36u-pip python36u-devel + fi +fi + +if [[ $SERVER_OS == "Ubuntu" ]] ; then + apt update -y + DEBIAN_FRONTEND=noninteractive apt upgrade -y + DEBIAN_FRONTEND=noninteracitve apt install -y htop telnet python-mysqldb python-dev libcurl4-gnutls-dev libgnutls28-dev libgcrypt20-dev libattr1 libattr1-dev liblzma-dev libgpgme-dev libmariadbclient-dev libcurl4-gnutls-dev libssl-dev nghttp2 libnghttp2-dev idn2 libidn2-dev libidn2-0-dev librtmp-dev libpsl-dev nettle-dev libgnutls28-dev libldap2-dev libgssapi-krb5-2 libk5crypto3 libkrb5-dev libcomerr2 libldap2-dev python-gpg python python-minimal python-setuptools virtualenv python-dev python-pip git + if [[ $DEV == "ON" ]] ; then + DEBIAN_FRONTEND=noninteractive apt install -y python3-pip + DEBIAN_FRONTEND=noninteractive apt install -y build-essential libssl-dev libffi-dev python3-dev + DEBIAN_FRONTEND=noninteractive apt install -y python3-venv + fi +fi +} + +memcached_installation() { +if [[ $SERVER_OS == "CentOS" ]] ; then + yum install -y lsphp73-memcached lsphp72-memcached lsphp71-memcached lsphp70-memcached lsphp56-pecl-memcached lsphp55-pecl-memcached lsphp54-pecl-memcached + if [[ $TOTAL_RAM -eq "2048" ]] || [[ $TOTAL_RAM -gt "2048" ]] ; then + yum groupinstall "Development Tools" -y + yum install autoconf automake zlib-devel openssl-devel expat-devel pcre-devel libmemcached-devel cyrus-sasl* -y + wget https://$DOWNLOAD_SERVER/litespeed/lsmcd.tar.gz + tar xzvf lsmcd.tar.gz + DIR=$(pwd) + cd $DIR/lsmcd + ./fixtimestamp.sh + ./configure CFLAGS=" -O3" CXXFLAGS=" -O3" + make + make install + systemctl enable lsmcd + systemctl start lsmcd + cd $DIR + else + yum install -y memcached + sed -i 's|OPTIONS=""|OPTIONS="-l 127.0.0.1 -U 0"|g' /etc/sysconfig/memcached + systemctl enable memcached + systemctl start memcached + fi +fi +if [[ $SERVER_OS == "Ubuntu" ]] ; then + DEBIAN_FRONTEND=noninteractive apt install -y lsphp73-memcached lsphp72-memcached lsphp71-memcached lsphp70-memcached + if [[ $TOTAL_RAM -eq "2048" ]] || [[ $TOTAL_RAM -gt "2048" ]] ; then + DEBIAN_FRONTEND=noninteractive apt install build-essential zlib1g-dev libexpat1-dev openssl libssl-dev libsasl2-dev libpcre3-dev git -y + wget https://$DOWNLOAD/litespeed/lsmcd.tar.gz + tar xzvf lsmcd.tar.gz + DIR=$(pwd) + cd $DIR/lsmcd + ./fixtimestamp.sh + ./configure CFLAGS=" -O3" CXXFLAGS=" -O3" + make + make install + cd $DIR + systemctl enable lsmcd + systemctl start lsmcd + else + DEBIAN_FRONTEND=noninteractive apt install -y memcached + systemctl enable memcached + systemctl start memcached + fi +fi + +if ps -aux | grep "lsmcd" | grep -v grep ; then + echo -e "\n\nLiteSpeed Memcached installed and running..." +fi + +if ps -aux | grep "memcached" | grep -v grep ; then + echo -e "\n\nMemcached installed and running..." +fi + +} + +redis_installation() { +if [[ $SERVER_OS == "CentOS" ]] ; then + yum install -y lsphp73-redis lsphp72-redis lsphp71-redis lsphp70-redis lsphp56-redis lsphp55-redis lsphp54-redis redis +fi +if [[ $SERVER_OS == "Ubuntu" ]] ; then + DEBIAN_FRONTEND=noninteractive apt install -y lsphp73-redis lsphp72-redis lsphp71-redis lsphp70-redis redis +fi + +if ifconfig -a | grep inet6 ; then + echo -e "\n IPv6 detected..." +else + sed -i 's|bind 127.0.0.1 ::1|bind 127.0.0.1|g' /etc/redis/redis.conf + echo -e "\n no IPv6 detected..." +fi + +if [[ $SERVER_OS == "CentOS" ]] ; then + systemctl enable redis + systemctl start redis +fi + +if [[ $SERVER_OS == "Ubuntu" ]] ; then + systemctl enable redis-server + systemctl start redis-server +fi + +if ps -aux | grep "redis" | grep -v grep ; then + echo -e "\n\nRedis installed and running..." +fi +} + +check_provider() { + +if hash dmidecode > /dev/null 2>&1 ; then + if [ "$(dmidecode -s bios-vendor)" = 'Google' ] ; then + PROVIDER='Google Cloud Platform' + elif [ "$(dmidecode -s bios-vendor)" = 'DigitalOcean' ] ; then + PROVIDER='Digital Ocean' + elif [ "$(dmidecode -s system-product-name | cut -c 1-7)" = 'Alibaba' ] ; then + PROVIDER='Alibaba Cloud' + elif [ "$(dmidecode -s system-manufacturer)" = 'Microsoft Corporation' ] ; then + PROVIDER='Microsoft Azure' + elif [ -d /usr/local/qcloud ] ; then + PROVIDER='Tencent Cloud' + else + PROVIDER='undefined' + fi +else + PROVIDER='undefined' +fi + +if [ "$(cat /sys/devices/virtual/dmi/id/product_uuid | cut -c 1-3)" = 'EC2' ] && [ -d /home/ubuntu ]; then + PROVIDER='Amazon Web Service' +fi + +} + + +check_OS() { +echo -e "\nChecking OS..." +OUTPUT=$(cat /etc/*release) +if echo $OUTPUT | grep -q "CentOS Linux 7" ; then + echo -e "\nDetecting CentOS 7.X...\n" + SERVER_OS="CentOS" +elif echo $OUTPUT | grep -q "CloudLinux 7" ; then + echo -e "\nDetecting CloudLinux 7.X...\n" + SERVER_OS="CentOS" +elif echo $OUTPUT | grep -q "Ubuntu 18.04" ; then + echo -e "\nDetecting Ubuntu 18.04...\n" + SERVER_OS="Ubuntu" +else + cat /etc/*release + echo -e "\nUnable to detect your OS...\n" + echo -e "\nCyberPanel is supported on Ubuntu 18.04, CentOS 7.x and CloudLinux 7.x...\n" + exit 1 +fi +} + +check_root() { +echo -e "Checking root privileges...\n" +if [[ $(id -u) != 0 ]] > /dev/null; then + echo -e "You must use root account to do this" + echo -e "or run following command: (do NOT miss the quotes)" + echo -e "\e[31msudo su -c \"sh <(curl https://cyberpanel.sh || wget -O - https://cyberpanel.sh)\"\e[39m" + exit 1 +else + echo -e "You are runing as root...\n" +fi +} + +check_panel() { +if [ -d /usr/local/cpanel ]; then + echo -e "\ncPanel detected...exit...\n" + exit 1 +fi +if [ -d /opt/plesk ]; then + echo -e "\nPlesk detected...exit...\n" + exit 1 +fi +} + +check_process() { +if systemctl is-active --quiet httpd; then + systemctl disable httpd + systemctl stop httpd + echo -e "\nhttpd process detected, disabling...\n" +fi +if systemctl is-active --quiet apache2; then + systemctl disable apache2 + systemctl stop apache2 + echo -e "\napache2 process detected, disabling...\n" +fi +if systemctl is-active --quiet named; then + systemctl stop named + systemctl disable named + echo -e "\nnamed process detected, disabling...\n" +fi +if systemctl is-active --quiet exim; then + systemctl stop exim + systemctl disable exim + echo -e "\nexim process detected, disabling...\n" +fi +} + +show_help() { +echo -e "\nCyberPanel Installer Script Help\n" +echo -e "\nUsage: wget https://cyberpanel.sh/cyberpanel.sh" +echo -e "\nchmod +x cyberpanel.sh" +echo -e "\n./cyberpanel.sh -v ols/SERIAL_NUMBER -c 1 -a 1" +echo -e "\n -v or --version: choose to install CyberPanel OpenLiteSpeed or CyberPanel Enterprise, available options are \e[31mols\e[39m and \e[31mSERIAL_NUMBER\e[39m, default ols" +echo -e "\n Please be aware, this serial number must be obtained from LiteSpeed Store." +echo -e "\n And if this serial number has been used before, it must be released/migrated in Store first, otherwise it will fail to start." +echo -e "\n -a or --addons: install addons: memcached, redis, PHP extension for memcached and redis, 1 for install addons, 0 for not to install, default 0, only applicable for CentOS system." +echo -e "\n -p or --password: set password of new installation, empty for default 1234567, [r] or [random] for randomly generated 16 digital password, any other value besdies [d] and [r(andom)] will be accept as password, default use 1234567." +#echo -e "\n -m: set to minimal mode which will not install PowerDNS, Pure-FTPd and Postfix" +echo -e "\n Example:" +echo -e "\n ./cyberpanel.sh -v ols -p r or ./cyberpanel.sh --version ols --password random" +echo -e "\n This will install CyberPanel OpenLiteSpeed and randomly generate the password." +echo -e "\n ./cyberpanel.sh default" +echo -e "\n This will install everything default , which is OpenLiteSpeed and nothing more.\n" + +} + +license_input() { +VERSION="ENT" +echo -e "\nPlease note that your server has \e[31m$TOTAL_RAM\e[39m RAM" +echo -e "If you are using \e[31mFree Start\e[39m license, It will not start due to \e[31m2GB RAM limit\e[39m.\n" +echo -e "If you do not have any license, you can also use trial license (if server has not used trial license before), type \e[31mTRIAL\e[39m\n" + +printf "%s" "Please input your serial number for LiteSpeed WebServer Enterprise:" +read LICENSE_KEY +if [ -z "$LICENSE_KEY" ] ; then + echo -e "\nPlease provide license key\n" + exit +fi + +echo -e "The serial number you input is: \e[31m$LICENSE_KEY\e[39m" +printf "%s" "Please verify it is correct. [y/N]" +read TMP_YN +if [ -z "$TMP_YN" ] ; then + echo -e "\nPlease type \e[31my\e[39m\n" + exit +fi + +KEY_SIZE=${#LICENSE_KEY} +TMP=$(echo $LICENSE_KEY | cut -c5) +TMP2=$(echo $LICENSE_KEY | cut -c10) +TMP3=$(echo $LICENSE_KEY | cut -c15) + +if [[ $TMP == "-" ]] && [[ $TMP2 == "-" ]] && [[ $TMP3 == "-" ]] && [[ $KEY_SIZE == "19" ]] ; then + echo -e "\nLicense key set..." +elif [[ $LICENSE_KEY == "trial" ]] || [[ $LICENSE_KEY == "TRIAL" ]] || [[ $LICENSE_KEY == "Trial" ]] ; then + echo -e "\nTrial license set..." + LICENSE_KEY="TRIAL" +else + echo -e "\nLicense key seems incorrect, please verify\n" + echo -e "\nIf you are copying/pasting, please make sure you didn't paste blank space...\n" + exit +fi +} + +interactive_mode() { +echo -e " CyberPanel Installer v$CP_VER1$CP_VER2 + + 1. Install CyberPanel. + + 2. Addons and Miscellaneous + + 3. Exit. + + " +read -p " Please enter the number[1-3]: " num +echo "" +case "$num" in + 1) + interactive_install + ;; + 2) + interactive_others + ;; + 3) + exit + ;; + *) + echo -e " Please enter the right number [1-3]\n" + exit + ;; +esac +} + +interactive_others() { +if [ ! -e "/etc/cyberpanel/machineIP" ]; then +echo -e "\nYou don't have CyberPanel installed...\n" +exit +fi + +echo -e " CyberPanel Addons v$CP_VER1$CP_VER2 + + 1. Install Memcached extension and backend + + 2. Install Redis extension and backend + + 3. Return to main page. + + 4. Exit + " + +echo && read -p "Please enter the number[1-4]: " num +case "$num" in + 1) + memcached_installation + exit + ;; + 2) + redis_installation + exit + ;; + 3) + interactive_mode + ;; + 4) + exit + ;; + *) + echo -e "${Error} please enter the right number [1-4]" + ;; +esac +} + +interactive_install() { +RAM=$(free -m | awk 'NR==2{printf "%s/%sMB (%.2f%%)\n", $3,$2,$3*100/$2 }') +DISK=$(df -h | awk '$NF=="/"{printf "%d/%dGB (%s)\n", $3,$2,$5}') +#clear +echo -e " CyberPanel Installer v$CP_VER1$CP_VER2 + + RAM check : $RAM + + Disk check : $DISK (Minimal \e[31m10GB\e[39m free space) + + 1. Install CyberPanel with \e[31mOpenLiteSpeed\e[39m. + + 2. Install Cyberpanel with \e[31mLiteSpeed Enterprise\e[39m. + + 3. Exit. + + " +read -p " Please enter the number[1-3]: " num +echo "" +case "$num" in + 1) + VERSION="OLS" + ;; + 2) + license_input + ;; + 3) + exit + ;; + *) + echo -e " Please enter the right number [1-3]\n" + exit + ;; +esac + +< /dev/null; then + echo -e "\nCyberPanel installation sucessfully completed..." +else + echo -e "Oops, something went wrong..." + exit +fi + +if [[ $MEMCACHED == "ON" ]] ; then + memcached_installation +fi +if [[ $REDIS == "ON" ]] ; then + redis_installation +fi + after_install +fi +} + +pip_virtualenv() { +if [[ $DEV == "OFF" ]] ; then +if [[ $SERVER_COUNTRY == "CN" ]] ; then + mkdir /root/.pip +cat << EOF > /root/.pip/pip.conf +[global] +index-url = https://mirrors.aliyun.com/pypi/simple/ +EOF +fi + +if [[ $PROVIDER == "Alibaba Cloud" ]] ; then + pip install --upgrade pip + pip install setuptools==40.8.0 +fi + +pip install virtualenv +virtualenv --system-site-packages /usr/local/CyberPanel +source /usr/local/CyberPanel/bin/activate +rm -rf requirements.txt +wget -O requirements.txt https://raw.githubusercontent.com/usmannasir/cyberpanel/1.8.0/requirments.txt +pip install --ignore-installed -r requirements.txt +virtualenv --system-site-packages /usr/local/CyberPanel +fi + +if [[ $DEV == "ON" ]] ; then + #install dev branch + #wget https://raw.githubusercontent.com/usmannasir/cyberpanel/$BRANCH_NAME/requirments.txt + cd /usr/local/ + python3.6 -m venv CyberPanel + source /usr/local/CyberPanel/bin/activate + wget -O requirements.txt https://raw.githubusercontent.com/usmannasir/cyberpanel/$BRANCH_NAME/requirments.txt + pip3.6 install --ignore-installed -r requirements.txt +fi + +if [ -f requirements.txt ] && [ -d cyberpanel ] ; then + rm -rf cyberpanel + rm -f requirements.txt +fi + +if [[ $SERVER_COUNTRY == "CN" ]] ; then + wget https://cyberpanel.sh/cyberpanel-git.tar.gz + tar xzvf cyberpanel-git.tar.gz > /dev/null + cp -r cyberpanel /usr/local/cyberpanel + cd cyberpanel/install +else + if [[ $DEV == "ON" ]] ; then + git clone https://github.com/usmannasir/cyberpanel + cd cyberpanel + git checkout $BRANCH_NAME + cd - + cd cyberpanel/install + else + git clone https://github.com/usmannasir/cyberpanel + cd cyberpanel/install + fi +fi +curl https://cyberpanel.sh/?version +} + +after_install() { +if [ ! -d "/var/lib/php" ]; then + mkdir /var/lib/php +fi + +if [ ! -d "/var/lib/php/session" ]; then + mkdir /var/lib/php/session +fi + +chmod 1733 /var/lib/php/session + +if grep "\[ERROR\] We are not able to run ./install.sh return code: 1. Fatal error, see /var/log/installLogs.txt for full details" /var/log/installLogs.txt > /dev/null; then + cd ${DIR}/cyberpanel/install/lsws-* + ./install.sh + echo -e "\n\n\nIt seems LiteSpeed Enterprise has failed to install, please check your license key is valid" + echo -e "\nIf this license key has been used before, you may need to go to store to release it first." + exit +fi + + +if grep "CyberPanel installation successfully completed" /var/log/installLogs.txt > /dev/null; then + +if [[ $DEV == "ON" ]] ; then +python3.6 -m venv /usr/local/CyberCP +source /usr/local/CyberCP/bin/activate +wget -O requirements.txt https://raw.githubusercontent.com/usmannasir/cyberpanel/$BRANCH_NAME/requirments.txt +pip3.6 install --ignore-installed -r requirements.txt +systemctl restart lscpd +fi + +for version in $(ls /usr/local/lsws | grep lsphp); + do + php_ini=$(find /usr/local/lsws/$version/ -name php.ini) + version2=${version:5:2} + version2=$(awk "BEGIN { print "${version2}/10" }") + if [[ $version2 = "7" ]] ; then + version2="7.0" + fi + if [[ $SERVER_OS == "CentOS" ]] ; then + yum remove -y $version-mysql + yum install -y $version-mysqlnd + yum install -y $version-devel make gcc glibc-devel libmemcached-devel zlib-devel + if [[ ! -d /usr/local/lsws/$version/tmp ]] ; then + mkdir /usr/local/lsws/$version/tmp + fi + /usr/local/lsws/${version}/bin/pecl channel-update pecl.php.net; + /usr/local/lsws/${version}/bin/pear config-set temp_dir /usr/local/lsws/${version}/tmp + /usr/local/lsws/${version}/bin/pecl install timezonedb + echo "extension=timezonedb.so" > /usr/local/lsws/${version}/etc/php.d/20-timezone.ini + sed -i 's|expose_php = On|expose_php = Off|g' $php_ini + sed -i 's|mail.add_x_header = On|mail.add_x_header = Off|g' $php_ini + sed -i 's|;session.save_path = "/tmp"|session.save_path = "/var/lib/php/session"|g' $php_ini + fi + + if [[ $SERVER_OS == "Ubuntu" ]] ; then + if [[ ! -d /usr/local/lsws/cyberpanel-tmp ]] ; then + echo "yes" > /etc/pure-ftpd/conf/ChrootEveryone + systemctl restart pure-ftpd-mysql + DEBIAN_FRONTEND=noninteractive apt install libmagickwand-dev pkg-config build-essential -y + mkdir /usr/local/lsws/cyberpanel-tmp + cd /usr/local/lsws/cyberpanel-tmp + wget https://pecl.php.net/get/timezonedb-2019.3.tgz + tar xzvf timezonedb-2019.3.tgz + cd timezonedb-2019.3 + fi + /usr/local/lsws/${version}/bin/phpize + ./configure --with-php-config=/usr/local/lsws/${version}/bin/php-config${version2} + make + make install + echo "extension=timezonedb.so" > /usr/local/lsws/${version}/etc/php/${version2}/mods-available/20-timezone.ini + make clean + fi +done + +rm -rf /etc/profile.d/cyberpanel* +curl --silent -o /etc/profile.d/cyberpanel.sh https://cyberpanel.sh/?banner 2>/dev/null +chmod +x /etc/profile.d/cyberpanel.sh +RAM2=$(free -m | awk 'NR==2{printf "%s/%sMB (%.2f%%)\n", $3,$2,$3*100/$2 }') +DISK2=$(df -h | awk '$NF=="/"{printf "%d/%dGB (%s)\n", $3,$2,$5}') +ELAPSED="$(($SECONDS / 3600)) hrs $((($SECONDS / 60) % 60)) min $(($SECONDS % 60)) sec" +MYSQLPASSWD=$(cat /etc/cyberpanel/mysqlPassword) +echo "$ADMIN_PASS" > /etc/cyberpanel/adminPass +/usr/local/CyberPanel/bin/python2 /usr/local/CyberCP/plogical/adminPass.py --password $ADMIN_PASS +systemctl restart lscpd +systemctl restart lsws +echo "/usr/local/CyberPanel/bin/python2 /usr/local/CyberCP/plogical/adminPass.py --password \$@" > /usr/bin/adminPass +echo "systemctl restart lscpd" >> /usr/bin/adminPass +chmod +x /usr/bin/adminPass +if [[ $VERSION = "OLS" ]] ; then + WORD="OpenLiteSpeed" +# sed -i 's|maxConnections 10000|maxConnections 100000|g' /usr/local/lsws/conf/httpd_config.conf +# OLS_LATEST=$(curl https://openlitespeed.org/packages/release) +# wget https://openlitespeed.org/packages/openlitespeed-$OLS_LATEST.tgz +# tar xzvf openlitespeed-$OLS_LATEST.tgz +# cd openlitespeed +# ./install.sh + /usr/local/lsws/bin/lswsctrl stop + /usr/local/lsws/bin/lswsctrl start +# rm -f openlitespeed-$OLS_LATEST.tgz +# rm -rf openlitespeed +# cd .. +fi +if [[ $VERSION = "ENT" ]] ; then + WORD="LiteSpeed Enterprise" + if [[ $SERVER_COUNTRY != "CN" ]] ; then + /usr/local/lsws/admin/misc/lsup.sh -f -v $LSWS_STABLE_VER + fi +fi + +systemctl status lsws 2>&1>/dev/null +if [[ $? == "0" ]] ; then + echo "LSWS service is running..." +else + systemctl stop lsws + systemctl start lsws +fi + +clear +echo "###################################################################" +echo " CyberPanel Successfully Installed " +echo " " +echo " Current Disk usage : $DISK2 " +echo " " +echo " Current RAM usage : $RAM2 " +echo " " +echo " Installation time : $ELAPSED " +echo " " +echo " Visit: https://$SERVER_IP:8090 " +echo " Panel username: admin " +echo " Panel password: $ADMIN_PASS " +#echo " Mysql username: root " +#echo " Mysql password: $MYSQLPASSWD " +echo " " +echo " Please change your default admin password " +echo " If you need to reset your panel password, please run: " +echo " adminPass YOUR_NEW_PASSWORD " +echo " " +echo " If you change mysql password, please modify file in " +echo -e " \e[31m/etc/cyberpanel/mysqlPassword\e[39m with new password as well " +echo " " +echo " Website : https://www.cyberpanel.net " +echo " Forums : https://forums.cyberpanel.net " +echo " Wikipage: https://docs.cyberpanel.net " +echo " " +echo -e " Enjoy your accelerated Internet by " +echo -e " CyberPanel & $WORD " +echo "###################################################################" +if [[ $PROVIDER != "undefined" ]] ; then + echo -e "\033[0;32m$PROVIDER\033[39m detected..." + echo -e "This provider has a \e[31mnetwork-level firewall\033[39m" +else + echo -e "If your provider has a \e[31mnetwork-level firewall\033[39m" +fi + echo -e "Please make sure you have opened following port for both in/out:" + echo -e "\033[0;32mTCP: 8090\033[39m for CyberPanel" + echo -e "\033[0;32mTCP: 80\033[39m, \033[0;32mTCP: 443\033[39m and \033[0;32mUDP: 443\033[39m for webserver" + echo -e "\033[0;32mTCP: 21\033[39m and \033[0;32mTCP: 40110-40210\033[39m for FTP" + echo -e "\033[0;32mTCP: 25\033[39m, \033[0;32mTCP: 587\033[39m, \033[0;32mTCP: 465\033[39m, \033[0;32mTCP: 110\033[39m, \033[0;32mTCP: 143\033[39m and \033[0;32mTCP: 993\033[39m for mail service" + echo -e "\033[0;32mTCP: 53\033[39m and \033[0;32mUDP: 53\033[39m for DNS service" +if [[ $SERVER_COUNTRY = CN ]] ; then + if [[ $PROVIDER == "Tencent Cloud" ]] ; then + if [[ $SERVER_OS == "Ubuntu" ]] ; then + rm -f /etc/apt/sources.list + mv /etc/apt/sources.list-backup /etc/apt/sources.list +echo > "nameserver 127.0.0.53 +options edns0" /run/systemd/resolve/stub-resolv.conf +echo > "nameserver 127.0.0.53 +options edns0" /etc/resolv.conf + apt update +#revert the previous change on tencent cloud repo. + fi + fi + if [[ $VERSION = "ENT" ]] ; then + sed -i 's|https://www.litespeedtech.com/packages/5.0/lsws-5.3.5-ent-x86_64-linux.tar.gz|https://cyberpanel.sh/packages/5.0/lsws-5.3.5-ent-x86_64-linux.tar.gz|g' /usr/local/CyberCP/install/installCyberPanel.py + sed -i 's|https://www.litespeedtech.com/packages/5.0/lsws-5.3.8-ent-x86_64-linux.tar.gz|https://cyberpanel.sh/packages/5.0/lsws-5.3.8-ent-x86_64-linux.tar.gz|g' /usr/local/CyberCP/serverStatus/serverStatusUtil.py + sed -i 's|https://www.litespeedtech.com/packages/5.0/lsws-5.3.8-ent-x86_64-linux.tar.gz|https://'$DOWNLOAD_SERVER'/litespeed/lsws-'$LSWS_STABLE_VER'-ent-x86_64-linux.tar.gz|g' /usr/local/CyberCP/serverStatus/serverStatusUtil.py + echo -e "If you have install LiteSpeed Enterprise, please run \e[31m/usr/local/lsws/admin/misc/lsup.sh\033[39m to update it to latest." + fi +fi + +sed -i 's|lsws-5.3.8|lsws-'$LSWS_STABLE_VER'|g' /usr/local/CyberCP/serverStatus/serverStatusUtil.py +sed -i 's|lsws-5.4.2|lsws-'$LSWS_STABLE_VER'|g' /usr/local/CyberCP/serverStatus/serverStatusUtil.py +sed -i 's|lsws-5.3.5|lsws-'$LSWS_STABLE_VER'|g' /usr/local/CyberCP/serverStatus/serverStatusUtil.py + +if [[ $SILENT != "ON" ]] ; then +printf "%s" "Would you like to restart your server now? [y/N]: " +read TMP_YN + +if [[ "$TMP_YN" = "N" ]] || [[ "$TMP_YN" = "n" ]] || [[ -z "$TMP_YN" ]]; then +: +else +reboot +exit +fi + +exit +fi +#replace URL for CN + + + +else +echo "something went wrong..." +exit +fi +} + +argument_mode() { +KEY_SIZE=${#VERSION} +TMP=$(echo $VERSION | cut -c5) +TMP2=$(echo $VERSION | cut -c10) +TMP3=$(echo $VERSION | cut -c15) +if [[ $VERSION == "OLS" || $VERSION == "ols" ]] ; then + VERSION="OLS" + echo -e "\nSet to OpenLiteSpeed..." +elif [[ $VERSION == "Trial" ]] || [[ $VERSION == "TRIAL" ]] || [[ $VERSION == "trial" ]] ; then + VERSION="ENT" + LICENSE_KEY="TRIAL" + echo -e "\nLiteSpeed Enterprise trial license set..." +elif [[ $TMP == "-" ]] && [[ $TMP2 == "-" ]] && [[ $TMP3 == "-" ]] && [[ $KEY_SIZE == "19" ]] ; then + LICENSE_KEY=$VERSION + VERSION="ENT" + echo -e "\nLiteSpeed Enterprise license key set..." +else + echo -e "\nCan not recognize the input value \e[31m$VERSION\e[39m " + echo -e "\nPlease verify the input value..." + echo -e "\nPlease run with \e[31m-h\e[39m or \e[31m--help\e[39m for more detail." + exit +fi + +if [[ $ADMIN_PASS == "d" ]] ; then + ADMIN_PASS="1234567" + echo -e "\nSet to default password..." + echo -e "\nAdmin password will be set to \e[31m$ADMIN_PASS\e[39m" +elif [[ $ADMIN_PASS == "r" ]] ; then + ADMIN_PASS=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 ; echo '') + echo -e "\nSet to random-generated password..." + echo -e "\nAdmin password will be set to \e[31m$ADMIN_PASS\e[39m" + echo $ADMIN_PASS +else + echo -e "\nAdmin password will be set to \e[31m$ADMIN_PASS\e[39m" +fi +} + +if [ $# -eq 0 ] ; then + echo -e "\nInitializing...\n" +else + if [[ $1 == "help" ]] ; then + show_help + exit + elif [[ $1 == "dev" ]] ; then + DEV="ON" + DEV_ARG="ON" + SILENT="OFF" + elif [[ $1 == "default" ]] ; then + echo -e "\nThis will start default installation...\n" + SILENT="ON" + POSTFIX_VARIABLE="ON" + POWERDNS_VARIABLE="ON" + PUREFTPD_VARIABLE="ON" + VERSION="OLS" + ADMIN_PASS="1234567" + MEMCACHED="ON" + REDIS="ON" + else + while [ ! -z "${1}" ]; do + case $1 in + -v | --version) shift + if [ "${1}" = '' ]; then + show_help + exit + else + VERSION="${1}" + SILENT="ON" + fi + ;; + -p | --password) shift + if [[ "${1}" == '' ]]; then + ADMIN_PASS="1234567" + elif [[ "${1}" == 'r' ]] || [[ $1 == 'random' ]] ; then + ADMIN_PASS=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 ; echo '') + else + if [ ${1} -lt 8 ] ; then + echo -e "\nPassword lenth less than 8 digital, please choose a more complicated password.\n" + exit + fi + ADMIN_PASS="${1}" + fi + ;; + -a | --addons) + MEMCACHED="ON" + REDIS="ON" + ;; + -m | --minimal) + echo "minimal installation is still work in progress..." + exit + ;; + -h | --help) + show_help + exit + ;; + *) + echo "unknown argument..." + show_help + exit + ;; + esac + shift + done + fi +fi + + + +SERVER_IP=$(curl --silent --max-time 10 -4 https://cyberpanel.sh/?ip) +if [[ $SERVER_IP =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo -e "Valid IP detected..." +else + echo -e "Can not detect IP, exit..." + exit +fi +SERVER_COUNTRY="unknow" +SERVER_COUNTRY=$(curl --silent --max-time 5 https://cyberpanel.sh/?country) +if [[ ${#SERVER_COUNTRY} == "2" ]] || [[ ${#SERVER_COUNTRY} == "6" ]] ; then + echo -e "\nChecking server..." + else + echo -e "\nChecking server..." + SERVER_COUNTRY="unknow" +fi +#SERVER_COUNTRY="CN" +#test string +if [[ $SERVER_COUNTRY == "CN" ]] ; then +DOWNLOAD_SERVER="cyberpanel.sh" +else +DOWNLOAD_SERVER="cdn.cyberpanel.sh" +fi + +check_OS +check_root +check_panel +check_process +check_provider + + + + + +if [[ $SILENT = "ON" ]] ; then +argument_mode +else +interactive_mode +fi + +SECONDS=0 +install_required + +pip_virtualenv + +system_tweak + +main_install \ No newline at end of file diff --git a/loginSystem/admin.py b/loginSystem/admin.py index 0458fe2f6..2dcc5abe5 100755 --- a/loginSystem/admin.py +++ b/loginSystem/admin.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin -import models +from . import models # Register your models here. admin.site.register(models.Administrator) \ No newline at end of file diff --git a/loginSystem/apps.py b/loginSystem/apps.py index b6b5fad7e..408639d32 100755 --- a/loginSystem/apps.py +++ b/loginSystem/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/loginSystem/models.py b/loginSystem/models.py index c00538038..8560e240b 100755 --- a/loginSystem/models.py +++ b/loginSystem/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models @@ -88,7 +88,7 @@ class Administrator(models.Model): securityLevel = models.IntegerField(default=0) initWebsitesLimit = models.IntegerField(default=0) - acl = models.ForeignKey(ACL, default=1) + acl = models.ForeignKey(ACL, default=1, on_delete=models.PROTECT) diff --git a/loginSystem/tests.py b/loginSystem/tests.py index 41600aa02..f0722b38b 100755 --- a/loginSystem/tests.py +++ b/loginSystem/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase, Client from django.urls import reverse diff --git a/loginSystem/urls.py b/loginSystem/urls.py index 93585445a..091b0afb7 100755 --- a/loginSystem/urls.py +++ b/loginSystem/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^$', views.loadLoginPage, name='adminLogin'), diff --git a/loginSystem/views.py b/loginSystem/views.py index 18c3e2da8..1a42e83f0 100755 --- a/loginSystem/views.py +++ b/loginSystem/views.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render from django.http import HttpResponse -from models import Administrator +from .models import Administrator from plogical import hashPassword import json from packages.models import Package @@ -12,7 +12,7 @@ from baseTemplate.models import version from plogical.getSystemInformation import SystemInformation from django.utils.translation import LANGUAGE_SESSION_KEY import CyberCP.settings as settings -from models import ACL +from .models import ACL from plogical.acl import ACLManager from django.views.decorators.csrf import ensure_csrf_cookie from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging @@ -141,7 +141,7 @@ def verifyLogin(request): json_data = json.dumps(data) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: data = {'userID': 0, 'loginStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) @@ -223,7 +223,7 @@ def loadLoginPage(request): firstName="Cyber",lastName="Panel", acl=acl, token=token) admin.save() - vers = version(currentVersion="1.9", build=1) + vers = version(currentVersion="1.9", build=3) vers.save() package = Package(admin=admin, packageName="Default", diskSpace=1000, diff --git a/mailServer/admin.py b/mailServer/admin.py index 13be29d96..4c33e0ec3 100755 --- a/mailServer/admin.py +++ b/mailServer/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/mailServer/apps.py b/mailServer/apps.py index 5ff6ef7af..f1b1eb3ad 100755 --- a/mailServer/apps.py +++ b/mailServer/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/mailServer/mailserverManager.py b/mailServer/mailserverManager.py index 8e4173442..db8ec3c20 100755 --- a/mailServer/mailserverManager.py +++ b/mailServer/mailserverManager.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python # coding=utf-8 import os.path import sys @@ -8,7 +8,7 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") django.setup() from django.shortcuts import render,redirect from django.http import HttpResponse -from models import Domains,EUsers +from .models import Domains,EUsers from loginSystem.views import loadLoginPage import plogical.CyberCPLogFileWriter as logging import json @@ -16,7 +16,7 @@ import shlex import subprocess from plogical.virtualHostUtilities import virtualHostUtilities from plogical.mailUtilities import mailUtilities -import thread +import _thread from dns.models import Domains as dnsDomains from dns.models import Records as dnsRecords from mailServer.models import Forwardings, Pipeprograms @@ -56,7 +56,7 @@ class MailServerManager: return render(self.request, 'mailServer/createEmailAccount.html', {'websiteList': websitesName, "status": 1}) - except BaseException, msg: + except BaseException as msg: return redirect(loadLoginPage) @@ -76,7 +76,7 @@ class MailServerManager: return render(self.request, 'mailServer/listEmails.html', {'websiteList': websitesName, "status": 1}) - except BaseException, msg: + except BaseException as msg: return redirect(loadLoginPage) def submitEmailCreation(self): @@ -115,7 +115,7 @@ class MailServerManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'createEmailStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -137,7 +137,7 @@ class MailServerManager: return render(self.request, 'mailServer/deleteEmailAccount.html', {'websiteList': websitesName, "status": 1}) - except BaseException, msg: + except BaseException as msg: return redirect(loadLoginPage) def getEmailsForDomain(self): @@ -190,7 +190,7 @@ class MailServerManager: return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -221,7 +221,7 @@ class MailServerManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'deleteEmailStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -241,7 +241,7 @@ class MailServerManager: websitesName = websitesName + ACLManager.findChildDomains(websitesName) return render(self.request, 'mailServer/emailForwarding.html', {'websiteList': websitesName, "status": 1}) - except BaseException, msg: + except BaseException as msg: return redirect(loadLoginPage) def fetchCurrentForwardings(self): @@ -320,7 +320,7 @@ class MailServerManager: return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -373,7 +373,7 @@ class MailServerManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'deleteForwardingStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -449,7 +449,7 @@ class MailServerManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'createStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -495,7 +495,7 @@ class MailServerManager: final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -518,7 +518,7 @@ class MailServerManager: return render(self.request, 'mailServer/changeEmailPassword.html', {'websiteList': websitesName, "status": 1}) - except BaseException, msg: + except BaseException as msg: return redirect(loadLoginPage) def submitPasswordChange(self): @@ -548,12 +548,12 @@ class MailServerManager: CentOSPath = '/etc/redhat-release' if os.path.exists(CentOSPath): - password = bcrypt.hashpw(str(password), bcrypt.gensalt()) - password = '{CRYPT}%s' % (password) + password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()) + password = '{CRYPT}%s' % (password.decode()) emailDB.password = password else: - password = bcrypt.hashpw(str(password), bcrypt.gensalt()) - password = '{CRYPT}%s' % (password) + password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()) + password = '{CRYPT}%s' % (password.decode()) emailDB.password = password emailDB.save() @@ -563,7 +563,7 @@ class MailServerManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'passChangeStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -586,7 +586,7 @@ class MailServerManager: return render(self.request, 'mailServer/dkimManager.html', {'websiteList': websitesName, 'openDKIMInstalled': openDKIMInstalled}) - except BaseException, msg: + except BaseException as msg: return redirect(loadLoginPage) def fetchDKIMKeys(self): @@ -623,12 +623,12 @@ class MailServerManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 1, 'fetchStatus': 1, 'keysAvailable': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -650,7 +650,7 @@ class MailServerManager: else: return ACLManager.loadErrorJson() - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py" execPath = execPath + " generateKeys --domain " + domainName output = ProcessUtilities.outputExecutioner(execPath) @@ -694,7 +694,7 @@ class MailServerManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'generateStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -705,10 +705,10 @@ class MailServerManager: currentACL = ACLManager.loadedACL(userID) if ACLManager.currentContextPermission(currentACL, 'dkimManager') == 0: return ACLManager.loadErrorJson('installOpenDKIM', 0) - thread.start_new_thread(mailUtilities.installOpenDKIM, ('Install', 'openDKIM')) + _thread.start_new_thread(mailUtilities.installOpenDKIM, ('Install', 'openDKIM')) final_json = json.dumps({'installOpenDKIM': 1, 'error_message': "None"}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'installOpenDKIM': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -716,11 +716,11 @@ class MailServerManager: def installStatusOpenDKIM(self): try: command = "sudo cat " + mailUtilities.installLogPath - installStatus = subprocess.check_output(shlex.split(command)) + installStatus = subprocess.check_output(shlex.split(command)).decode("utf-8") if installStatus.find("[200]") > -1: - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py" execPath = execPath + " configureOpenDKIM" output = ProcessUtilities.outputExecutioner(execPath) @@ -760,7 +760,7 @@ class MailServerManager: }) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'abort': 1, 'installed': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) diff --git a/mailServer/models.py b/mailServer/models.py index 7e3fe26e7..b190bc617 100755 --- a/mailServer/models.py +++ b/mailServer/models.py @@ -5,7 +5,7 @@ # * Make sure each ForeignKey has `on_delete` set to the desired behavior. # * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table # Feel free to rename the models, but don't rename db_table values or field names. -from __future__ import unicode_literals + from django.db import models from websiteFunctions.models import Websites, ChildDomains diff --git a/mailServer/pluginManager.py b/mailServer/pluginManager.py index fab06b5a0..7b9107a8c 100755 --- a/mailServer/pluginManager.py +++ b/mailServer/pluginManager.py @@ -1,4 +1,4 @@ -from signals import * +from .signals import * from plogical.pluginManagerGlobal import pluginManagerGlobal class pluginManager: diff --git a/mailServer/tests.py b/mailServer/tests.py index b5e055caf..7a144f59e 100755 --- a/mailServer/tests.py +++ b/mailServer/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase import json diff --git a/mailServer/urls.py b/mailServer/urls.py index 6d4680075..74d902484 100755 --- a/mailServer/urls.py +++ b/mailServer/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^$', views.loadEmailHome, name='loadEmailHome'), diff --git a/mailServer/views.py b/mailServer/views.py index 78d9b6ab9..337567c07 100755 --- a/mailServer/views.py +++ b/mailServer/views.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import redirect from django.http import HttpResponse from loginSystem.views import loadLoginPage import json -from mailserverManager import MailServerManager -from pluginManager import pluginManager +from .mailserverManager import MailServerManager +from .pluginManager import pluginManager def loadEmailHome(request): try: @@ -66,7 +66,7 @@ def getEmailsForDomain(request): try: msM = MailServerManager(request) return msM.getEmailsForDomain() - except KeyError,msg: + except KeyError as msg: data_ret = {'fetchStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -86,7 +86,7 @@ def submitEmailDeletion(request): return result return coreResult - except KeyError,msg: + except KeyError as msg: data_ret = {'deleteEmailStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -102,7 +102,7 @@ def fetchCurrentForwardings(request): try: msM = MailServerManager(request) return msM.fetchCurrentForwardings() - except KeyError,msg: + except KeyError as msg: data_ret = {'fetchStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -122,7 +122,7 @@ def submitForwardDeletion(request): return result return coreResult - except KeyError,msg: + except KeyError as msg: data_ret = {'deleteEmailStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -142,7 +142,7 @@ def submitEmailForwardingCreation(request): return result return coreResult - except KeyError,msg: + except KeyError as msg: data_ret = {'createStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -171,7 +171,7 @@ def submitPasswordChange(request): return result return coreResult - except KeyError,msg: + except KeyError as msg: data_ret = {'passChangeStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -189,7 +189,7 @@ def fetchDKIMKeys(request): try: msM = MailServerManager(request) return msM.fetchDKIMKeys() - except KeyError,msg: + except KeyError as msg: data_ret = {'fetchStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -209,7 +209,7 @@ def generateDKIMKeys(request): return result return coreResult - except BaseException, msg: + except BaseException as msg: data_ret = {'generateStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) diff --git a/managePHP/admin.py b/managePHP/admin.py index 3ccc77a21..ca64a0bcd 100755 --- a/managePHP/admin.py +++ b/managePHP/admin.py @@ -1,7 +1,7 @@ -from __future__ import unicode_literals + from django.contrib import admin -import models +from . import models # Register your models here. diff --git a/managePHP/apps.py b/managePHP/apps.py index 0327fb030..f7161b6e4 100755 --- a/managePHP/apps.py +++ b/managePHP/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/managePHP/models.py b/managePHP/models.py index 549cc49c7..6b00d2e33 100755 --- a/managePHP/models.py +++ b/managePHP/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/managePHP/phpManager.py b/managePHP/phpManager.py index 59ad15315..a75034667 100755 --- a/managePHP/phpManager.py +++ b/managePHP/phpManager.py @@ -11,7 +11,10 @@ class PHPManager: @staticmethod def findPHPVersions(): - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + distro = ProcessUtilities.decideDistro() + if distro == ProcessUtilities.centos: + if distro == ProcessUtilities.cent8: + return ['PHP 7.1', 'PHP 7.2', 'PHP 7.3', 'PHP 7.4'] return ['PHP 5.3', 'PHP 5.4', 'PHP 5.5', 'PHP 5.6', 'PHP 7.0', 'PHP 7.1', 'PHP 7.2', 'PHP 7.3', 'PHP 7.4'] else: return ['PHP 7.0', 'PHP 7.1', 'PHP 7.2', 'PHP 7.3', 'PHP 7.4'] diff --git a/managePHP/tests.py b/managePHP/tests.py index 5982e6bcd..f067dcaac 100755 --- a/managePHP/tests.py +++ b/managePHP/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/managePHP/urls.py b/managePHP/urls.py index 28360c444..6d2a1a83b 100755 --- a/managePHP/urls.py +++ b/managePHP/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^$', views.loadPHPHome, name='loadPHPHome'), diff --git a/managePHP/views.py b/managePHP/views.py index 8375f082b..4ef3a6ecc 100755 --- a/managePHP/views.py +++ b/managePHP/views.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals -import sys -reload(sys) -sys.setdefaultencoding("utf-8") +import sys +import importlib + +importlib.reload(sys) from django.shortcuts import render, redirect from loginSystem.views import loadLoginPage from .models import PHP, installedPackages, ApachePHP, installedPackagesApache @@ -19,7 +19,7 @@ from random import randint from xml.etree import ElementTree from plogical.acl import ACLManager from plogical.processUtilities import ProcessUtilities -from phpManager import PHPManager +from .phpManager import PHPManager # Create your views here. @@ -1275,7 +1275,7 @@ def getExtensionsInformation(request): final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) @@ -1303,10 +1303,10 @@ def submitExtensionRequest(request): type = data['type'] if type == "install": - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py" execPath = execPath + " installPHPExtension --extension " + extensionName else: - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py" execPath = execPath + " unInstallPHPExtension --extension " + extensionName ProcessUtilities.popenExecutioner(execPath) @@ -1314,7 +1314,7 @@ def submitExtensionRequest(request): final_json = json.dumps({'extensionRequestStatus': 1, 'error_message': "None"}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'extensionRequestStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) @@ -1441,7 +1441,7 @@ def getRequestStatus(request): - except BaseException, msg: + except BaseException as msg: final_dic = {'extensionRequestStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1563,12 +1563,12 @@ def getRequestStatusApache(request): - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [getRequestStatusApache]') final_dic = {'status': 0, 'extensionRequestStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except KeyError, msg: + except KeyError as msg: logging.writeToFile(str(msg) + ' [getRequestStatusApache]') final_dic = {'status': 0, 'extensionRequestStatus': 0, 'error_message': "Not Logged In, please refresh the page or login again."} @@ -1667,7 +1667,7 @@ def getCurrentPHPConfig(request): return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) @@ -1726,7 +1726,7 @@ def savePHPConfigBasic(request): ## - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py" execPath = execPath + " savePHPConfigBasic --phpVers " + phpVers + " --allow_url_fopen '" + allow_url_fopen + "' --display_errors '" + display_errors + "' --file_uploads '" + file_uploads + "' --allow_url_include '" + allow_url_include + "' --memory_limit " + memory_limit + " --max_execution_time " + max_execution_time + " --upload_max_filesize " + upload_max_filesize + " --max_input_time " + max_input_time + " --post_max_size " + post_max_size output = ProcessUtilities.outputExecutioner(execPath) @@ -1740,7 +1740,7 @@ def savePHPConfigBasic(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'saveStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1784,7 +1784,7 @@ def getCurrentAdvancedPHPConfig(request): return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1824,7 +1824,7 @@ def savePHPConfigAdvance(request): vhost.write(data['configData']) vhost.close() - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py" execPath = execPath + " savePHPConfigAdvance --phpVers " + path + " --tempPath " + tempPath output = ProcessUtilities.outputExecutioner(execPath) @@ -1838,11 +1838,11 @@ def savePHPConfigAdvance(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except KeyError, msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[saveConfigsToFile]") return HttpResponse("Not Logged in as admin") diff --git a/manageSSL/admin.py b/manageSSL/admin.py index 13be29d96..4c33e0ec3 100755 --- a/manageSSL/admin.py +++ b/manageSSL/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/manageSSL/apps.py b/manageSSL/apps.py index 52532b43b..780a85252 100755 --- a/manageSSL/apps.py +++ b/manageSSL/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/manageSSL/models.py b/manageSSL/models.py index 1dfab7604..4e6a8e76d 100755 --- a/manageSSL/models.py +++ b/manageSSL/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/manageSSL/tests.py b/manageSSL/tests.py index 3c3d87027..859e26504 100755 --- a/manageSSL/tests.py +++ b/manageSSL/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase import json diff --git a/manageSSL/urls.py b/manageSSL/urls.py index 01488e1c6..84488c724 100755 --- a/manageSSL/urls.py +++ b/manageSSL/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^$', views.loadSSLHome, name='loadSSLHome'), diff --git a/manageSSL/views.py b/manageSSL/views.py index 99aa571d7..05ec7e988 100755 --- a/manageSSL/views.py +++ b/manageSSL/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render, redirect from loginSystem.views import loadLoginPage @@ -80,7 +80,7 @@ def issueSSL(request): ## ssl issue - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " issueSSL --virtualHostName " + virtualHost + " --administratorEmail " + adminEmail + " --path " + path output = ProcessUtilities.outputExecutioner(execPath) @@ -102,7 +102,7 @@ def issueSSL(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, "SSL": 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) @@ -163,7 +163,7 @@ def obtainHostNameSSL(request): ## ssl issue - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " issueSSLForHostName --virtualHostName " + virtualHost + " --path " + path output = ProcessUtilities.outputExecutioner(execPath) @@ -180,7 +180,7 @@ def obtainHostNameSSL(request): ## ssl issue ends - except BaseException, msg: + except BaseException as msg: data_ret = {"status": 0, "SSL": 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) @@ -240,7 +240,7 @@ def obtainMailServerSSL(request): ## ssl issue - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " issueSSLForMailServer --virtualHostName " + virtualHost + " --path " + path output = ProcessUtilities.outputExecutioner(execPath) @@ -258,12 +258,12 @@ def obtainMailServerSSL(request): ## ssl issue ends - except BaseException, msg: + except BaseException as msg: data_ret = {"status": 0, "SSL": 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except KeyError, msg: + except KeyError as msg: data_ret = {"status": 0, "SSL": 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) diff --git a/manageServices/admin.py b/manageServices/admin.py index 13be29d96..4c33e0ec3 100755 --- a/manageServices/admin.py +++ b/manageServices/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/manageServices/apps.py b/manageServices/apps.py index 5009166ee..2a09d9f00 100755 --- a/manageServices/apps.py +++ b/manageServices/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/manageServices/models.py b/manageServices/models.py index e98e554a9..4b99127fa 100755 --- a/manageServices/models.py +++ b/manageServices/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/manageServices/serviceManager.py b/manageServices/serviceManager.py index 9d0afcfb6..c37468a3b 100755 --- a/manageServices/serviceManager.py +++ b/manageServices/serviceManager.py @@ -14,7 +14,7 @@ class ServiceManager: path = '/etc/pdns/pdns.conf' data = ProcessUtilities.outputExecutioner('sudo cat ' + path).splitlines() - #data = subprocess.check_output(shlex.split('sudo cat ' + path)).splitlines() + #data = subprocess.check_output(shlex.split('sudo cat ' + path)).decode("utf-8").splitlines() if type == 'MASTER': diff --git a/manageServices/tests.py b/manageServices/tests.py index 5982e6bcd..f067dcaac 100755 --- a/manageServices/tests.py +++ b/manageServices/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/manageServices/urls.py b/manageServices/urls.py index 23f3a31bf..04a34f863 100755 --- a/manageServices/urls.py +++ b/manageServices/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^managePowerDNS$', views.managePowerDNS, name='managePowerDNS'), diff --git a/manageServices/views.py b/manageServices/views.py index fb289eb3e..1facec6a0 100755 --- a/manageServices/views.py +++ b/manageServices/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render from django.shortcuts import HttpResponse, redirect @@ -9,7 +9,7 @@ import os import json from plogical.mailUtilities import mailUtilities from plogical.acl import ACLManager -from models import PDNSStatus, SlaveServers +from .models import PDNSStatus, SlaveServers from .serviceManager import ServiceManager from plogical.processUtilities import ProcessUtilities # Create your views here. @@ -27,7 +27,7 @@ def managePowerDNS(request): try: return render(request, 'manageServices/managePowerDNS.html', {"status": 1}) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse("See CyberCP main log file.") @@ -47,7 +47,7 @@ def managePostfix(request): return render(request, 'manageServices/managePostfix.html', {"status": 1}) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse("See CyberCP main log file.") @@ -65,7 +65,7 @@ def managePureFtpd(request): return ACLManager.loadError() try: return render(request, 'manageServices/managePureFtpd.html', {"status": 1}) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse("See CyberCP main log file.") @@ -125,12 +125,12 @@ def fetchStatus(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) @@ -268,12 +268,12 @@ def saveStatus(request): return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) diff --git a/packages/admin.py b/packages/admin.py index 87f306cac..75c68f72c 100755 --- a/packages/admin.py +++ b/packages/admin.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin # Register your models here. from django.contrib import admin -import models +from . import models # Register your models here. admin.site.register(models.Package) \ No newline at end of file diff --git a/packages/apps.py b/packages/apps.py index d99b934aa..57e12de16 100755 --- a/packages/apps.py +++ b/packages/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/packages/models.py b/packages/models.py index 50a8931a7..ea0403ff5 100755 --- a/packages/models.py +++ b/packages/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from loginSystem.models import Administrator from django.db import models diff --git a/packages/packagesManager.py b/packages/packagesManager.py index 1a6ff8197..897465283 100755 --- a/packages/packagesManager.py +++ b/packages/packagesManager.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os.path import sys import django @@ -21,7 +21,7 @@ class PackagesManager: try: val = self.request.session['userID'] return render(self.request, 'packages/index.html', {}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def createPacakge(self): @@ -49,7 +49,7 @@ class PackagesManager: packageList = ACLManager.loadPackages(userID, currentACL) return render(self.request, 'packages/deletePackage.html', {"packageList": packageList}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def submitPackage(self): @@ -101,7 +101,7 @@ class PackagesManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -125,7 +125,7 @@ class PackagesManager: return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'deleteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -141,7 +141,7 @@ class PackagesManager: packageList = ACLManager.loadPackages(userID, currentACL) return render(self.request, 'packages/modifyPackage.html', {"packList": packageList}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def submitModify(self): @@ -170,7 +170,7 @@ class PackagesManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'modifyStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -215,7 +215,7 @@ class PackagesManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -232,7 +232,7 @@ class PackagesManager: packageList = ACLManager.loadPackages(userID, currentACL) return render(self.request, 'packages/listPackages.html', {"packList": packageList}) - except BaseException, msg: + except BaseException as msg: return redirect(loadLoginPage) def fetchPackagesTable(self): diff --git a/packages/pluginManager.py b/packages/pluginManager.py index 56d52db88..547d8be44 100755 --- a/packages/pluginManager.py +++ b/packages/pluginManager.py @@ -1,4 +1,4 @@ -from signals import * +from .signals import * from plogical.pluginManagerGlobal import pluginManagerGlobal class pluginManager: diff --git a/packages/tests.py b/packages/tests.py index b4d828661..a41602834 100755 --- a/packages/tests.py +++ b/packages/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase import json diff --git a/packages/urls.py b/packages/urls.py index 0f680c58d..fe335e206 100755 --- a/packages/urls.py +++ b/packages/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^$', views.packagesHome, name='packagesHome'), diff --git a/packages/views.py b/packages/views.py index 731244329..825dbc066 100755 --- a/packages/views.py +++ b/packages/views.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import redirect from loginSystem.views import loadLoginPage -from packagesManager import PackagesManager -from pluginManager import pluginManager +from .packagesManager import PackagesManager +from .pluginManager import pluginManager # Create your views here. diff --git a/plogical/CyberCPLogFileWriter.py b/plogical/CyberCPLogFileWriter.py index 449a321a9..5b2539bfa 100755 --- a/plogical/CyberCPLogFileWriter.py +++ b/plogical/CyberCPLogFileWriter.py @@ -13,7 +13,7 @@ class CyberCPLogFileWriter: "%m.%d.%Y_%H-%M-%S") + "] "+ message + "\n") file.close() - except IOError,msg: + except BaseException as msg: return "Can not write to error file." @staticmethod @@ -24,18 +24,18 @@ class CyberCPLogFileWriter: "%m.%d.%Y_%H-%M-%S") + "] [" + level + ":" + method + "] " + message + "\n") file.close() file.close() - except IOError: + except BaseException: return "Can not write to error file!" @staticmethod def readLastNFiles(numberOfLines,fileName): try: - lastFewLines = subprocess.check_output(["tail", "-n",str(numberOfLines),fileName]) + lastFewLines = str(subprocess.check_output(["tail", "-n",str(numberOfLines),fileName]).decode("utf-8")) return lastFewLines - except subprocess.CalledProcessError,msg: + except subprocess.CalledProcessError as msg: return "File was empty" @staticmethod @@ -47,8 +47,8 @@ class CyberCPLogFileWriter: statusFile = open(tempStatusPath, 'a') statusFile.writelines(mesg + '\n') statusFile.close() - print(mesg + '\n') - except BaseException, msg: + print((mesg + '\n')) + except BaseException as msg: CyberCPLogFileWriter.writeToFile(str(msg) + ' [statusWriter]') #print str(msg) diff --git a/plogical/IncScheduler.py b/plogical/IncScheduler.py index 6e874bf7c..eeeffb886 100644 --- a/plogical/IncScheduler.py +++ b/plogical/IncScheduler.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os.path import sys sys.path.append('/usr/local/CyberCP') @@ -79,7 +79,7 @@ class IncScheduler(): logging.statusWriter(IncScheduler.logPath, 'Failed backup for %s, error: %s.' % (web.website, result), 1) break - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) diff --git a/plogical/acl.py b/plogical/acl.py index 679c8e367..51db810b5 100755 --- a/plogical/acl.py +++ b/plogical/acl.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os,sys sys.path.append('/usr/local/CyberCP') import django @@ -12,7 +12,7 @@ from dns.models import Domains import json from subprocess import call, CalledProcessError from shlex import split -from CyberCPLogFileWriter import CyberCPLogFileWriter as logging +from .CyberCPLogFileWriter import CyberCPLogFileWriter as logging from dockerManager.models import Containers class ACLManager: @@ -30,7 +30,7 @@ class ACLManager: f = open(ipFile) ipData = f.read() serverIPAddress = ipData.split('\n', 1)[0] - except BaseException, msg: + except BaseException as msg: serverIPAddress = "192.168.100.1" finalResponse['serverIPAddress'] = serverIPAddress @@ -534,7 +534,7 @@ class ACLManager: return 0, 'Something bad happened' else: return 1, 'None' - except CalledProcessError, msg: + except CalledProcessError as msg: logging.writeToFile(str(msg) + ' [ACLManager.executeCall]') return 0, str(msg) diff --git a/plogical/adminPass.py b/plogical/adminPass.py index 433f317b2..d7036e390 100755 --- a/plogical/adminPass.py +++ b/plogical/adminPass.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os.path import sys import django @@ -11,6 +11,7 @@ from plogical import hashPassword from plogical.acl import ACLManager from packages.models import Package from baseTemplate.models import version +from CLManager.models import CLPackages def main(): @@ -31,13 +32,14 @@ def main(): firstName="Cyber", lastName="Panel", acl=acl, token=token) admin.save() - vers = version(currentVersion="1.9", build=2) + vers = version(currentVersion="1.9", build=3) vers.save() package = Package(admin=admin, packageName="Default", diskSpace=1000, bandwidth=1000, ftpAccounts=1000, dataBases=1000, emailAccounts=1000, allowedDomains=20) package.save() + print("Admin password successfully changed!") return 1 diff --git a/plogical/alias.py b/plogical/alias.py index 769c1bbd7..0c978f1af 100755 --- a/plogical/alias.py +++ b/plogical/alias.py @@ -1,15 +1,10 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os,sys sys.path.append('/usr/local/CyberCP') import django os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") django.setup() -from loginSystem.models import Administrator, ACL -from django.shortcuts import HttpResponse -from packages.models import Package from websiteFunctions.models import Websites -from dns.models import Domains -import json class AliasManager: diff --git a/plogical/apiAccess.py b/plogical/apiAccess.py index 6d4cb1c4e..1c5ec1d38 100755 --- a/plogical/apiAccess.py +++ b/plogical/apiAccess.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os.path import sys import django diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index bba893afa..79ec37dd8 100755 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os, sys sys.path.append('/usr/local/CyberCP') @@ -9,23 +9,25 @@ django.setup() import threading as multi from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging import subprocess -from vhost import vhost +from plogical.vhost import vhost from websiteFunctions.models import ChildDomains, Websites -import randomPassword -from mysqlUtilities import mysqlUtilities +from plogical import randomPassword +from plogical.mysqlUtilities import mysqlUtilities from databases.models import Databases -from installUtilities import installUtilities +from plogical.installUtilities import installUtilities import shutil from plogical.mailUtilities import mailUtilities from plogical.processUtilities import ProcessUtilities + class ApplicationInstaller(multi.Thread): def __init__(self, installApp, extraArgs): multi.Thread.__init__(self) self.installApp = installApp self.extraArgs = extraArgs + self.tempStatusPath = self.extraArgs['tempStatusPath'] def run(self): try: @@ -45,10 +47,91 @@ class ApplicationInstaller(multi.Thread): self.installPrestaShop() elif self.installApp == 'magento': self.installMagento() + elif self.installApp == 'convertDomainToSite': + self.convertDomainToSite() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [ApplicationInstaller.run]') + def convertDomainToSite(self): + try: + + from websiteFunctions.website import WebsiteManager + import json, time + + request = self.extraArgs['request'] + + ## + + statusFile = open(self.tempStatusPath, 'w') + statusFile.writelines('Deleting domain as child..,20') + statusFile.close() + + data = json.loads(request.body) + + domainName = data['domainName'] + + childDomain = ChildDomains.objects.get(domain=domainName) + path = childDomain.path + + wm = WebsiteManager() + + wm.submitDomainDeletion(request.session['userID'], {'websiteName': domainName}) + time.sleep(5) + + ## + + statusFile = open(self.tempStatusPath, 'w') + statusFile.writelines('Creating domain as website..,40') + statusFile.close() + + resp = wm.submitWebsiteCreation(request.session['userID'], data) + respData = json.loads(resp.content.decode('utf-8')) + + ## + + while True: + respDataStatus = ProcessUtilities.outputExecutioner("cat " + respData['tempStatusPath']) + + if respDataStatus.find('[200]') > -1: + break + elif respDataStatus.find('[404]') > -1: + statusFile = open(self.tempStatusPath, 'w') + statusFile.writelines(respDataStatus['currentStatus'] + ' [404]') + statusFile.close() + return 0 + else: + statusFile = open(self.tempStatusPath, 'w') + statusFile.writelines(respDataStatus) + statusFile.close() + time.sleep(1) + + statusFile = open(self.tempStatusPath, 'w') + statusFile.writelines('Moving data..,80') + statusFile.close() + + + command = 'rm -rf /home/%s/public_html' % (domainName) + ProcessUtilities.executioner(command) + + command = 'mv %s /home/%s/public_html' % (path, domainName) + ProcessUtilities.executioner(command) + + website = Websites.objects.get(domain=domainName) + + command = 'chown %s:%s /home/%s/public_html' % (website.externalApp, website.externalApp, domainName) + ProcessUtilities.executioner(command) + + statusFile = open(self.tempStatusPath, 'w') + statusFile.writelines('Successfully converted. [200]') + statusFile.close() + + except BaseException as msg: + statusFile = open(self.tempStatusPath, 'w') + statusFile.writelines(str(msg) + " [404]") + statusFile.close() + return 0 + def installWPCLI(self): try: command = 'sudo wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar' @@ -60,7 +143,7 @@ class ApplicationInstaller(multi.Thread): command = 'sudo mv wp-cli.phar /usr/bin/wp' ProcessUtilities.executioner(command) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [ApplicationInstaller.installWPCLI]') def dataLossCheck(self, finalPath, tempStatusPath): @@ -106,7 +189,7 @@ class ApplicationInstaller(multi.Thread): command = 'sudo yum install git -y' ProcessUtilities.executioner(command) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [ApplicationInstaller.installGit]') def dbCreation(self, tempStatusPath, website): @@ -141,7 +224,7 @@ class ApplicationInstaller(multi.Thread): return dbName, dbUser, dbPassword - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + '[ApplicationInstallerdbCreation]') def installWordPress(self): @@ -298,7 +381,7 @@ class ApplicationInstaller(multi.Thread): return 0 - except BaseException, msg: + except BaseException as msg: # remove the downloaded files FNULL = open(os.devnull, 'w') @@ -469,7 +552,7 @@ class ApplicationInstaller(multi.Thread): return 0 - except BaseException, msg: + except BaseException as msg: # remove the downloaded files homeDir = "/home/" + domainName + "/public_html" @@ -568,7 +651,7 @@ class ApplicationInstaller(multi.Thread): try: command = 'git clone --depth 1 --no-single-branch git@' + defaultProvider + '.com:' + username + '/' + reponame + '.git -b ' + branch + ' ' + finalPath ProcessUtilities.executioner(command, externalApp) - except subprocess.CalledProcessError, msg: + except subprocess.CalledProcessError as msg: statusFile = open(tempStatusPath, 'w') statusFile.writelines( 'Failed to clone repository, make sure you deployed your key to repository. [404]') @@ -596,7 +679,7 @@ class ApplicationInstaller(multi.Thread): return 0 - except BaseException, msg: + except BaseException as msg: os.remove('/home/cyberpanel/' + domainName + '.git') statusFile = open(tempStatusPath, 'w') statusFile.writelines(str(msg) + " [404]") @@ -636,7 +719,7 @@ class ApplicationInstaller(multi.Thread): return 0 - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + " [ApplicationInstaller.gitPull]") return 0 @@ -679,7 +762,7 @@ class ApplicationInstaller(multi.Thread): return 0 - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + " [ApplicationInstaller.gitPull]") return 0 @@ -829,7 +912,7 @@ class ApplicationInstaller(multi.Thread): statusFile.close() return 0 - except BaseException, msg: + except BaseException as msg: # remove the downloaded files homeDir = "/home/" + domainName + "/public_html" @@ -873,11 +956,11 @@ class ApplicationInstaller(multi.Thread): try: command = 'sudo git --git-dir=' + finalPath + '/.git checkout ' + githubBranch ProcessUtilities.executioner(command, externalApp) - except subprocess.CalledProcessError, msg: + except subprocess.CalledProcessError as msg: logging.writeToFile('Failed to change branch: ' + str(msg)) return 0 return 0 - except BaseException, msg: + except BaseException as msg: logging.writeToFile('Failed to change branch: ' + str(msg)) return 0 @@ -1038,7 +1121,7 @@ class ApplicationInstaller(multi.Thread): return 0 - except BaseException, msg: + except BaseException as msg: # remove the downloaded files homeDir = "/home/" + domainName + "/public_html" diff --git a/plogical/backupManager.py b/plogical/backupManager.py index cff44f583..3e2c6fd30 100644 --- a/plogical/backupManager.py +++ b/plogical/backupManager.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os import os.path import sys @@ -7,15 +7,15 @@ sys.path.append('/usr/local/CyberCP') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") django.setup() import json -from acl import ACLManager -import CyberCPLogFileWriter as logging +from plogical.acl import ACLManager +from plogical import CyberCPLogFileWriter as logging from websiteFunctions.models import Websites, Backups, dest, backupSchedules -from virtualHostUtilities import virtualHostUtilities +from plogical.virtualHostUtilities import virtualHostUtilities import subprocess import shlex from django.shortcuts import HttpResponse, render from loginSystem.models import Administrator -from mailUtilities import mailUtilities +from plogical.mailUtilities import mailUtilities from random import randint import time import plogical.backupUtilities as backupUtil @@ -30,7 +30,7 @@ class BackupManager: try: currentACL = ACLManager.loadedACL(userID) return render(request, 'backup/index.html', currentACL) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def backupSite(self, request = None, userID = None, data = None): @@ -42,7 +42,7 @@ class BackupManager: websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'backup/backup.html', {'websiteList': websitesName}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def restoreSite(self, request = None, userID = None, data = None): @@ -70,7 +70,7 @@ class BackupManager: return render(request, 'backup/restore.html', {'backups': all_files}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def getCurrentBackups(self, userID = None, data = None): @@ -112,7 +112,7 @@ class BackupManager: json_data = json_data + ']' final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -151,7 +151,7 @@ class BackupManager: final_json = json.dumps({'status': 1, 'metaStatus': 1, 'error_message': "None", 'tempStorage': tempStoragePath}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) final_dic = {'status': 0, 'metaStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) @@ -168,7 +168,7 @@ class BackupManager: try: backupFileNamePath = os.path.join("/home", backupDomain, "backup/backupFileName") command = "sudo cat " + backupFileNamePath - fileName = subprocess.check_output(shlex.split(command)) + fileName = subprocess.check_output(shlex.split(command)).decode("utf-8") except: fileName = "Fetching.." @@ -176,7 +176,7 @@ class BackupManager: if os.path.exists(status): command = "sudo cat " + status - status = subprocess.check_output(shlex.split(command)) + status = subprocess.check_output(shlex.split(command)).decode("utf-8") if status.find("Completed") > -1: @@ -213,7 +213,7 @@ class BackupManager: for items in backupObs: items.delete() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupStatus]") final_json = json.dumps( @@ -229,7 +229,7 @@ class BackupManager: final_json = json.dumps({'backupStatus': 0, 'error_message': "None", "status": 0, "abort": 0}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'backupStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupStatus]") @@ -250,13 +250,13 @@ class BackupManager: try: backupOb = Backups.objects.get(fileName=fileName) backupOb.delete() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [cancelBackupCreation]") final_json = json.dumps({'abortStatus': 1, 'error_message': "None", "status": 0}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'abortStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -276,7 +276,7 @@ class BackupManager: final_json = json.dumps({'status': 1, 'deleteStatus': 1, 'error_message': "None"}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'deleteStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) @@ -300,7 +300,7 @@ class BackupManager: final_dic = {'restoreStatus': 1, 'error_message': "None"} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'restoreStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -322,7 +322,7 @@ class BackupManager: if os.path.exists(path): try: execPath = "sudo cat " + path + "/status" - status = subprocess.check_output(shlex.split(execPath)) + status = subprocess.check_output(shlex.split(execPath)).decode("utf-8") if status.find("Done") > -1: @@ -347,7 +347,7 @@ class BackupManager: 'running': 'Running..'}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) status = "Just Started" final_json = json.dumps( @@ -360,7 +360,7 @@ class BackupManager: 'abort': 1}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'restoreStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -374,7 +374,7 @@ class BackupManager: return render(request, 'backup/backupDestinations.html', {}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def submitDestinationCreation(self, userID = None, data = None): @@ -410,7 +410,7 @@ class BackupManager: execPath = execPath + " submitDestinationCreation --ipAddress " + ipAddress + " --password " \ + password + " --port " + port - output = subprocess.check_output(shlex.split(execPath)) + output = subprocess.check_output(shlex.split(execPath)).decode("utf-8") if output.find('1,') > -1: try: @@ -436,7 +436,7 @@ class BackupManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'destStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -471,7 +471,7 @@ class BackupManager: final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -488,7 +488,7 @@ class BackupManager: execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" execPath = execPath + " getConnectionStatus --ipAddress " + ipAddress - output = subprocess.check_output(shlex.split(execPath)) + output = subprocess.check_output(shlex.split(execPath)).decode("utf-8") if output.find('1,') > -1: final_dic = {'connStatus': 1, 'error_message': "None"} @@ -499,7 +499,7 @@ class BackupManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'connStatus': 1, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -552,7 +552,7 @@ class BackupManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'delStatus': 1, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -579,7 +579,7 @@ class BackupManager: return render(request, 'backup/backupSchedule.html', {'destinations': destinations}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def getCurrentBackupSchedules(self, userID = None, data = None): @@ -610,7 +610,7 @@ class BackupManager: final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -811,7 +811,7 @@ class BackupManager: final_json = json.dumps({'scheduleStatus': 1, 'error_message': "None"}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_json = json.dumps({'scheduleStatus': 0, 'error_message': str(msg)}) return HttpResponse(final_json) @@ -939,7 +939,7 @@ class BackupManager: final_json = json.dumps({'delStatus': 1, 'error_message': "None"}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_json = json.dumps({'delStatus': 0, 'error_message': str(msg)}) return HttpResponse(final_json) @@ -952,7 +952,7 @@ class BackupManager: return render(request, 'backup/remoteBackups.html') - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def submitRemoteBackups(self, userID = None, data = None): @@ -995,7 +995,7 @@ class BackupManager: return HttpResponse(data_ret) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': "Not able to fetch version of remote server. Error Message: " + str( msg), @@ -1036,7 +1036,7 @@ class BackupManager: execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/remoteTransferUtilities.py" execPath = execPath + " writeAuthKey --pathToKey " + pathToKey - output = subprocess.check_output(shlex.split(execPath)) + output = subprocess.check_output(shlex.split(execPath)).decode("utf-8") if output.find("1,None") > -1: pass @@ -1067,14 +1067,14 @@ class BackupManager: data['error_message'], "dir": "Null"} data_ret = json.dumps(data_ret) return HttpResponse(data_ret) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': "Not able to fetch accounts from remote server. Error Message: " + str( msg), "dir": "Null"} data_ret = json.dumps(data_ret) return HttpResponse(data_ret) - except BaseException, msg: + except BaseException as msg: final_json = json.dumps({'status': 0, 'error_message': str(msg)}) return HttpResponse(final_json) @@ -1132,13 +1132,13 @@ class BackupManager: data['error_message']}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_json = json.dumps({'remoteTransferStatus': 0, 'error_message': "Can not initiate remote transfer. Error message: " + str(msg)}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_json = json.dumps({'remoteTransferStatus': 0, 'error_message': str(msg)}) return HttpResponse(final_json) @@ -1182,7 +1182,7 @@ class BackupManager: 'backupsSent': 0} json_data = json.dumps(data) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data = {'remoteTransferStatus': 0, 'error_message': str(msg), 'backupsSent': 0} json_data = json.dumps(data) return HttpResponse(json_data) @@ -1213,7 +1213,7 @@ class BackupManager: json_data = json.dumps(data) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data = {'remoteRestoreStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) @@ -1236,7 +1236,7 @@ class BackupManager: if os.path.isfile(backupLogPath): command = "sudo cat " + backupLogPath - status = subprocess.check_output(shlex.split(command)) + status = subprocess.check_output(shlex.split(command)).decode("utf-8") if status.find("completed[success]") > -1: command = "sudo rm -rf " + removalPath @@ -1260,7 +1260,7 @@ class BackupManager: "complete": 0} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data = {'remoteTransferStatus': 0, 'error_message': str(msg), "status": "None", "complete": 0} json_data = json.dumps(data) return HttpResponse(json_data) @@ -1294,7 +1294,7 @@ class BackupManager: pathpid = path + "/pid" command = "sudo cat " + pathpid - pid = subprocess.check_output(shlex.split(command)) + pid = subprocess.check_output(shlex.split(command)).decode("utf-8") command = "sudo kill -KILL " + pid subprocess.call(shlex.split(command)) @@ -1306,7 +1306,7 @@ class BackupManager: json_data = json.dumps(data) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data = {'cancelStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data) return HttpResponse(json_data) diff --git a/plogical/backupSchedule.py b/plogical/backupSchedule.py index 12a59ea91..c49c6ac6a 100755 --- a/plogical/backupSchedule.py +++ b/plogical/backupSchedule.py @@ -1,18 +1,18 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os.path import sys import django sys.path.append('/usr/local/CyberCP') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") django.setup() -import CyberCPLogFileWriter as logging +from plogical import CyberCPLogFileWriter as logging import subprocess import shlex import os import time -from backupUtilities import backupUtilities +from plogical.backupUtilities import backupUtilities from re import match,I,M -from websiteFunctions.models import Websites, Backups +from websiteFunctions.models import Backups from plogical.processUtilities import ProcessUtilities from random import randint import json, requests @@ -28,9 +28,9 @@ class backupSchedule: try: file = open(fileName,'a') file.writelines("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] "+ message + "\n") - print ("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] "+ message + "\n") + print(("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] "+ message + "\n")) file.close() - except IOError,msg: + except IOError as msg: return "Can not write to error file." @staticmethod @@ -75,7 +75,7 @@ class backupSchedule: if os.path.exists(status): status = open(status, 'r').read() - print status + print(status) time.sleep(2) if status.find("Completed") > -1: @@ -127,11 +127,7 @@ class backupSchedule: os.remove(schedulerPath) return 0, 'Backup process killed without reporting any error.' - - - - - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [119:startBackup]") return 0, str(msg) @@ -177,7 +173,7 @@ class backupSchedule: backupSchedule.remoteBackupLogging(backupLogPath, "") backupSchedule.remoteBackupLogging(backupLogPath, "") - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupSchedule.createBackup]") @staticmethod @@ -201,7 +197,7 @@ class backupSchedule: os.remove(backupPath) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [189:startBackup]") @staticmethod @@ -258,7 +254,7 @@ class backupSchedule: - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [prepare]") def main(): diff --git a/plogical/backupScheduleLocal.py b/plogical/backupScheduleLocal.py index 73f3d5ae7..089da954f 100755 --- a/plogical/backupScheduleLocal.py +++ b/plogical/backupScheduleLocal.py @@ -1,7 +1,7 @@ -import CyberCPLogFileWriter as logging +from plogical import CyberCPLogFileWriter as logging import os import time -from backupSchedule import backupSchedule +from plogical.backupSchedule import backupSchedule from plogical.processUtilities import ProcessUtilities from re import match,I,M import signal @@ -58,7 +58,7 @@ class backupScheduleLocal: writeToFile.close() - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [214:startBackup]") def main(): diff --git a/plogical/backupUtilities.py b/plogical/backupUtilities.py index bc09d8ddf..1a1a162f2 100755 --- a/plogical/backupUtilities.py +++ b/plogical/backupUtilities.py @@ -7,19 +7,19 @@ try: except: pass import pexpect -import CyberCPLogFileWriter as logging +from plogical import CyberCPLogFileWriter as logging import subprocess import shlex from shutil import make_archive,rmtree -import mysqlUtilities +from plogical import mysqlUtilities import tarfile from multiprocessing import Process import signal -from installUtilities import installUtilities +from plogical.installUtilities import installUtilities import argparse try: - from virtualHostUtilities import virtualHostUtilities - from sslUtilities import sslUtilities + from plogical.virtualHostUtilities import virtualHostUtilities + from plogical.sslUtilities import sslUtilities from plogical.mailUtilities import mailUtilities except: pass @@ -35,7 +35,7 @@ try: from websiteFunctions.models import Websites, ChildDomains, Backups from databases.models import Databases from loginSystem.models import Administrator - from dnsUtilities import DNS + from plogical.dnsUtilities import DNS from mailServer.models import Domains as eDomains from backup.models import DBUsers except: @@ -123,12 +123,12 @@ class backupUtilities: for it in dbusers: dbuser = it break - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( 'While creating backup for %s, we failed to backup database %s. Error message: %s' % ( backupDomain, items.dbName, str(msg))) continue - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( 'While creating backup for %s, we failed to backup database %s. Error message: %s' % ( backupDomain, items.dbName, str(msg))) @@ -163,7 +163,7 @@ class backupUtilities: metaFileXML.append(aliasesXML) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(status, '%s. [167:prepMeta]' % (str(msg))) ## Finish Alias @@ -191,7 +191,7 @@ class backupUtilities: metaFileXML.append(dnsRecordsXML) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(status, '%s. [158:prepMeta]' % (str(msg))) ## Email accounts XML @@ -212,7 +212,7 @@ class backupUtilities: emailRecordsXML.append(emailRecordXML) metaFileXML.append(emailRecordsXML) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(status, '%s. [179:prepMeta]' % (str(msg))) ## Email meta generated! @@ -233,9 +233,9 @@ class backupUtilities: xmlpretty = prettify(metaFileXML).encode('ascii', 'ignore') metaFile = open(metaPath, 'w') - metaFile.write(xmlpretty) + metaFile.write(xmlpretty.decode()) metaFile.close() - os.chmod(metaPath, 0777) + os.chmod(metaPath, 0o777) ## meta generated @@ -249,7 +249,7 @@ class backupUtilities: return 1,'None', metaPath - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(status, "%s [207][5009]" % (str(msg))) return 0,str(msg) @@ -308,9 +308,9 @@ class backupUtilities: make_archive(os.path.join(tempStoragePath,"public_html"), 'gztar', os.path.join("/home",domainName,"public_html")) logging.CyberCPLogFileWriter.statusWriter(status, "Backing up databases..") - print '1,None' + print('1,None') - except BaseException,msg: + except BaseException as msg: try: os.remove(os.path.join(backupPath,backupName+".tar.gz")) except: @@ -323,7 +323,7 @@ class backupUtilities: status = os.path.join(backupPath, 'status') logging.CyberCPLogFileWriter.statusWriter(status, "Aborted, "+ str(msg) + ".[365] [5009]") - print ("Aborted, "+ str(msg) + ".[365] [5009]") + print(("Aborted, "+ str(msg) + ".[365] [5009]")) os.remove(pidFile) @@ -352,7 +352,7 @@ class backupUtilities: os.path.join(tempStoragePath, domainName + ".fullchain.pem")) copy(os.path.join(sslStoragePath, "privkey.pem"), os.path.join(tempStoragePath, domainName + ".privkey.pem")) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile('%s. [283:startBackup]' % (str(msg))) ## Child Domains SSL. @@ -384,7 +384,7 @@ class backupUtilities: sslStoragePath) except: pass - except BaseException, msg: + except BaseException as msg: pass ## backup emails @@ -402,7 +402,7 @@ class backupUtilities: try: make_archive(os.path.join(tempStoragePath, domainName), 'gztar', os.path.join("/home", "vmail", domainName)) - except BaseException, msg: + except BaseException as msg: pass @@ -444,7 +444,7 @@ class backupUtilities: pid = open(backupPath + 'pid', "w") pid.write(str(p.pid)) pid.close() - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [initiateBackup]") @staticmethod @@ -531,7 +531,7 @@ class backupUtilities: return 1,'None' - except BaseException, msg: + except BaseException as msg: return 0, str(msg) @staticmethod @@ -600,7 +600,7 @@ class backupUtilities: copy(completPath + "/" + masterDomain + ".fullchain.pem", sslHome + "/fullchain.pem") sslUtilities.installSSLForDomain(masterDomain) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile('%s. [555:startRestore]' % (str(msg))) else: @@ -666,7 +666,7 @@ class backupUtilities: else: logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + retValues[1] + ". Not able to create child domains, aborting. [635][5009]") return 0 - except BaseException, msg: + except BaseException as msg: status = open(os.path.join(completPath,'status'), "w") status.write("Error Message: " + str(msg) +". Not able to create child domains, aborting. [638][5009]") status.close() @@ -699,7 +699,7 @@ class backupUtilities: if result[0] == 0: raise BaseException(result[1]) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + str(msg) +". Not able to create email accounts, aborting. [671][5009]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startRestore]") return 0 @@ -763,7 +763,7 @@ class backupUtilities: cmd = shlex.split(command) subprocess.call(cmd) - except BaseException, msg: + except BaseException as msg: status = os.path.join(completPath, 'status') logging.CyberCPLogFileWriter.statusWriter(status, str(msg) + " [736][5009]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startRestore]") @@ -773,7 +773,7 @@ class backupUtilities: try: p = Process(target=backupUtilities.startRestore, args=(backupName, dir,)) p.start() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [initiateRestore]") @staticmethod @@ -810,13 +810,13 @@ class backupUtilities: return [1, "None"] - except pexpect.TIMEOUT, msg: + except pexpect.TIMEOUT as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [sendKey]") return [0, "TIMEOUT [sendKey]"] - except pexpect.EOF, msg: + except pexpect.EOF as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [sendKey]") return [0, "EOF [sendKey]"] - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [sendKey]") return [0, str(msg) + " [sendKey]"] @@ -881,19 +881,19 @@ class backupUtilities: return [0,sendKey[1]] - except pexpect.TIMEOUT, msg: + except pexpect.TIMEOUT as msg: return [0, str(msg) + " [TIMEOUT setupSSHKeys]"] - except BaseException, msg: + except BaseException as msg: return [0, str(msg) + " [setupSSHKeys]"] @staticmethod def checkIfHostIsUp(IPAddress): try: - if subprocess.check_output(['ping', IPAddress, '-c 1']).find("0% packet loss") > -1: + if subprocess.check_output(['ping', IPAddress, '-c 1']).decode("utf-8").find("0% packet loss") > -1: return 1 else: return 0 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[checkIfHostIsUp]") @staticmethod @@ -936,13 +936,13 @@ class backupUtilities: subprocess.call(['kill', str(checkConn.pid)]) return [1, "None"] - except pexpect.TIMEOUT, msg: + except pexpect.TIMEOUT as msg: logging.CyberCPLogFileWriter.writeToFile("Timeout "+IPAddress+ " [checkConnection]") return [0, "371 Timeout while making connection to this server [checkConnection]"] - except pexpect.EOF, msg: + except pexpect.EOF as msg: logging.CyberCPLogFileWriter.writeToFile("EOF "+IPAddress+ "[checkConnection]") return [0, "374 Remote Server is not able to authenticate for transfer to initiate. [checkConnection]"] - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)+" " +IPAddress+ " [checkConnection]") return [0, "377 Remote Server is not able to authenticate for transfer to initiate. [checkConnection]"] @@ -1003,13 +1003,13 @@ class backupUtilities: return [1, "None"] - except pexpect.TIMEOUT, msg: + except pexpect.TIMEOUT as msg: logging.CyberCPLogFileWriter.writeToFile("Timeout [verifyHostKey]") return [0,"Timeout [verifyHostKey]"] - except pexpect.EOF, msg: + except pexpect.EOF as msg: logging.CyberCPLogFileWriter.writeToFile("EOF [verifyHostKey]") return [0,"EOF [verifyHostKey]"] - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [verifyHostKey]") return [0,str(msg)+" [verifyHostKey]"] @@ -1026,7 +1026,7 @@ class backupUtilities: command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel root@" + IPAddress + ' "cat /root/.ssh/authorized_temp > /root/.ssh/authorized_keys"' subprocess.call(shlex.split(command)) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createBackupDir]") return 0 @@ -1036,7 +1036,7 @@ class backupUtilities: command = 'sudo ssh-keygen -R ' + IPAddress subprocess.call(shlex.split(command)) return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [host_key_verification]") return 0 @@ -1052,9 +1052,9 @@ class backupUtilities: return aliases - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [getAliases]") - print 0 + print(0) def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain): @@ -1142,7 +1142,7 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain): command = 'chown %s:%s %s' % (website.externalApp, website.externalApp, status) ProcessUtilities.executioner(command) - execPath = "sudo nice -n 10 /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" + execPath = "sudo nice -n 10 /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" execPath = execPath + " startBackup --tempStoragePath " + tempStoragePath + " --backupName " \ + backupName + " --backupPath " + backupPath + ' --backupDomain ' + backupDomain + ' --metaPath %s' % (result[2]) @@ -1178,7 +1178,7 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain): output = ProcessUtilities.outputExecutioner(execPath, website.externalApp) if output.find('1,None') > -1: - execPath = "sudo nice -n 10 /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" + execPath = "sudo nice -n 10 /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" execPath = execPath + " BackupRoot --tempStoragePath " + tempStoragePath + " --backupName " \ + backupName + " --backupPath " + backupPath + ' --backupDomain ' + backupDomain + ' --metaPath %s' % ( result[2]) @@ -1193,7 +1193,7 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain): command = 'rm -f %s' % (result[2]) ProcessUtilities.executioner(command, 'cyberpanel') - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [submitBackupCreation]") @@ -1206,7 +1206,7 @@ def cancelBackupCreation(backupCancellationDomain,fileName): try: os.kill(int(pid), signal.SIGKILL) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [cancelBackupCreation]") backupPath = "/home/" + backupCancellationDomain + "/backup/" @@ -1215,21 +1215,21 @@ def cancelBackupCreation(backupCancellationDomain,fileName): try: os.remove(tempStoragePath + ".tar.gz") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [cancelBackupCreation]") try: rmtree(tempStoragePath) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [cancelBackupCreation]") status = open(backupPath + 'status', "w") status.write("Aborted manually. [1165][5009]") status.close() - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [cancelBackupCreation]") - print "0,"+str(msg) + print("0,"+str(msg)) def submitRestore(backupFile,dir): try: @@ -1237,21 +1237,21 @@ def submitRestore(backupFile,dir): p = Process(target=backupUtilities.startRestore, args=(backupFile, dir,)) p.start() - print "1,None" + print("1,None") - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [cancelBackupCreation]") - print "0,"+str(msg) + print("0,"+str(msg)) def submitDestinationCreation(ipAddress, password, port): setupKeys = backupUtilities.setupSSHKeys(ipAddress, password, port) if setupKeys[0] == 1: backupUtilities.createBackupDir(ipAddress, port) - print "1,None" + print("1,None") else: - print setupKeys[1] + print(setupKeys[1]) def getConnectionStatus(ipAddress): @@ -1259,12 +1259,12 @@ def getConnectionStatus(ipAddress): checkCon = backupUtilities.checkConnection(ipAddress) if checkCon[0] == 1: - print "1,None" + print("1,None") else: - print checkCon[1] + print(checkCon[1]) - except BaseException, msg: - print str(msg) + except BaseException as msg: + print(str(msg)) def main(): diff --git a/plogical/cPanelImporter.py b/plogical/cPanelImporter.py index 5c75c1493..dfdafd145 100644 --- a/plogical/cPanelImporter.py +++ b/plogical/cPanelImporter.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os.path import sys import django @@ -139,7 +139,7 @@ class cPanelImporter: return 1 - except BaseException, msg: + except BaseException as msg: message = 'Failed to extract backup for file %s, error message: %s. [ExtractBackup]' % ( self.backupFile, str(msg)) logging.statusWriter(self.logFile, message, 1) @@ -219,8 +219,8 @@ class cPanelImporter: tWeb = Websites.objects.get(externalApp=self.externalApp) self.externalApp = '%s%s' % (tWeb.externalApp, str(counter)) counter = counter + 1 - print self.externalApp - except BaseException, msg: + print(self.externalApp) + except BaseException as msg: logging.statusWriter(self.logFile, str(msg), 1) time.sleep(2) @@ -291,7 +291,7 @@ class cPanelImporter: return 1 - except BaseException, msg: + except BaseException as msg: message = 'Failed to create main website from backup file %s, error message: %s.' % ( self.backupFile, str(msg)) logging.statusWriter(self.logFile, message, 1) @@ -354,7 +354,7 @@ class cPanelImporter: logging.statusWriter(self.logFile, message, 1) for items in Domains: - print items.domain + print(items.domain) ## Starting Child-domains creation @@ -469,13 +469,13 @@ class cPanelImporter: message = 'Successfully created child domain.' logging.statusWriter(self.logFile, message, 1) - except BaseException, msg: + except BaseException as msg: message = 'Failed to create child domain from backup file %s, error message: %s. Moving on..' % ( self.backupFile, str(msg)) return 1 - except BaseException, msg: + except BaseException as msg: message = 'Failed to create child domain from backup file %s, error message: %s.' % ( self.backupFile, str(msg)) logging.statusWriter(self.logFile, message, 1) @@ -578,7 +578,7 @@ class cPanelImporter: else: DNS.createDNSRecord(zone, RecordsData[0] + '.' + topLevelDomain , RecordsData[3], RecordsData[4].rstrip('.').rstrip('.\n'), 0, RecordsData[1]) - except BaseException, msg: + except BaseException as msg: message = 'Failed while creating DNS entry for %s, error message: %s.' % (topLevelDomain, str(msg)) logging.statusWriter(self.logFile, message, 1) @@ -587,7 +587,7 @@ class cPanelImporter: return 1 - except BaseException, msg: + except BaseException as msg: message = 'Failed to create DNS records from file %s, error message: %s.' % ( self.backupFile, str(msg)) logging.statusWriter(self.logFile, message, 1) @@ -607,7 +607,7 @@ class cPanelImporter: return conn, cursor - except BaseException, msg: + except BaseException as msg: message = 'Failed to connect to database, error message: %s. [ExtractBackup]' % (str(msg)) logging.statusWriter(self.logFile, message, 1) return 0, 0 @@ -642,7 +642,7 @@ class cPanelImporter: try: cursor.execute("CREATE DATABASE `%s`" % (items.replace('.sql', ''))) - except BaseException, msg: + except BaseException as msg: message = 'Failed while restoring database %s from backup file %s, error message: %s' % (items.replace('.sql', ''), self.backupFile, str(msg)) logging.statusWriter(self.logFile, message, 1) @@ -694,7 +694,7 @@ class cPanelImporter: continue try: cursor.execute(items) - except BaseException, msg: + except BaseException as msg: message = 'Failed while restoring database %s from backup file %s, error message: %s' % ( items.replace('.sql', ''), self.backupFile, str(msg)) logging.statusWriter(self.logFile, message, 1) @@ -706,7 +706,7 @@ class cPanelImporter: return 1 - except BaseException, msg: + except BaseException as msg: message = 'Failed to retore databases from file %s, error message: %s.' % ( self.backupFile, str(msg)) logging.statusWriter(self.logFile, message, 1) @@ -869,7 +869,7 @@ class cPanelImporter: message = 'Restore completed for %s.' % (finalEmailUsername) logging.statusWriter(self.logFile, message, 1) - except BaseException, msg: + except BaseException as msg: message = 'Failed to restore emails from archive file %s, For domain: %s. error message: %s. [ExtractBackup]' % ( self.backupFile, items, str(msg)) logging.statusWriter(self.logFile, message, 1) @@ -883,7 +883,7 @@ class cPanelImporter: return 1 - except BaseException, msg: + except BaseException as msg: message = 'Failed to restore emails from archive file %s, error message: %s. [ExtractBackup]' % ( self.backupFile, str(msg)) logging.statusWriter(self.logFile, message, 1) diff --git a/plogical/childDomain.py b/plogical/childDomain.py index 250fc8044..828bae8ce 100755 --- a/plogical/childDomain.py +++ b/plogical/childDomain.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os import os.path import sys diff --git a/plogical/cronUtil.py b/plogical/cronUtil.py index 48d45d4c0..741823f80 100755 --- a/plogical/cronUtil.py +++ b/plogical/cronUtil.py @@ -1,5 +1,7 @@ +import sys +sys.path.append('/usr/local/CyberCP') import argparse -from processUtilities import ProcessUtilities +from plogical.processUtilities import ProcessUtilities class CronUtil: @@ -14,13 +16,13 @@ class CronUtil: try: f = open(cronPath, 'r').read() - print f - except BaseException, msg: - print "0,CyberPanel," + str(msg) + print(f) + except BaseException as msg: + print("0,CyberPanel," + str(msg)) return 1 - except BaseException, msg: - print "0,CyberPanel," + str(msg) + except BaseException as msg: + print("0,CyberPanel," + str(msg)) @staticmethod def saveCronChanges(externalApp, finalCron, line): @@ -40,9 +42,9 @@ class CronUtil: with open(cronPath, 'w') as file: file.writelines(data) - print "1,None" - except BaseException, msg: - print "0," + str(msg) + print("1,None") + except BaseException as msg: + print("0," + str(msg)) @staticmethod def remCronbyLine(externalApp, line): @@ -68,9 +70,9 @@ class CronUtil: counter = counter + 1 - print "1," + removedLine - except BaseException, msg: - print "0," + str(msg) + print("1," + removedLine) + except BaseException as msg: + print("0," + str(msg)) @staticmethod def addNewCron(externalApp, finalCron): @@ -80,9 +82,9 @@ class CronUtil: with open(CronPath, "a") as file: file.write(finalCron + "\n") - print "1,None" - except BaseException, msg: - print "0," + str(msg) + print("1,None") + except BaseException as msg: + print("0," + str(msg)) @staticmethod def CronPrem(mode): diff --git a/plogical/csf.py b/plogical/csf.py index eaafddd24..8109e4c5e 100755 --- a/plogical/csf.py +++ b/plogical/csf.py @@ -1,13 +1,11 @@ -#!/usr/local/CyberCP/bin/python2 -import CyberCPLogFileWriter as logging +#!/usr/local/CyberCP/bin/python +import sys +sys.path.append('/usr/local/CyberCP') +from plogical import CyberCPLogFileWriter as logging import subprocess import shlex import argparse -from virtualHostUtilities import virtualHostUtilities import os -import tarfile -import shutil -from mailUtilities import mailUtilities import threading as multi from plogical.processUtilities import ProcessUtilities @@ -27,7 +25,7 @@ class CSF(multi.Thread): self.installCSF() elif self.installApp == 'removeCSF': self.removeCSF() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [CSF.run]') @staticmethod @@ -354,7 +352,7 @@ class CSF(multi.Thread): pass return 1 - except BaseException, msg: + except BaseException as msg: try: os.remove('csf.tgz') os.removedirs('csf') @@ -394,7 +392,7 @@ class CSF(multi.Thread): subprocess.call(shlex.split(command)) return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[removeCSF]") @staticmethod @@ -438,7 +436,7 @@ class CSF(multi.Thread): return currentSettings - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [fetchCSFSettings]") @staticmethod @@ -448,11 +446,11 @@ class CSF(multi.Thread): if status == 'enable': command = 'csf -s' subprocess.call(shlex.split(command)) - print '1,None' + print('1,None') else: command = 'csf -f' subprocess.call(shlex.split(command)) - print '1,None' + print('1,None') elif controller == 'testingMode': data = open('/etc/csf/csf.conf', 'r').readlines() @@ -468,11 +466,11 @@ class CSF(multi.Thread): else: writeToFile.writelines(items) writeToFile.close() - print '1,None' + print('1,None') - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[changeStatus]") - print '0', str(msg) + print('0', str(msg)) @staticmethod def modifyPorts(protocol, portsPath): @@ -528,11 +526,11 @@ class CSF(multi.Thread): except: pass - print '1,None' + print('1,None') - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[modifyPorts]") - print '0', str(msg) + print('0', str(msg)) @staticmethod def allowIP(ipAddress): @@ -543,7 +541,7 @@ class CSF(multi.Thread): command = 'sudo csf -a ' + ipAddress ProcessUtilities.executioner(command) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[allowIP]") @staticmethod @@ -556,7 +554,7 @@ class CSF(multi.Thread): command = 'sudo csf -d ' + ipAddress ProcessUtilities.executioner(command) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[blockIP]") @staticmethod @@ -565,7 +563,7 @@ class CSF(multi.Thread): command = 'sudo csf -g ' + ipAddress ProcessUtilities.executioner(command) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[checkIP]") diff --git a/plogical/dnsUtilities.py b/plogical/dnsUtilities.py index cdc910c32..259c3aa05 100755 --- a/plogical/dnsUtilities.py +++ b/plogical/dnsUtilities.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os,sys sys.path.append('/usr/local/CyberCP') import django @@ -7,12 +7,12 @@ try: django.setup() except: pass -import CyberCPLogFileWriter as logging +from plogical import CyberCPLogFileWriter as logging import subprocess import shlex try: from dns.models import Domains,Records - from processUtilities import ProcessUtilities + from plogical.processUtilities import ProcessUtilities from manageServices.models import PDNSStatus, SlaveServers except: pass @@ -369,7 +369,7 @@ class DNS: command = 'sudo systemctl restart pdns' ProcessUtilities.executioner(command) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( "We had errors while creating DNS records for: " + domain + ". Error message: " + str(msg)) @@ -386,7 +386,7 @@ class DNS: path = "/etc/opendkim/keys/" + topLevelDomain + "/default.txt" command = "sudo cat " + path - output = subprocess.check_output(shlex.split(command)) + output = subprocess.check_output(shlex.split(command)).decode("utf-8") leftIndex = output.index('(') + 2 rightIndex = output.rindex(')') - 1 @@ -405,7 +405,7 @@ class DNS: command = 'sudo systemctl restart pdns' ProcessUtilities.executioner(command) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( "We had errors while creating DKIM record for: " + domain + ". Error message: " + str(msg)) @@ -498,7 +498,7 @@ class DNS: if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: command = 'sudo systemctl restart pdns' ProcessUtilities.executioner(command) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createDNSRecord]") @staticmethod diff --git a/plogical/filemanager.py b/plogical/filemanager.py index 69faec37a..93ff1f561 100755 --- a/plogical/filemanager.py +++ b/plogical/filemanager.py @@ -1,4 +1,4 @@ -import CyberCPLogFileWriter as logging +from plogical import CyberCPLogFileWriter as logging import argparse from random import randint @@ -16,12 +16,12 @@ class filemanager: filemanager.write(fileKey) filemanager.close() - print fileKey + print(fileKey) - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [createTemporaryFile]") - print "0," + str(msg) + print("0," + str(msg)) def main(): diff --git a/plogical/findBWUsage.py b/plogical/findBWUsage.py index 1a88816fe..c5f7da546 100755 --- a/plogical/findBWUsage.py +++ b/plogical/findBWUsage.py @@ -1,5 +1,5 @@ import os -import CyberCPLogFileWriter as logging +from plogical import CyberCPLogFileWriter as logging import shlex import subprocess class findBWUsage: @@ -54,10 +54,10 @@ class findBWUsage: writeMeta.writelines(str(newSeekPoint) + "\n") writeMeta.close() - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [calculateBandwidth]") return 0 - except ValueError, msg: + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [calculateBandwidth]") return 0 @@ -70,7 +70,7 @@ class findBWUsage: try: for directories in os.listdir("/home"): findBWUsage.calculateBandwidth(directories) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startCalculations]") return 0 @@ -110,10 +110,10 @@ class findBWUsage: return [0, 0] - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [findDomainBW]") return 0 - except ValueError, msg: + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [findDomainBW]") return 0 @@ -140,10 +140,10 @@ class findBWUsage: print("###############################################") - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [changeSystemLanguage]") return 0 - except ValueError, msg: + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [changeSystemLanguage]") return 0 diff --git a/plogical/firewallUtilities.py b/plogical/firewallUtilities.py index a7db987fe..d3f07fb63 100755 --- a/plogical/firewallUtilities.py +++ b/plogical/firewallUtilities.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os import os.path import sys @@ -29,10 +29,10 @@ class FirewallUtilities: logging.CyberCPLogFileWriter.writeToFile("Failed to apply rule: " + command + " Error #" + str(res)) return 0 - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile("Failed to apply rule: " + command + " Error: " + str(msg)) return 0 - except ValueError, msg: + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile("Failed to apply rule: " + command + " Error: " + str(msg), 1) return 0 return 1 @@ -45,23 +45,20 @@ class FirewallUtilities: ruleProtocol = 'port protocol="' + proto + '"' rulePort = 'port="' + port + '"' - command = "sudo firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'" + command = "firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'" - if not FirewallUtilities.doCommand(command): - return 0 + ProcessUtilities.executioner(command) ruleFamily = 'rule family="ipv6"' sourceAddress = '' - command = "sudo firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'" + command = "firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'" - if not FirewallUtilities.doCommand(command): - return 0 + ProcessUtilities.executioner(command) - command = 'sudo firewall-cmd --reload' + command = 'firewall-cmd --reload' - if not FirewallUtilities.doCommand(command): - return 0 + ProcessUtilities.executioner(command) return 1 @@ -72,23 +69,20 @@ class FirewallUtilities: ruleProtocol = 'port protocol="' + proto + '"' rulePort = 'port="' + port + '"' - command = "sudo firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'" + command = "firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'" - if ProcessUtilities.executioner(command) == 0: - return 0 + ProcessUtilities.executioner(command) ruleFamily = 'rule family="ipv6"' sourceAddress = '' - command = "sudo firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'" + command = "firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'" - if ProcessUtilities.executioner(command) == 0: - return 0 + ProcessUtilities.executioner(command) - command = 'sudo firewall-cmd --reload' + command = 'firewall-cmd --reload' - if ProcessUtilities.executioner(command) == 0: - return 0 + ProcessUtilities.executioner(command) return 1 @@ -97,7 +91,7 @@ class FirewallUtilities: try: if type == "1": - command = 'sudo semanage port -a -t ssh_port_t -p tcp ' + sshPort + command = 'semanage port -a -t ssh_port_t -p tcp ' + sshPort ProcessUtilities.normalExecutioner(command) FirewallUtilities.addRule('tcp', sshPort, "0.0.0.0/0") @@ -127,13 +121,13 @@ class FirewallUtilities: writeToFile.writelines(items) writeToFile.close() - command = 'sudo systemctl restart sshd' + command = 'systemctl restart sshd' ProcessUtilities.normalExecutioner(command) - print "1,None" + print("1,None") - except BaseException, msg: - print "0," + str(msg) + except BaseException as msg: + print("0," + str(msg)) @staticmethod def addSSHKey(tempPath): @@ -176,10 +170,10 @@ class FirewallUtilities: if os.path.split(tempPath): os.remove(tempPath) - print "1,None" + print("1,None") - except BaseException, msg: - print "0," + str(msg) + except BaseException as msg: + print("0," + str(msg)) @staticmethod def deleteSSHKey(key): @@ -199,10 +193,10 @@ class FirewallUtilities: writeToFile.close() - print "1,None" + print("1,None") - except BaseException, msg: - print "0," + str(msg) + except BaseException as msg: + print("0," + str(msg)) def main(): diff --git a/plogical/ftpUtilities.py b/plogical/ftpUtilities.py index 31dab10a3..7c72131ca 100755 --- a/plogical/ftpUtilities.py +++ b/plogical/ftpUtilities.py @@ -1,12 +1,12 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os,sys sys.path.append('/usr/local/CyberCP') import django os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") django.setup() -import mysqlUtilities as sql +from plogical import mysqlUtilities as sql import subprocess -import CyberCPLogFileWriter as logging +from plogical import CyberCPLogFileWriter as logging import os import shlex import argparse @@ -34,15 +34,15 @@ class FTPUtilities: res = subprocess.call(cmd) if res == 1: - print "Permissions not changed." + print("Permissions not changed.") else: - print "User permissions setted." + print("User permissions setted.") query = "INSERT INTO ftp_ftpuser (userid,passwd,homedir) VALUES ('" + username + "'" +","+"'"+password+"'"+","+"'"+path+"'"+");" - print query + print(query) sql.mysqlUtilities.SendQuery(udb,upass, "ftp", query) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [createNewFTPAccount]") return 0 @@ -61,10 +61,10 @@ class FTPUtilities: res = subprocess.call(cmd) if res == 1: - print "Permissions not changed." + print("Permissions not changed.") return 0 else: - print "User permissions setted." + print("User permissions setted.") @@ -79,7 +79,7 @@ class FTPUtilities: else: return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [createNewFTPAccount]") return 0 @@ -95,7 +95,7 @@ class FTPUtilities: return 1,'None' - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [ftpFunctions]") return 0, str(msg) @@ -140,11 +140,11 @@ class FTPUtilities: path = "/home/" + domainName if os.path.islink(path): - print "0, %s file is symlinked." % (path) + print("0, %s file is symlinked." % (path)) return 0 hash = hashlib.md5() - hash.update(password) + hash.update(password.encode('utf-8')) admin = Administrator.objects.get(userName=owner) @@ -175,12 +175,12 @@ class FTPUtilities: else: raise BaseException("Exceeded maximum amount of FTP accounts allowed for the package.") - print "1,None" + print("1,None") return 1,'None' - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [submitFTPCreation]") - print "0,"+str(msg) + print("0,"+str(msg)) return 0, str(msg) @staticmethod @@ -189,21 +189,21 @@ class FTPUtilities: ftp = Users.objects.get(user=ftpUsername) ftp.delete() return 1,'None' - except BaseException, msg: + except BaseException as msg: return 0, str(msg) @staticmethod def changeFTPPassword(userName, password): try: hash = hashlib.md5() - hash.update(password) + hash.update(password.encode('utf-8')) ftp = Users.objects.get(user=userName) ftp.password = hash.hexdigest() ftp.save() return 1, None - except BaseException, msg: + except BaseException as msg: return 0,str(msg) @staticmethod diff --git a/plogical/httpProc.py b/plogical/httpProc.py index 2a338664f..61518e85c 100755 --- a/plogical/httpProc.py +++ b/plogical/httpProc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render, HttpResponse import json @@ -30,7 +30,7 @@ class httpProc: finalDic['status'] = status finalDic['error_message'] = errorMessage - for key, value in data.iteritems(): + for key, value in data.items(): finalDic[key] = value finalJson = json.dumps(finalDic) diff --git a/plogical/installUtilities.py b/plogical/installUtilities.py index cedfbf654..d7f54e4eb 100755 --- a/plogical/installUtilities.py +++ b/plogical/installUtilities.py @@ -1,11 +1,11 @@ import subprocess import sys -import CyberCPLogFileWriter as logging +from plogical import CyberCPLogFileWriter as logging import shutil import pexpect import os import shlex -from processUtilities import ProcessUtilities +from plogical.processUtilities import ProcessUtilities class installUtilities: @@ -29,10 +29,10 @@ class installUtilities: print("###############################################") print(" EPEL Repo Added ") print("###############################################") - except OSError,msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [enableEPELRepo]") return 0 - except ValueError,msg: + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [enableEPELRepo]") return 0 @@ -57,10 +57,10 @@ class installUtilities: print(" Litespeed Repo Added ") print("###############################################") - except OSError,msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [addLiteSpeedRepo]") return 0 - except ValueError,msg: + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [addLiteSpeedRepo]") return 0 @@ -91,10 +91,10 @@ class installUtilities: print(" Litespeed Installed ") print("###############################################") - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installLiteSpeed]") return 0 - except ValueError, msg: + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installLiteSpeed]") return 0 @@ -123,10 +123,10 @@ class installUtilities: print(" Litespeed Started ") print("###############################################") - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startLiteSpeed]") return 0 - except ValueError, msg: + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startLiteSpeed]") return 0 @@ -144,10 +144,10 @@ class installUtilities: ProcessUtilities.normalExecutioner(command) - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]") return 0 - except ValueError, msg: + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]") return 0 return 1 @@ -163,10 +163,10 @@ class installUtilities: return ProcessUtilities.executioner(command) - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]") return 0 - except ValueError, msg: + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]") return 0 @@ -181,10 +181,10 @@ class installUtilities: return ProcessUtilities.executioner(command) - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]") return 0 - except ValueError, msg: + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]") return 0 @@ -211,10 +211,10 @@ class installUtilities: print(" Litespeed Re-Started ") print("###############################################") - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartOpenLiteSpeed]") return 0 - except ValueError, msg: + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartOpenLiteSpeed]") return 0 return 1 @@ -233,7 +233,7 @@ class installUtilities: writeDataToFile.close() - except IOError, msg: + except IOError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [changePortTo80]") return 0 @@ -267,13 +267,13 @@ class installUtilities: - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installAllPHPVersion]") return 0 - except ValueError, msg: + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installAllPHPVersion]") @@ -306,7 +306,7 @@ class installUtilities: writeDataToFile.close() - except IOError, msg: + except IOError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installAllPHPToLitespeed]") return 0 @@ -357,10 +357,10 @@ class installUtilities: print("###############################################") - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [removeWebServer]") return 0 - except ValueError, msg: + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [removeWebServer]") return 0 @@ -385,17 +385,17 @@ class installUtilities: print("###############################################") sys.exit() - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [removeWebServer]") return 0 - except ValueError, msg: + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [removeWebServer]") return 0 try: shutil.rmtree(installUtilities.Server_root_path) - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [removeWebServer]") return 0 @@ -427,10 +427,10 @@ class installUtilities: print("###############################################") - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startMariaDB]") return 0 - except ValueError, msg: + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startMariaDB]") return 0 @@ -463,13 +463,13 @@ class installUtilities: print("###############################################") - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installMySQL]") return 0 - except ValueError, msg: + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installMySQL]") @@ -502,10 +502,10 @@ class installUtilities: print(" MariaDB Addded to startup ") print("###############################################") - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " Could not add mariadb to startup [installMySQL]") return 0 - except ValueError, msg: + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " Could not add mariadb to startup [installMySQL]") return 0 @@ -562,18 +562,18 @@ class installUtilities: if (securemysql.before.find("Thanks for using MariaDB!") > -1 or securemysql.after.find("Thanks for using MariaDB!")>-1): return 1 - except pexpect.EOF,msg: + except pexpect.EOF as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " Exception EOF [installMySQL]") print("###########################Before########################################") - print securemysql.before + print(securemysql.before) print("###########################After########################################") - print securemysql.after + print(securemysql.after) print("########################################################################") - except BaseException,msg: + except BaseException as msg: print("#############################Before#####################################") - print securemysql.before + print(securemysql.before) print("############################After######################################") - print securemysql.after + print(securemysql.after) print("########################################################################") logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installMySQL]") diff --git a/plogical/mailUtilities.py b/plogical/mailUtilities.py index 414b97377..9034ef71b 100755 --- a/plogical/mailUtilities.py +++ b/plogical/mailUtilities.py @@ -8,11 +8,11 @@ except: pass import os.path import shutil -import CyberCPLogFileWriter as logging +from plogical import CyberCPLogFileWriter as logging import subprocess import argparse import shlex -from processUtilities import ProcessUtilities +from plogical.processUtilities import ProcessUtilities import os, getpass import hashlib import bcrypt @@ -37,8 +37,8 @@ class mailUtilities: try: smtpObj = smtplib.SMTP('localhost') smtpObj.sendmail(sender, receivers, message) - print "Successfully sent email" - except BaseException, msg: + print("Successfully sent email") + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) @staticmethod def AfterEffects(domain): @@ -121,7 +121,7 @@ class mailUtilities: ## After effects - execPath = "/usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/mailUtilities.py" + execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/mailUtilities.py" execPath = execPath + " AfterEffects --domain " + domain if getpass.getuser() == 'root': @@ -134,24 +134,21 @@ class mailUtilities: emailDomain = Domains.objects.get(domain=domain) - hash = hashlib.md5() - hash.update(password) - #emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=hash.hexdigest()) CentOSPath = '/etc/redhat-release' if os.path.exists(CentOSPath): if restore == None: - password = bcrypt.hashpw(str(password), bcrypt.gensalt()) - password = '{CRYPT}%s' % (password) + password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()) + password = '{CRYPT}%s' % (password.decode()) emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=password) emailAcct.mail = 'maildir:/home/vmail/%s/%s/Maildir' % (domain, userName) emailAcct.save() else: if restore == None: - password = bcrypt.hashpw(str(password), bcrypt.gensalt()) - password = '{CRYPT}%s' % (password) + password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()) + password = '{CRYPT}%s' % (password.decode()) emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=password) emailAcct.mail = 'maildir:/home/vmail/%s/%s/Maildir' % (domain, userName) emailAcct.save() @@ -159,13 +156,13 @@ class mailUtilities: emailLimits = EmailLimits(email=emailAcct) emailLimits.save() - print "1,None" + print("1,None") return 1,"None" - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [createEmailAccount]") - print "0," + str(msg) + print("0," + str(msg)) return 0, str(msg) @staticmethod @@ -177,7 +174,7 @@ class mailUtilities: return 1, 'None' - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [deleteEmailAccount]") return 0, str(msg) @@ -197,8 +194,8 @@ class mailUtilities: CentOSPath = '/etc/redhat-release' changePass = EUsers.objects.get(email=email) if os.path.exists(CentOSPath): - password = bcrypt.hashpw(str(newPassword), bcrypt.gensalt()) - password = '{CRYPT}%s' % (password) + password = bcrypt.hashpw(newPassword.encode('utf-8'), bcrypt.gensalt()) + password = '{CRYPT}%s' % (password.decode()) changePass.password = password else: changePass.password = newPassword @@ -208,7 +205,7 @@ class mailUtilities: changePass.password = newPassword changePass.save() return 0,'None' - except BaseException, msg: + except BaseException as msg: return 0, str(msg) @staticmethod @@ -282,7 +279,7 @@ class mailUtilities: return 1, "None" - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [setupDKIM:275]") return 0, str(msg) @@ -296,7 +293,7 @@ class mailUtilities: command = "sudo cat " + path return ProcessUtilities.executioner(command) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [checkIfDKIMInstalled]") return 0 @@ -308,12 +305,12 @@ class mailUtilities: if result[0] == 0: raise BaseException(result[1]) else: - print "1,None" + print("1,None") - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [generateKeys]") - print "0," + str(msg) + print("0," + str(msg)) @staticmethod def configureOpenDKIM(): @@ -363,18 +360,18 @@ milter_default_action = accept command = "systemctl start postfix" subprocess.call(shlex.split(command)) - print "1,None" + print("1,None") return - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [configureOpenDKIM]") - print "0," + str(msg) + print("0," + str(msg)) return - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [configureOpenDKIM]") - print "0," + str(msg) + print("0," + str(msg)) return @staticmethod @@ -400,7 +397,7 @@ milter_default_action = accept command = "sudo chown -R cyberpanel:cyberpanel " + mailUtilities.cyberPanelHome subprocess.call(shlex.split(command), stdout=FNULL) - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [checkHome]") @staticmethod @@ -428,7 +425,7 @@ milter_default_action = accept writeToFile.close() return 1 - except BaseException, msg: + except BaseException as msg: writeToFile = open(mailUtilities.installLogPath, 'a') writeToFile.writelines("Can not be installed.[404]\n") writeToFile.close() @@ -442,7 +439,7 @@ milter_default_action = accept command = 'systemctl restart dovecot' subprocess.call(shlex.split(command)) - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [restartServices]") @staticmethod @@ -471,7 +468,7 @@ milter_default_action = accept writeToFile.close() return 1 - except BaseException, msg: + except BaseException as msg: writeToFile = open(mailUtilities.spamassassinInstallLogPath, 'a') writeToFile.writelines("Can not be installed.[404]\n") writeToFile.close() @@ -491,7 +488,7 @@ milter_default_action = accept else: return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [checkIfSpamAssassinInstalled]") return 0 @@ -554,17 +551,17 @@ milter_default_action = accept ProcessUtilities.normalExecutioner(command) - print "1,None" + print("1,None") return - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [configureSpamAssassin]") - print "0," + str(msg) + print("0," + str(msg)) return - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [configureSpamAssassin]") - print "0," + str(msg) + print("0," + str(msg)) return @staticmethod @@ -606,13 +603,13 @@ milter_default_action = accept command = 'systemctl restart spamassassin' subprocess.call(shlex.split(command)) - print "1,None" + print("1,None") return - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [saveSpamAssassinConfigs]") - print "0," + str(msg) + print("0," + str(msg)) @staticmethod def savePolicyServerStatus(install): @@ -658,13 +655,13 @@ milter_default_action = accept command = 'systemctl restart postfix' subprocess.call(shlex.split(command)) - print "1,None" + print("1,None") return - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [savePolicyServerStatus]") - print "0," + str(msg) + print("0," + str(msg)) def main(): diff --git a/plogical/modSec.py b/plogical/modSec.py index 971fb6a6e..6c4e86c6f 100755 --- a/plogical/modSec.py +++ b/plogical/modSec.py @@ -1,13 +1,15 @@ -import CyberCPLogFileWriter as logging +import sys +sys.path.append('/usr/local/CyberCP') +from plogical import CyberCPLogFileWriter as logging import subprocess import shlex import argparse -from virtualHostUtilities import virtualHostUtilities +from plogical.virtualHostUtilities import virtualHostUtilities import os import tarfile import shutil -from mailUtilities import mailUtilities -from processUtilities import ProcessUtilities +from plogical.mailUtilities import mailUtilities +from plogical.processUtilities import ProcessUtilities from plogical.installUtilities import installUtilities class modSec: @@ -44,7 +46,7 @@ class modSec: writeToFile.close() return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installModSec]") @staticmethod @@ -101,13 +103,13 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf rule.write(initialRules) rule.close() - print "1,None" + print("1,None") return - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [installModSecConfigs]") - print "0," + str(msg) + print("0," + str(msg)) @staticmethod def saveModSecConfigs(tempConfigPath): @@ -152,7 +154,7 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf installUtilities.reStartLiteSpeed() - print "1,None" + print("1,None") return else: confFile = os.path.join(virtualHostUtilities.Server_root, "conf/modsec.conf") @@ -186,13 +188,13 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf installUtilities.reStartLiteSpeed() - print "1,None" + print("1,None") return - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [saveModSecConfigs]") - print "0," + str(msg) + print("0," + str(msg)) @staticmethod def saveModSecRules(): @@ -212,13 +214,13 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf installUtilities.reStartLiteSpeed() - print "1,None" + print("1,None") return - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [saveModSecRules]") - print "0," + str(msg) + print("0," + str(msg)) @staticmethod def setupComodoRules(): @@ -264,7 +266,7 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [setupComodoRules]") return 0 @@ -275,7 +277,7 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf if ProcessUtilities.decideServer() == ProcessUtilities.OLS: if modSec.setupComodoRules() == 0: - print '0, Unable to download Comodo Rules.' + print('0, Unable to download Comodo Rules.') return owaspRulesConf = """modsecurity_rules_file /usr/local/lsws/conf/modsec/comodo/modsecurity.conf @@ -327,7 +329,7 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf conf.close() installUtilities.reStartLiteSpeed() - print "1,None" + print("1,None") return else: if os.path.exists('/usr/local/lsws/conf/comodo_litespeed'): @@ -351,13 +353,13 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf subprocess.call(shlex.split(command)) installUtilities.reStartLiteSpeed() - print "1,None" + print("1,None") return - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [installComodo]") - print "0," + str(msg) + print("0," + str(msg)) @staticmethod def disableComodo(): @@ -377,22 +379,22 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf conf.close() installUtilities.reStartLiteSpeed() - print "1,None" + print("1,None") else: try: shutil.rmtree('/usr/local/lsws/conf/comodo_litespeed') - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [disableComodo]') installUtilities.reStartLiteSpeed() - print "1,None" + print("1,None") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [disableComodo]") - print "0," + str(msg) + print("0," + str(msg)) @staticmethod def setupOWASPRules(): @@ -418,7 +420,7 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [setupOWASPRules]") return 0 @@ -427,7 +429,7 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf def installOWASP(): try: if modSec.setupOWASPRules() == 0: - print '0, Unable to download OWASP Rules.' + print('0, Unable to download OWASP Rules.') return owaspRulesConf = """modsecurity_rules_file /usr/local/lsws/conf/modsec/owasp/modsecurity.conf @@ -476,12 +478,12 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/owasp/rules/RESPONSE-999-EXCL conf.close() installUtilities.reStartLiteSpeed() - print "1,None" + print("1,None") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [installOWASP]") - print "0," + str(msg) + print("0," + str(msg)) @staticmethod def disableOWASP(): @@ -500,12 +502,12 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/owasp/rules/RESPONSE-999-EXCL conf.close() installUtilities.reStartLiteSpeed() - print "1,None" + print("1,None") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [disableOWASP]") - print "0," + str(msg) + print("0," + str(msg)) @staticmethod def disableRuleFile(fileName, packName): @@ -534,12 +536,12 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/owasp/rules/RESPONSE-999-EXCL installUtilities.reStartLiteSpeed() - print "1,None" + print("1,None") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [disableRuleFile]") - print "0," + str(msg) + print("0," + str(msg)) @staticmethod def enableRuleFile(fileName, packName): @@ -567,12 +569,12 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/owasp/rules/RESPONSE-999-EXCL installUtilities.reStartLiteSpeed() - print "1,None" + print("1,None") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [enableRuleFile]") - print "0," + str(msg) + print("0," + str(msg)) def main(): diff --git a/plogical/mysqlUtilities.py b/plogical/mysqlUtilities.py index 108804a73..b3aeab14d 100755 --- a/plogical/mysqlUtilities.py +++ b/plogical/mysqlUtilities.py @@ -6,7 +6,7 @@ try: django.setup() except: pass -import CyberCPLogFileWriter as logging +from plogical import CyberCPLogFileWriter as logging import subprocess import shlex try: @@ -65,7 +65,7 @@ class mysqlUtilities: return conn, cursor - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0, 0 @@ -85,7 +85,7 @@ class mysqlUtilities: return 1 - except BaseException, msg: + except BaseException as msg: mysqlUtilities.deleteDatabase(dbname, dbuser) logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[createDatabase]") return 0 @@ -104,7 +104,7 @@ class mysqlUtilities: return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[createDBUser]") return 0 @@ -122,7 +122,7 @@ class mysqlUtilities: return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[createDatabase]") return 0 @@ -141,7 +141,7 @@ class mysqlUtilities: return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[deleteDatabase]") return str(msg) @@ -167,7 +167,7 @@ password=%s writeToFile.write(cnfContent) writeToFile.close() - os.chmod(cnfPath, 0600) + os.chmod(cnfPath, 0o600) command = 'mysqldump --defaults-extra-file=/home/cyberpanel/.my.cnf --host=localhost ' + databaseName cmd = shlex.split(command) @@ -182,12 +182,12 @@ password=%s "Database: " + databaseName + "could not be backed! [createDatabaseBackup]") return 0 - except subprocess.CalledProcessError, msg: + except subprocess.CalledProcessError as msg: logging.CyberCPLogFileWriter.writeToFile( "Database: " + databaseName + "could not be backed! Error: %s. [createDatabaseBackup]" % (str(msg))) return 0 return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[createDatabaseBackup]") return 0 @@ -214,7 +214,7 @@ password=%s writeToFile.write(cnfContent) writeToFile.close() - os.chmod(cnfPath, 0600) + os.chmod(cnfPath, 0o600) command = 'chown cyberpanel:cyberpanel %s' % (cnfPath) subprocess.call(shlex.split(command)) @@ -247,7 +247,7 @@ password=%s connection.close() return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[restoreDatabaseBackup]") return 0 @@ -282,7 +282,7 @@ password=%s return 1,'None' - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0,str(msg) @@ -299,7 +299,7 @@ password=%s else: return 0,result - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0, str(msg) @@ -383,7 +383,7 @@ password=%s return data - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[showStatus]") return 0 @@ -430,7 +430,7 @@ password=%s return 1, None - except BaseException, msg: + except BaseException as msg: if ProcessUtilities.decideDistro() == ProcessUtilities.centos: command = 'sudo mv /etc/my.cnf.bak /etc/my.cnf' else: @@ -457,7 +457,7 @@ password=%s ## - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[showStatus]") return 0 @@ -469,7 +469,7 @@ password=%s return 1, None - except BaseException, msg: + except BaseException as msg: command = 'sudo mv /etc/my.cnf.bak /etc/my.cnf' subprocess.call(shlex.split(command)) logging.CyberCPLogFileWriter.writeToFile(str(msg)) @@ -517,7 +517,7 @@ password=%s data['databases'] = json_data return data - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[fetchDatabases]") return 0 @@ -563,7 +563,7 @@ password=%s data['tables'] = json_data return data - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[fetchDatabases]") return 0 @@ -584,7 +584,7 @@ password=%s return data - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[fetchDatabases]") return 0 @@ -644,7 +644,7 @@ password=%s return data - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[fetchTableData]") return 0 @@ -694,7 +694,7 @@ password=%s return data - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[showStatus]") return 0 @@ -722,7 +722,7 @@ password=%s return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[mysqlUtilities.changePassword]") return 0 @@ -762,6 +762,6 @@ password=%s return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[mysqlUtilities.fetchuser]") return 0 \ No newline at end of file diff --git a/plogical/phpUtilities.py b/plogical/phpUtilities.py index 7a3209bbf..45baa7bd7 100755 --- a/plogical/phpUtilities.py +++ b/plogical/phpUtilities.py @@ -1,12 +1,14 @@ -import CyberCPLogFileWriter as logging +import sys +sys.path.append('/usr/local/CyberCP') +from plogical import CyberCPLogFileWriter as logging import subprocess import shlex -import thread -import installUtilities +import _thread +from plogical import installUtilities import argparse import os -from mailUtilities import mailUtilities -from processUtilities import ProcessUtilities +from plogical.mailUtilities import mailUtilities +from plogical.processUtilities import ProcessUtilities class phpUtilities: @@ -43,7 +45,7 @@ class phpUtilities: logging.CyberCPLogFileWriter.writeToFile("[Could not Install]") installUtilities.installUtilities.reStartLiteSpeed() return 0 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installPHPExtension]") @staticmethod @@ -77,21 +79,21 @@ class phpUtilities: installUtilities.installUtilities.reStartLiteSpeed() return 0 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[unInstallPHPExtension]") @staticmethod def initiateInstall(extension): try: - thread.start_new_thread(phpUtilities.installPHPExtension, (extension, extension)) - except BaseException, msg: + _thread.start_new_thread(phpUtilities.installPHPExtension, (extension, extension)) + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [initiateInstall]") @staticmethod def initiateRemoval(extension): try: - thread.start_new_thread(phpUtilities.unInstallPHPExtension, (extension, extension)) - except BaseException, msg: + _thread.start_new_thread(phpUtilities.unInstallPHPExtension, (extension, extension)) + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [initiateRestore]") @staticmethod @@ -144,12 +146,12 @@ class phpUtilities: installUtilities.installUtilities.reStartLiteSpeed() - print "1,None" + print("1,None") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [savePHPConfigBasic]") - print "0,"+str(msg) + print("0,"+str(msg)) @staticmethod def savePHPConfigAdvance(phpVers,tempPath): @@ -162,11 +164,11 @@ class phpUtilities: if os.path.exists(tempPath): os.remove(tempPath) - print "1,None" - except BaseException, msg: + print("1,None") + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [savePHPConfigAdvance]") - print "0,"+str(msg) + print("0,"+str(msg)) diff --git a/plogical/pluginManagerGlobal.py b/plogical/pluginManagerGlobal.py index aad75f0e1..e9e32f75d 100755 --- a/plogical/pluginManagerGlobal.py +++ b/plogical/pluginManagerGlobal.py @@ -1,5 +1,5 @@ from django.http import HttpResponse -from CyberCPLogFileWriter import CyberCPLogFileWriter as logging +from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging class pluginManagerGlobal: diff --git a/plogical/processUtilities.py b/plogical/processUtilities.py index 568a84c49..e0517ce96 100755 --- a/plogical/processUtilities.py +++ b/plogical/processUtilities.py @@ -1,4 +1,4 @@ -from CyberCPLogFileWriter import CyberCPLogFileWriter as logging +from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging import subprocess import shlex import os @@ -6,12 +6,14 @@ import socket import threading as multi import time import getpass +import codecs class ProcessUtilities(multi.Thread): litespeedProcess = "litespeed" ent = 1 OLS = 0 centos = 1 + cent8 = 2 ubuntu = 0 server_address = '/usr/local/lscpd/admin/comm.sock' token = "unset" @@ -25,7 +27,7 @@ class ProcessUtilities(multi.Thread): try: if self.function == 'popen': self.customPoen() - except BaseException, msg: + except BaseException as msg: logging.writeToFile( str(msg) + ' [ApplicationInstaller.run]') @staticmethod @@ -38,7 +40,7 @@ class ProcessUtilities(multi.Thread): if proc.name().find(ProcessUtilities.litespeedProcess) > -1: finalListOfProcesses.append(proc.pid) - except BaseException,msg: + except BaseException as msg: logging.writeToFile( str(msg) + " [getLitespeedProcessNumber]") return 0 @@ -52,9 +54,9 @@ class ProcessUtilities(multi.Thread): def restartLitespeed(): try: if ProcessUtilities.decideServer() == ProcessUtilities.OLS: - command = "sudo systemctl restart lsws" + command = "systemctl restart lsws" else: - command = "sudo /usr/local/lsws/bin/lswsctrl restart" + command = "/usr/local/lsws/bin/lswsctrl restart" cmd = shlex.split(command) res = subprocess.call(cmd) @@ -64,16 +66,16 @@ class ProcessUtilities(multi.Thread): else: return 0 - except subprocess.CalledProcessError,msg: + except subprocess.CalledProcessError as msg: logging.writeToFile(str(msg) + "[restartLitespeed]") @staticmethod def stopLitespeed(): try: if ProcessUtilities.decideServer() == ProcessUtilities.OLS: - command = "sudo systemctl stop lsws" + command = "systemctl stop lsws" else: - command = "sudo /usr/local/lsws/bin/lswsctrl stop" + command = "/usr/local/lsws/bin/lswsctrl stop" cmd = shlex.split(command) res = subprocess.call(cmd) @@ -83,7 +85,7 @@ class ProcessUtilities(multi.Thread): else: return 0 - except subprocess.CalledProcessError, msg: + except subprocess.CalledProcessError as msg: logging.writeToFile(str(msg) + "[stopLitespeed]") @staticmethod @@ -98,17 +100,17 @@ class ProcessUtilities(multi.Thread): return 1 else: return 0 - except subprocess.CalledProcessError, msg: + except subprocess.CalledProcessError as msg: logging.writeToFile('%s. [ProcessUtilities.normalExecutioner]' % (str(msg))) return 0 - except BaseException, msg: + except BaseException as msg: logging.writeToFile('%s. [ProcessUtilities.normalExecutioner.Base]' % (str(msg))) return 0 @staticmethod def killLiteSpeed(): try: - command = 'sudo systemctl stop lsws' + command = 'systemctl stop lsws' ProcessUtilities.normalExecutioner(command) except: pass @@ -124,8 +126,6 @@ class ProcessUtilities(multi.Thread): @staticmethod def decideServer(): - entPath = '/usr/local/lsws/bin/lshttpd' - if os.path.exists('/usr/local/lsws/bin/openlitespeed'): return ProcessUtilities.OLS else: @@ -138,12 +138,14 @@ class ProcessUtilities(multi.Thread): if os.path.exists(distroPath): return ProcessUtilities.ubuntu else: + if open('/etc/redhat-release', 'r').read().find('CentOS Linux release 8') > -1: + return ProcessUtilities.cent8 return ProcessUtilities.centos @staticmethod def containerCheck(): try: - command = 'sudo cat /etc/cgrules.conf' + command = 'cat /etc/cgrules.conf' output = ProcessUtilities.outputExecutioner(command) if output.find('No such') > -1: return 0 @@ -160,7 +162,7 @@ class ProcessUtilities(multi.Thread): sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock.connect(ProcessUtilities.server_address) return [sock, "None"] - except BaseException, msg: + except BaseException as msg: if count == 3: logging.writeToFile("Failed to connect to LSCPD socket, run 'systemctl restart lscpd' on command line to fix this issue.") return [-1, str(msg)] @@ -173,12 +175,6 @@ class ProcessUtilities(multi.Thread): @staticmethod def sendCommand(command, user=None): try: - # if user == None: - # pass - # else: - # cmd = 'usermod -a -G %s %s' % ('cyberpanel', user) - # ProcessUtilities.executioner(cmd) - ret = ProcessUtilities.setupUDSConnection() if ret[0] == -1: @@ -191,13 +187,13 @@ class ProcessUtilities(multi.Thread): sock = ret[0] if user == None: - #logging.writeToFile(ProcessUtilities.token + command) - sock.sendall(ProcessUtilities.token + command) + logging.writeToFile(ProcessUtilities.token + command) + sock.sendall((ProcessUtilities.token + command).encode('utf-8')) else: command = '%s-u %s %s' % (ProcessUtilities.token, user, command) - #logging.writeToFile(ProcessUtilities.token + command) command = command.replace('sudo', '') - sock.sendall(command) + logging.writeToFile(ProcessUtilities.token + command) + sock.sendall(command.encode('utf-8')) data = "" @@ -205,19 +201,17 @@ class ProcessUtilities(multi.Thread): currentData = sock.recv(32) if len(currentData) == 0 or currentData == None: break - data = data + currentData + try: + data = data + currentData.decode(errors = 'ignore') + except BaseException as msg: + logging.writeToFile('Some data could not be decoded to str, error message: %s' % str(msg)) sock.close() - - # if user == None: - # pass - # else: - # cmd = 'deluser %s cyberpanel' % (user) - # ProcessUtilities.executioner(cmd) + logging.writeToFile('Final data: %s.' % (str(data))) return data - except BaseException, msg: - logging.writeToFile(str(msg) + " [sendCommand]") + except BaseException as msg: + logging.writeToFile(str(msg) + " [hey:sendCommand]") return "0" + str(msg) @staticmethod @@ -230,14 +224,14 @@ class ProcessUtilities(multi.Thread): ret = ProcessUtilities.sendCommand(command, user) exitCode = ret[len(ret) -1] - exitCode = int(exitCode.encode('hex'), 16) + exitCode = int(codecs.encode(exitCode.encode(), 'hex')) if exitCode == 0: return 1 else: return 0 - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + " [executioner]") return 0 @@ -245,20 +239,18 @@ class ProcessUtilities(multi.Thread): def outputExecutioner(command, user=None): try: if getpass.getuser() == 'root': - return subprocess.check_output(command, shell=True) + return subprocess.check_output(command, shell=True).decode("utf-8") - if type(command) == str or type(command) == unicode: - pass - else: + if type(command) == list: command = " ".join(command) return ProcessUtilities.sendCommand(command, user)[:-1] - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + "[outputExecutioner:188]") def customPoen(self): try: - if type(self.extraArgs['command']) == str or type(self.extraArgs['command']) == unicode: + if type(self.extraArgs['command']) == str or type(self.extraArgs['command']) == bytes: command = self.extraArgs['command'] else: command = " ".join(self.extraArgs['command']) @@ -266,7 +258,7 @@ class ProcessUtilities(multi.Thread): ProcessUtilities.sendCommand(command, self.extraArgs['user']) return 1 - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + " [customPoen]") @staticmethod @@ -277,13 +269,13 @@ class ProcessUtilities(multi.Thread): extraArgs['user'] = user pu = ProcessUtilities("popen", extraArgs) pu.start() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + " [popenExecutioner]") @staticmethod def BuildCommand(path, functionName, parameters): - execPath = "/usr/local/CyberCP/bin/python2 %s %s " % (path, functionName) - for key, value in parameters.iteritems(): + execPath = "/usr/local/CyberCP/bin/python %s %s " % (path, functionName) + for key, value in parameters.items(): execPath = execPath + ' --%s %s' % (key, value) return execPath diff --git a/plogical/randomPassword.py b/plogical/randomPassword.py index 2eb292e45..9cfe205f5 100755 --- a/plogical/randomPassword.py +++ b/plogical/randomPassword.py @@ -1,38 +1,7 @@ -from os import urandom -from random import choice - -char_set = {'small': 'abcdefghijklmnopqrstuvwxyz', - 'nums': '0123456789', - 'big': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', - } - +import string +import random def generate_pass(length=14): - """Function to generate a password""" - - password = [] - - while len(password) < length: - key = choice(char_set.keys()) - a_char = urandom(1) - if a_char in char_set[key]: - if check_prev_char(password, char_set[key]): - continue - else: - password.append(a_char) - return ''.join(password) - - -def check_prev_char(password, current_char_set): - """Function to ensure that there are no consecutive - UPPERCASE/lowercase/numbers/special-characters.""" - - index = len(password) - if index == 0: - return False - else: - prev_char = password[index - 1] - if prev_char in current_char_set: - return True - else: - return False \ No newline at end of file + chars = string.ascii_uppercase + string.ascii_lowercase + string.digits + size = length + return ''.join(random.choice(chars) for x in range(size)) \ No newline at end of file diff --git a/plogical/remoteBackup.py b/plogical/remoteBackup.py index 0713f5e8c..e7346cc4a 100755 --- a/plogical/remoteBackup.py +++ b/plogical/remoteBackup.py @@ -1,9 +1,9 @@ -import CyberCPLogFileWriter as logging +from plogical import CyberCPLogFileWriter as logging import os import requests import json import time -import backupUtilities as backupUtil +from plogical import backupUtilities as backupUtil import subprocess import shlex from multiprocessing import Process @@ -25,7 +25,7 @@ class remoteBackup: else: return [0, data['error_message']] - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [getKey]") return [0,"Not able to fetch key from remote server, Error Message:" + str(msg)] @@ -105,7 +105,7 @@ class remoteBackup: writeToFile.writelines("completed[success]") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [initiateRestore]") @staticmethod @@ -144,7 +144,7 @@ class remoteBackup: pid.write(str(p.pid)) pid.close() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [remoteRestore]") return [0, msg] @@ -164,7 +164,7 @@ class remoteBackup: else: return [0, data['error_message']] - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [postRemoteTransfer]") return [0, msg] @@ -210,7 +210,7 @@ class remoteBackup: writeToFile.writelines("\n") writeToFile.writelines("\n") - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [214:startBackup]") @@ -223,7 +223,7 @@ class remoteBackup: subprocess.call(shlex.split(command), stdout=writeToFile) os.remove(completedPathToSend) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]") @staticmethod @@ -308,7 +308,7 @@ class remoteBackup: time.sleep(5) #rmtree(dir) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupProcess]") @staticmethod @@ -358,6 +358,6 @@ class remoteBackup: return [1, None] - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [remoteTransfer]") return [0, msg] diff --git a/plogical/remoteTransferUtilities.py b/plogical/remoteTransferUtilities.py index 6d537a83e..e3a23831d 100755 --- a/plogical/remoteTransferUtilities.py +++ b/plogical/remoteTransferUtilities.py @@ -1,18 +1,17 @@ import argparse import os -import CyberCPLogFileWriter as logging -import backupUtilities as backupUtil +import sys +sys.path.append('/usr/local/CyberCP') +from plogical import CyberCPLogFileWriter as logging +from plogical import backupUtilities as backupUtil import time from multiprocessing import Process -import json -import requests import subprocess import shlex from shutil import move from plogical.virtualHostUtilities import virtualHostUtilities from plogical.processUtilities import ProcessUtilities -from backupSchedule import backupSchedule -import shutil +from plogical.backupSchedule import backupSchedule class remoteTransferUtilities: @@ -30,7 +29,7 @@ class remoteTransferUtilities: os.remove(pathToKey) except: pass - print "1,None" + print("1,None") return except: pass @@ -45,12 +44,12 @@ class remoteTransferUtilities: os.remove(pathToKey) except: pass - print "1,None" + print("1,None") return - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile("For remote transfer, I am not able to write key to auth file, Error Message: "+str(msg)) - print "0,"+"For remote transfer, I am not able to write key to auth file, Error Message: " + str(msg) + print("0,"+"For remote transfer, I am not able to write key to auth file, Error Message: " + str(msg)) ## House keeping function to run remote backups @staticmethod @@ -110,7 +109,7 @@ class remoteTransferUtilities: return - except BaseException, msg: + except BaseException as msg: writeToFile = open(backupLogPath, "w+") writeToFile.writelines(str(msg) + " [5010]" + "\n") writeToFile.close() @@ -168,7 +167,7 @@ class remoteTransferUtilities: writeToFile.writelines("[" + time.strftime( "%m.%d.%Y_%H-%M-%S") + "]" + "Failed to generate local backup for: " + virtualHost + "\n") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [remoteTransferUtilities.backupProcess:173]") pass @@ -181,7 +180,7 @@ class remoteTransferUtilities: #time.sleep(5) # rmtree(dir) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupProcess]") @staticmethod @@ -194,7 +193,7 @@ class remoteTransferUtilities: os.remove(completedPathToSend) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]") @staticmethod @@ -236,7 +235,7 @@ class remoteTransferUtilities: return - except BaseException, msg: + except BaseException as msg: backupLogPath = backupDir + "/backup_log" writeToFile = open(backupLogPath, "w+") writeToFile.writelines(str(msg) + " [5010]" + "\n") @@ -262,7 +261,7 @@ class remoteTransferUtilities: writeToFile.close() backupFile = backup - execPath = "sudo nice -n 10 /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" + execPath = "sudo nice -n 10 /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" execPath = execPath + " submitRestore --backupFile " + backupFile + " --dir " + dir subprocess.Popen(shlex.split(execPath)) time.sleep(4) @@ -320,7 +319,7 @@ class remoteTransferUtilities: "%m.%d.%Y_%H-%M-%S") + "]" + " Backup Restore complete\n") writeToFile.writelines("completed[success]") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [remoteTransferUtilities.startRestore]") diff --git a/plogical/renew.py b/plogical/renew.py index 08709fc7a..70d43bd29 100644 --- a/plogical/renew.py +++ b/plogical/renew.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os import os.path import sys @@ -99,7 +99,7 @@ class Renew: virtualHostUtilities.issueSSL(website.domain, website.path, website.master.adminEmail) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + '. Renew.SSLObtainer') diff --git a/IncBackups/restoreMeta.py b/plogical/restoreMeta.py similarity index 97% rename from IncBackups/restoreMeta.py rename to plogical/restoreMeta.py index 863733514..8a267d38a 100644 --- a/IncBackups/restoreMeta.py +++ b/plogical/restoreMeta.py @@ -1,15 +1,11 @@ -#!/usr/local/CyberCP/bin/python2 -import os +#!/usr/local/CyberCP/bin/python import os.path import sys sys.path.append('/usr/local/CyberCP') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") - import django -try: - django.setup() -except: - pass +django.setup() + from websiteFunctions.models import Websites from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging from xml.etree import ElementTree @@ -49,7 +45,7 @@ class restoreMeta(): virtualHostUtilities.createDomain(masterDomain, domain, phpSelection, path, 0, 0, 0, 'admin', 0) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + " [startRestore]") return 0 @@ -92,7 +88,7 @@ class restoreMeta(): 'Email created: %s' % ( email)) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + " [startRestore]") return 0 @@ -148,7 +144,7 @@ class restoreMeta(): except: pass - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + " [startRestore]") def main(): diff --git a/plogical/serverLogs.py b/plogical/serverLogs.py index 9369d94a4..8789cb025 100755 --- a/plogical/serverLogs.py +++ b/plogical/serverLogs.py @@ -1,4 +1,4 @@ -import CyberCPLogFileWriter as logging +from plogical import CyberCPLogFileWriter as logging import argparse class serverLogs: @@ -8,8 +8,8 @@ class serverLogs: try: logFile = open(fileName,'w') logFile.close() - print "1,None" - except BaseException,msg: + print("1,None") + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[cleanLogFile]") def main(): diff --git a/plogical/sslUtilities.py b/plogical/sslUtilities.py index 0d6f6cae9..4bf312c7d 100755 --- a/plogical/sslUtilities.py +++ b/plogical/sslUtilities.py @@ -1,4 +1,4 @@ -import CyberCPLogFileWriter as logging +from plogical import CyberCPLogFileWriter as logging import os import shlex import subprocess @@ -28,11 +28,11 @@ class sslUtilities: if items.find("}") > -1: return 0 if items.find(virtualHostName) > -1 and sslCheck == 1: - data = filter(None, items.split(" ")) + data = [_f for _f in items.split(" ") if _f] if data[1] == virtualHostName: return 1 - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [IO Error with main config file [checkIfSSLMap]]") return 0 @@ -44,7 +44,7 @@ class sslUtilities: if items.find("listener SSL") > -1: return 1 - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [IO Error with main config file [checkSSLListener]]") return str(msg) return 0 @@ -58,7 +58,7 @@ class sslUtilities: return [1, withWWW, withoutWWW] - except BaseException, msg: + except BaseException as msg: return [0, "347 " + str(msg) + " [issueSSLForDomain]"] @staticmethod @@ -182,7 +182,7 @@ class sslUtilities: writeSSLConfig.close() return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installSSLForDomain]]") return 0 else: @@ -203,7 +203,7 @@ class sslUtilities: chilDomain = ChildDomains.objects.get(domain=virtualHostName) externalApp = chilDomain.master.externalApp DocumentRoot = ' DocumentRoot ' + chilDomain.path + '\n' - except BaseException, msg: + except BaseException as msg: website = Websites.objects.get(domain=virtualHostName) externalApp = website.externalApp DocumentRoot = ' DocumentRoot /home/' + virtualHostName + '/public_html\n' @@ -255,7 +255,7 @@ class sslUtilities: confFile.close() return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installSSLForDomain]") return 0 @@ -284,7 +284,7 @@ class sslUtilities: logging.CyberCPLogFileWriter.writeToFile(command) - output = subprocess.check_output(shlex.split(command)) + output = subprocess.check_output(shlex.split(command)).decode("utf-8") logging.CyberCPLogFileWriter.writeToFile("Successfully obtained SSL for: " + virtualHostName + " and: www." + virtualHostName) @@ -297,7 +297,7 @@ class sslUtilities: command = acmePath + " --issue -d " + virtualHostName + ' --cert-file ' + existingCertPath \ + '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \ + ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force' - output = subprocess.check_output(shlex.split(command)) + output = subprocess.check_output(shlex.split(command)).decode("utf-8") logging.CyberCPLogFileWriter.writeToFile("Successfully obtained SSL for: " + virtualHostName) except subprocess.CalledProcessError: logging.CyberCPLogFileWriter.writeToFile('Failed to obtain SSL, issuing self-signed SSL for: ' + virtualHostName) @@ -318,7 +318,7 @@ class sslUtilities: + ' --cert-file ' + existingCertPath + '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \ + ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force' - output = subprocess.check_output(shlex.split(command)) + output = subprocess.check_output(shlex.split(command)).decode("utf-8") logging.CyberCPLogFileWriter.writeToFile( "Successfully obtained SSL for: " + virtualHostName + ", www." + virtualHostName + ", " + aliasDomain + "and www." + aliasDomain + ",") @@ -335,7 +335,7 @@ class sslUtilities: else: return 0 - except BaseException,msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [Failed to obtain SSL. [obtainSSLForADomain]]") return 0 @@ -362,6 +362,6 @@ def issueSSLForDomain(domain, adminEmail, sslpath, aliasDomain = None): else: return [0, "210 Failed to install SSL for domain. [issueSSLForDomain]"] - except BaseException,msg: + except BaseException as msg: return [0, "347 "+ str(msg)+ " [issueSSLForDomain]"] diff --git a/plogical/tuning.py b/plogical/tuning.py index 5694149fb..e146a0d28 100755 --- a/plogical/tuning.py +++ b/plogical/tuning.py @@ -1,9 +1,9 @@ -import CyberCPLogFileWriter as logging -from installUtilities import installUtilities +import sys +sys.path.append('/usr/local/CyberCP') +from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging +from plogical.installUtilities import installUtilities import argparse -import subprocess -import shlex -from processUtilities import ProcessUtilities +from plogical.processUtilities import ProcessUtilities from xml.etree import ElementTree class tuning: @@ -49,7 +49,7 @@ class tuning: dataToReturn['enableGzipCompress'] = data[1] return dataToReturn - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [fetchTuningDetails]") return 0 @@ -71,7 +71,7 @@ class tuning: return dataToReturn - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [fetchTuningDetails]") return 0 @@ -125,11 +125,11 @@ class tuning: writeDataToFile.close() - print "1,None" - except BaseException, msg: + print("1,None") + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [saveTuningDetails]") - print "0," + str(msg) + print("0," + str(msg)) else: try: datas = open("/usr/local/lsws/conf/httpd_config.xml").readlines() @@ -173,11 +173,11 @@ class tuning: else: writeDataToFile.writelines(items) writeDataToFile.close() - print "1,None" - except BaseException, msg: + print("1,None") + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [saveTuningDetails]") - print "0," + str(msg) + print("0," + str(msg)) @staticmethod @@ -223,7 +223,7 @@ class tuning: dataToReturn['procHardLimit'] = data[1] return dataToReturn - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [fetchPHPDetails]") return 0 @@ -248,7 +248,7 @@ class tuning: break return dataToReturn - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [fetchPHPDetails]") return 0 @@ -308,11 +308,11 @@ class tuning: writeDataToFile.close() - print "1,None" - except BaseException, msg: + print("1,None") + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [saveTuningDetails]") - print "0,"+str(msg) + print("0,"+str(msg)) else: try: path = "/usr/local/lsws/conf/httpd_config.xml" @@ -377,12 +377,12 @@ class tuning: writeDataToFile.close() - print "1,None" + print("1,None") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [saveTuningDetails]") - print "0," + str(msg) + print("0," + str(msg)) def main(): diff --git a/plogical/upgrade.py b/plogical/upgrade.py index 6aade47a2..6df96c15b 100755 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -1,23 +1,19 @@ import os import os.path import sys -import django - +import argparse sys.path.append('/usr/local/CyberCP') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") -django.setup() import shlex import subprocess import shutil import requests import json import time -from baseTemplate.models import version import MySQLdb as mysql from CyberCP import settings import random import string -from mailServer.models import EUsers class Upgrade: @@ -27,11 +23,11 @@ class Upgrade: @staticmethod def stdOut(message, do_exit=0): print("\n\n") - print ("[" + time.strftime( - "%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n") - print("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] " + message + "\n") - print ("[" + time.strftime( - "%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n") + print(("[" + time.strftime( + "%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n")) + print(("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] " + message + "\n")) + print(("[" + time.strftime( + "%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n")) if do_exit: os._exit(0) @@ -124,36 +120,9 @@ class Upgrade: writeToFile.writelines(varTmp) writeToFile.close() - except BaseException, msg: + except BaseException as msg: Upgrade.stdOut(str(msg) + " [mountTemp]", 0) - @staticmethod - def setupPythonWSGI(): - try: - - cwd = os.getcwd() - - command = "wget http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.4.tgz" - Upgrade.executioner(command, 0) - - command = "tar xf wsgi-lsapi-1.4.tgz" - Upgrade.executioner(command, 0) - - os.chdir("wsgi-lsapi-1.4") - - command = "python ./configure.py" - Upgrade.executioner(command, 0) - - command = "make" - Upgrade.executioner(command, 0) - - command = "cp lswsgi /usr/local/CyberCP/bin/" - Upgrade.executioner(command, 0) - - os.chdir(cwd) - - except: - return 0 @staticmethod def dockerUsers(): @@ -241,7 +210,7 @@ class Upgrade: ## Write secret phrase - rString = ''.join([random.choice(string.ascii_letters + string.digits) for n in xrange(32)]) + rString = ''.join([random.choice(string.ascii_letters + string.digits) for n in range(32)]) data = open('/usr/local/CyberCP/public/phpmyadmin/config.sample.inc.php', 'r').readlines() @@ -262,11 +231,15 @@ class Upgrade: os.chdir(cwd) - except BaseException, msg: + except BaseException as msg: Upgrade.stdOut(str(msg) + " [download_install_phpmyadmin]", 0) @staticmethod def setupComposer(): + + if os.path.exists('composer.sh'): + os.remove('composer.sh') + command = "wget https://cyberpanel.sh/composer.sh" Upgrade.executioner(command, 0) @@ -410,7 +383,7 @@ class Upgrade: os.chdir(cwd) - except BaseException, msg: + except BaseException as msg: Upgrade.stdOut(str(msg) + " [downoad_and_install_raindloop]", 0) return 1 @@ -434,51 +407,10 @@ class Upgrade: pass return (version_number + "." + version_build + ".tar.gz") - except BaseException, msg: + except BaseException as msg: Upgrade.stdOut(str(msg) + ' [downloadLink]') os._exit(0) - @staticmethod - def setupVirtualEnv(): - try: - Upgrade.stdOut('Setting up virtual environment for CyberPanel.') - ## - - command = "yum install -y libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel" - Upgrade.executioner(command, 'VirtualEnv Pre-reqs', 0) - - command = "yum install -y libattr-devel xz-devel gpgme-devel curl-devel" - Upgrade.executioner(command, 'VirtualEnv Pre-reqs', 0) - - ## - - command = "pip install virtualenv" - Upgrade.executioner(command, 'VirtualEnv Install', 0) - - #### - - command = "virtualenv --system-site-packages /usr/local/CyberCP" - Upgrade.executioner(command, 'Setting up VirtualEnv [One]', 1) - - ## - - env_path = '/usr/local/CyberCP' - subprocess.call(['virtualenv', env_path]) - activate_this = os.path.join(env_path, 'bin', 'activate_this.py') - execfile(activate_this, dict(__file__=activate_this)) - - ## - - command = "pip install --ignore-installed -r /usr/local/CyberCP/requirments.txt" - Upgrade.executioner(command, 'CyberPanel requirements', 0) - - command = "virtualenv --system-site-packages /usr/local/CyberCP" - Upgrade.executioner(command, 'Setting up VirtualEnv [Two]', 0) - - Upgrade.stdOut('Virtual enviroment for CyberPanel successfully installed.') - except OSError, msg: - Upgrade.stdOut(str(msg) + " [setupVirtualEnv]", 0) - @staticmethod def fileManager(): ## Copy File manager files @@ -508,7 +440,7 @@ class Upgrade: command = "chmod +x /usr/local/CyberCP/cli/cyberPanel.py" Upgrade.executioner(command, 'CLI Permissions', 0) - except OSError, msg: + except OSError as msg: Upgrade.stdOut(str(msg) + " [setupCLI]") return 0 @@ -528,6 +460,12 @@ class Upgrade: @staticmethod def upgradeVersion(): try: + + import django + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") + django.setup() + from baseTemplate.models import version + vers = version.objects.get(pk=1) getVersion = requests.get('https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/version.txt') latest = getVersion.json() @@ -568,7 +506,7 @@ class Upgrade: cursor = conn.cursor() return conn, cursor - except BaseException, msg: + except BaseException as msg: Upgrade.stdOut(str(msg)) return 0, 0 @@ -670,7 +608,7 @@ class Upgrade: except: pass - except OSError, msg: + except OSError as msg: Upgrade.stdOut(str(msg) + " [applyLoginSystemMigrations]") @staticmethod @@ -856,7 +794,7 @@ class Upgrade: except: pass - except OSError, msg: + except OSError as msg: Upgrade.stdOut(str(msg) + " [applyLoginSystemMigrations]") @staticmethod @@ -1216,11 +1154,11 @@ class Upgrade: cwd = os.getcwd() os.chdir('/usr/local/CyberCP') - command = '/usr/local/CyberPanel/bin/python2 manage.py makemigrations' + command = '/usr/local/CyberPanel/bin/python manage.py makemigrations' Upgrade.executioner(command, 'python manage.py makemigrations', 0) - command = '/usr/local/CyberPanel/bin/python2 manage.py makemigrations' - Upgrade.executioner(command, '/usr/local/CyberPanel/bin/python2 manage.py migrate', 0) + command = '/usr/local/CyberPanel/bin/python manage.py makemigrations' + Upgrade.executioner(command, '/usr/local/CyberPanel/bin/python manage.py migrate', 0) os.chdir(cwd) @@ -1324,11 +1262,11 @@ class Upgrade: command = 'sudo yum install git -y' Upgrade.executioner(command, 'installGit', 0) - except BaseException, msg: + except BaseException as msg: pass @staticmethod - def downloadAndUpgrade(versionNumbring): + def downloadAndUpgrade(versionNumbring, branch): try: ## Download latest version. @@ -1357,6 +1295,15 @@ class Upgrade: shutil.move('cyberpanel', 'CyberCP') + if branch != 'stable': + os.chdir('CyberCP') + command = 'git checkout %s' % (branch) + Upgrade.executioner(command, command, 1) + os.chdir('/usr/local') + + + + ## Copy settings file data = open("/usr/local/settings.py", 'r').readlines() @@ -1522,26 +1469,6 @@ CSRF_COOKIE_SECURE = True except: pass - @staticmethod - def installPYDNS(): - try: - command = "pip install pydns" - Upgrade.executioner(command, 'Install PyDNS', 1) - except OSError, msg: - Upgrade.stdOut(str(msg) + " [installPYDNS]") - return 0 - - @staticmethod - def installTLDExtract(): - try: - command = "pip install tldextract" - Upgrade.executioner(command, 'Install tldextract', 1) - command = "pip install bcrypt" - Upgrade.executioner(command, 'Install tldextract', 1) - except OSError, msg: - Upgrade.stdOut(str(msg) + " [installTLDExtract]") - return 0 - @staticmethod def installLSCPD(): try: @@ -1593,7 +1520,7 @@ CSRF_COOKIE_SECURE = True Upgrade.stdOut("LSCPD successfully installed!") - except BaseException, msg: + except BaseException as msg: Upgrade.stdOut(str(msg) + " [installLSCPD]") @staticmethod @@ -1723,9 +1650,18 @@ CSRF_COOKIE_SECURE = True command = 'chmod +x /usr/local/CyberCP/CLManager/CLPackages.py' Upgrade.executioner(command, command, 0) + clScripts = ['/usr/local/CyberCP/CLScript/panel_info.py', '/usr/local/CyberCP/CLScript/CloudLinuxPackages.py', + '/usr/local/CyberCP/CLScript/CloudLinuxUsers.py', '/usr/local/CyberCP/CLScript/CloudLinuxDomains.py' + ,'/usr/local/CyberCP/CLScript/CloudLinuxResellers.py', '/usr/local/CyberCP/CLScript/CloudLinuxAdmins.py', + '/usr/local/CyberCP/CLScript/CloudLinuxDB.py', '/usr/local/CyberCP/CLScript/UserInfo.py'] + + for items in clScripts: + command = 'chmod +x %s' % (items) + Upgrade.executioner(command, 0) + Upgrade.stdOut("Permissions updated.") - except BaseException, msg: + except BaseException as msg: Upgrade.stdOut(str(msg) + " [installLSCPD]") @staticmethod @@ -1816,12 +1752,17 @@ enabled=1""" writeToFile.close() + import django + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") + django.setup() + from mailServer.models import EUsers + Upgrade.stdOut("Upgrading passwords...") for items in EUsers.objects.all(): if items.password.find('CRYPT') > -1: continue command = 'doveadm pw -p %s' % (items.password) - items.password = subprocess.check_output(shlex.split(command)).strip('\n') + items.password = subprocess.check_output(shlex.split(command)).decode("utf-8").strip('\n') items.save() command = "systemctl restart dovecot" @@ -1943,11 +1884,17 @@ failovermethod=priority writeToFile.close() Upgrade.stdOut("Upgrading passwords...") + + import django + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") + django.setup() + from mailServer.models import EUsers + for items in EUsers.objects.all(): if items.password.find('CRYPT') > -1: continue command = 'doveadm pw -p %s' % (items.password) - items.password = subprocess.check_output(shlex.split(command)).strip('\n') + items.password = subprocess.check_output(shlex.split(command)).decode("utf-8").strip('\n') items.save() @@ -1956,7 +1903,7 @@ failovermethod=priority Upgrade.stdOut("Dovecot upgraded.") - except BaseException, msg: + except BaseException as msg: Upgrade.stdOut(str(msg) + " [upgradeDovecot]") @staticmethod @@ -1981,65 +1928,22 @@ failovermethod=priority data = open(cronTab, 'r').read() if data.find('IncScheduler') == -1: - cronJob = '0 12 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n' + cronJob = '0 12 * * * root /usr/local/CyberPanel/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n' writeToFile = open(cronTab, 'a') writeToFile.writelines(cronJob) - cronJob = '0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n' + cronJob = '0 0 * * 0 root /usr/local/CyberPanel/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n' writeToFile.writelines(cronJob) writeToFile.close() if data.find('renew.py') == -1: writeToFile = open(cronTab, 'a') - writeToFile.writelines("0 2 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/renew.py\n") + writeToFile.writelines("0 2 * * * root /usr/local/CyberPanel/bin/python /usr/local/CyberCP/plogical/renew.py\n") writeToFile.close() - @staticmethod - def p3(): - - ### Virtual Env 3 - - CentOSPath = '/etc/redhat-release' - - if os.path.exists(CentOSPath): - command = 'yum -y install python36 -y' - Upgrade.executioner(command, 0) - - command = 'virtualenv -p python3 /usr/local/CyberPanel/p3' - Upgrade.executioner(command, 0) - - env_path = '/usr/local/CyberPanel/p3' - subprocess.call(['virtualenv', env_path]) - activate_this = os.path.join(env_path, 'bin', 'activate_this.py') - execfile(activate_this, dict(__file__=activate_this)) - - command = "pip3 install --ignore-installed -r %s" % ('/usr/local/CyberCP/WebTerminal/requirments.txt') - Upgrade.executioner(command, 0) - - else: - command = 'apt install -y python3-pip' - Upgrade.executioner(command, 0) - - command = 'apt install build-essential libssl-dev libffi-dev python3-dev -y' - Upgrade.executioner(command, 0) - - command = 'apt install -y python3-venv' - Upgrade.executioner(command, 0) - - command = 'virtualenv -p python3 /usr/local/CyberPanel/p3' - Upgrade.executioner(command, 0) - - env_path = '/usr/local/CyberPanel/p3' - subprocess.call(['virtualenv', env_path]) - activate_this = os.path.join(env_path, 'bin', 'activate_this.py') - execfile(activate_this, dict(__file__=activate_this)) - - command = "pip3 install --ignore-installed -r %s" % ('/usr/local/CyberCP/WebTerminal/requirments.txt') - Upgrade.executioner(command, 0) - @staticmethod def UpdateMaxSSLCons(): command = "sed -i 's|2000|10000|g' /usr/local/lsws/conf/httpd_config.xml" @@ -2048,10 +1952,45 @@ failovermethod=priority command = "sed -i 's|200|10000|g' /usr/local/lsws/conf/httpd_config.xml" Upgrade.executioner(command, 0) + @staticmethod + def installCLScripts(): + try: + + CentOSPath = '/etc/redhat-release' + + if os.path.exists(CentOSPath): + command = 'mkdir -p /opt/cpvendor/etc/' + Upgrade.executioner(command, 0) + + content = """[integration_scripts] + +panel_info = /usr/local/CyberCP/CLScript/panel_info.py +packages = /usr/local/CyberCP/CLScript/CloudLinuxPackages.py +users = /usr/local/CyberCP/CLScript/CloudLinuxUsers.py +domains = /usr/local/CyberCP/CLScript/CloudLinuxDomains.py +resellers = /usr/local/CyberCP/CLScript/CloudLinuxResellers.py +admins = /usr/local/CyberCP/CLScript/CloudLinuxAdmins.py +db_info = /usr/local/CyberCP/CLScript/CloudLinuxDB.py + +[lvemanager_config] +ui_user_info = /usr/local/CyberCP/CLScript/UserInfo.py +base_path = /usr/local/lvemanager +run_service = 1 +service_port = 9000 +""" + + if not os.path.exists('/opt/cpvendor/etc/integration.ini'): + writeToFile = open('/opt/cpvendor/etc/integration.ini', 'w') + writeToFile.write(content) + writeToFile.close() + + except: + pass + @staticmethod - def upgrade(): + def upgrade(branch): # Upgrade.stdOut("Upgrades are currently disabled") # return 0 @@ -2072,7 +2011,6 @@ failovermethod=priority ## Current Version - Version = version.objects.get(pk=1) command = "systemctl stop lscpd" Upgrade.executioner(command, 'stop lscpd', 0) @@ -2089,21 +2027,14 @@ failovermethod=priority if os.path.exists('/usr/local/CyberPanel.' + versionNumbring): os.remove('/usr/local/CyberPanel.' + versionNumbring) - if float(Version.currentVersion) < 1.6: - Upgrade.stdOut('Upgrades works for version 1.6 onwards.') - os._exit(0) - ## - Upgrade.installPYDNS() - Upgrade.downloadAndUpgrade(versionNumbring) + Upgrade.downloadAndUpgrade(versionNumbring, branch) Upgrade.download_install_phpmyadmin() Upgrade.downoad_and_install_raindloop() ## - Upgrade.installTLDExtract() - ## Upgrade.mailServerMigrations() @@ -2115,7 +2046,7 @@ failovermethod=priority ## - Upgrade.setupVirtualEnv() + #Upgrade.setupVirtualEnv() ## @@ -2127,7 +2058,6 @@ failovermethod=priority Upgrade.installPHP73() Upgrade.setupCLI() - Upgrade.setupPythonWSGI() Upgrade.someDirectories() Upgrade.installLSCPD() Upgrade.GeneralMigrations() @@ -2167,12 +2097,18 @@ failovermethod=priority command = 'systemctl start cpssh' Upgrade.executioner(command, 'fix csf if there', 0) Upgrade.AutoUpgradeAcme() + Upgrade.installCLScripts() Upgrade.stdOut("Upgrade Completed.") def main(): - Upgrade.upgrade() + parser = argparse.ArgumentParser(description='CyberPanel Installer') + parser.add_argument('branch', help='Install from branch name.') + + args = parser.parse_args() + + Upgrade.upgrade(args.branch) if __name__ == "__main__": diff --git a/plogical/upgradeCritical.py b/plogical/upgradeCritical.py index 8a1fded6b..0bf38086e 100755 --- a/plogical/upgradeCritical.py +++ b/plogical/upgradeCritical.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import sys sys.path.append('/usr/local/CyberCP') import subprocess, shlex @@ -16,7 +16,7 @@ class UpgradeCritical: return 1 else: return 0 - except BaseException, msg: + except BaseException as msg: return 0 @staticmethod diff --git a/plogical/vhost.py b/plogical/vhost.py index 148cd2596..583db1d7a 100755 --- a/plogical/vhost.py +++ b/plogical/vhost.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os import os.path import sys @@ -10,18 +10,18 @@ try: except: pass import shutil -import installUtilities +from plogical import installUtilities import subprocess import shlex -import CyberCPLogFileWriter as logging +from plogical import CyberCPLogFileWriter as logging -from mysqlUtilities import mysqlUtilities -from dnsUtilities import DNS +from plogical.mysqlUtilities import mysqlUtilities +from plogical.dnsUtilities import DNS from random import randint -from processUtilities import ProcessUtilities +from plogical.processUtilities import ProcessUtilities from managePHP.phpManager import PHPManager -from vhostConfs import vhostConfs +from plogical.vhostConfs import vhostConfs from ApachController.ApacheVhosts import ApacheVhost try: from websiteFunctions.models import Websites, ChildDomains, aliasDomains @@ -57,7 +57,7 @@ class vhost: cmd = shlex.split(command) subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [addingUsers]") @staticmethod @@ -83,7 +83,7 @@ class vhost: cmd = shlex.split(command) subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [27 Not able create to directories for virtual host [createDirectories]]") return [0, "[27 Not able to directories for virtual host [createDirectories]]"] @@ -95,7 +95,7 @@ class vhost: cmd = shlex.split(command) subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [33 Not able to directories for virtual host [createDirectories]]") return [0, "[33 Not able to directories for virtual host [createDirectories]]"] @@ -121,7 +121,7 @@ class vhost: cmd = shlex.split(command) subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [39 Not able to directories for virtual host [createDirectories]]") return [0, "[39 Not able to directories for virtual host [createDirectories]]"] @@ -129,7 +129,7 @@ class vhost: try: ## For configuration files permissions will be changed later globally. os.makedirs(confPath) - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [45 Not able to directories for virtual host [createDirectories]]") return [0, "[45 Not able to directories for virtual host [createDirectories]]"] @@ -146,13 +146,13 @@ class vhost: cmd = shlex.split(command) subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) - except IOError, msg: + except IOError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createDirectories]]") return [0, "[45 Not able to directories for virtual host [createDirectories]]"] return [1, 'None'] - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createDirectories]") return [0, str(msg)] @@ -174,7 +174,7 @@ class vhost: cmd = shlex.split(command) subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [finalizeVhostCreation]") @staticmethod @@ -232,7 +232,7 @@ class vhost: confFile.write(currentConf) confFile.close() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [IO Error with per host config file [perHostVirtualConf]]") return 0 @@ -252,7 +252,7 @@ class vhost: confFile.write(currentConf) confFile.close() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [IO Error with per host config file [perHostVirtualConf]]") return 0 @@ -277,7 +277,7 @@ class vhost: writeDataToFile.writelines(items) return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -298,7 +298,7 @@ class vhost: writeDataToFile.close() return [1,"None"] - except BaseException,msg: + except BaseException as 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: @@ -310,7 +310,7 @@ class vhost: writeDataToFile.close() return [1, "None"] - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + "223 [IO Error with main config file [createConfigInMainVirtualHostFile]]") return [0, "223 [IO Error with main config file [createConfigInMainVirtualHostFile]]"] @@ -326,10 +326,7 @@ class vhost: delWebsite = Websites.objects.get(domain=virtualHostName) - ## Cagefs - - command = '/usr/sbin/cagefsctl --disable %s' % (delWebsite.externalApp) - ProcessUtilities.normalExecutioner(command) + ## databases = Databases.objects.filter(website=delWebsite) @@ -356,7 +353,7 @@ class vhost: command = "sudo rm -rf /home/vmail/" + virtualHostName subprocess.call(shlex.split(command)) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [Not able to remove virtual host configuration from main configuration file.]") return 0 return 1 @@ -398,7 +395,7 @@ class vhost: command = "sudo rm -rf /home/vmail/" + virtualHostName subprocess.call(shlex.split(command)) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [Not able to remove virtual host configuration from main configuration file.]") return 0 @@ -451,7 +448,7 @@ class vhost: ApacheVhost.DeleteApacheVhost(virtualHostName) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [Not able to remove virtual host configuration from main configuration file.]") return 0 @@ -460,14 +457,14 @@ class vhost: virtualHostPath = "/home/" + virtualHostName try: shutil.rmtree(virtualHostPath) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [Not able to remove virtual host directory from /home continuing..]") try: confPath = vhost.Server_root + "/conf/vhosts/" + virtualHostName shutil.rmtree(confPath) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [Not able to remove virtual host configuration directory from /conf ]") @@ -484,7 +481,7 @@ class vhost: writeDataToFile.close() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [Not able to remove virtual host configuration from main configuration file.]") return 0 @@ -507,7 +504,7 @@ class vhost: php = PHPManager.getPHPString(phpVersion) if not os.path.exists("/usr/local/lsws/lsphp" + str(php) + "/bin/lsphp"): - print 0, 'This PHP version is not available on your CyberPanel.' + print(0, 'This PHP version is not available on your CyberPanel.') return [0, "[This PHP version is not available on your CyberPanel. [changePHP]"] writeDataToFile = open(vhFile, "w") @@ -535,12 +532,12 @@ class vhost: command = "systemctl restart php%s-php-fpm" % (php) ProcessUtilities.normalExecutioner(command) - print "1,None" + print("1,None") return 1,'None' - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [IO Error with per host config file [changePHP]") - print 0,str(msg) + print(0,str(msg)) return [0, str(msg) + " [IO Error with per host config file [changePHP]"] else: try: @@ -549,7 +546,7 @@ class vhost: php = PHPManager.getPHPString(phpVersion) if not os.path.exists("/usr/local/lsws/lsphp" + str(php) + "/bin/lsphp"): - print 0, 'This PHP version is not available on your CyberPanel.' + print(0, 'This PHP version is not available on your CyberPanel.') return [0, "[This PHP version is not available on your CyberPanel. [changePHP]"] writeDataToFile = open(vhFile, "w") @@ -573,19 +570,19 @@ class vhost: except: pass - print "1,None" + print("1,None") return 1, 'None' - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [IO Error with per host config file [changePHP]]") - print 0, str(msg) + print(0, str(msg)) return [0, str(msg) + " [IO Error with per host config file [changePHP]]"] @staticmethod def addRewriteRules(virtualHostName, fileName=None): try: pass - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [IO Error with per host config file [changePHP]]") return 0 @@ -599,7 +596,7 @@ class vhost: return 1 return 0 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [IO Error with per host config file [checkIfRewriteEnabled]]") return 0 @@ -610,12 +607,12 @@ class vhost: path = "/home/" + domainName + "/logs/" + domainName + ".access_log" if not os.path.exists("/home/" + domainName + "/logs"): - print "0,0" + print("0,0") bwmeta = "/home/" + domainName + "/logs/bwmeta" if not os.path.exists(path): - print "0,0" + print("0,0") if os.path.exists(bwmeta): try: @@ -630,20 +627,20 @@ class vhost: percentage = float(100) / float(totalAllowed) percentage = float(percentage) * float(inMB) except: - print "0,0" + print("0,0") if percentage > 100.0: percentage = 100 - print str(inMB) + "," + str(percentage) + print(str(inMB) + "," + str(percentage)) else: - print "0,0" - except OSError, msg: + print("0,0") + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [findDomainBW]") - print "0,0" - except ValueError, msg: + print("0,0") + except ValueError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [findDomainBW]") - print "0,0" + print("0,0") @staticmethod def permissionControl(path): @@ -651,7 +648,7 @@ class vhost: command = 'sudo chown -R cyberpanel:cyberpanel ' + path cmd = shlex.split(command) res = subprocess.call(cmd) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) @staticmethod @@ -663,7 +660,7 @@ class vhost: res = subprocess.call(cmd) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) @staticmethod @@ -671,7 +668,7 @@ class vhost: try: alias = aliasDomains.objects.get(aliasDomain=aliasDomain) return 1 - except BaseException, msg: + except BaseException as msg: return 0 @staticmethod @@ -682,7 +679,7 @@ class vhost: return 1 return 0 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [checkIfSSLAliasExists]") return 1 @@ -699,7 +696,7 @@ class vhost: if (items.find("listener SSL") > -1): sslCheck = 1 if items.find(masterDomain) > -1 and items.find('map') > -1 and sslCheck == 1: - data = filter(None, items.split(" ")) + data = [_f for _f in items.split(" ") if _f] if data[1] == masterDomain: if vhost.checkIfSSLAliasExists(data, aliasDomain) == 0: writeToFile.writelines(items.rstrip('\n') + ", " + aliasDomain + "\n") @@ -712,7 +709,7 @@ class vhost: writeToFile.close() installUtilities.installUtilities.reStartLiteSpeed() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createAliasSSLMap]") ## Child Domain Functions @@ -734,7 +731,7 @@ class vhost: cmd = shlex.split(command) subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [finalizeDomainCreation]") @staticmethod @@ -751,14 +748,14 @@ class vhost: command = "chown " + virtualHostUser + ":" + virtualHostUser + " " + path cmd = shlex.split(command) subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + "329 [Not able to create directories for virtual host [createDirectoryForDomain]]") try: ## For configuration files permissions will be changed later globally. os.makedirs(confPath) - except OSError, msg: + except OSError as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + "335 [Not able to create directories for virtual host [createDirectoryForDomain]]") return [0, "[344 Not able to directories for virtual host [createDirectoryForDomain]]"] @@ -766,7 +763,7 @@ class vhost: try: ## For configuration files permissions will be changed later globally. file = open(completePathToConfigFile, "w+") - except IOError, msg: + except IOError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createDirectoryForDomain]]") return [0, "[351 Not able to directories for virtual host [createDirectoryForDomain]]"] @@ -803,7 +800,7 @@ class vhost: confFile.write(currentConf) confFile.close() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [IO Error with per host config file [perHostDomainConf]]") return 0 @@ -826,7 +823,7 @@ class vhost: confFile.write(currentConf) confFile.close() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [IO Error with per host config file [perHostDomainConf]]") return 0 @@ -852,7 +849,7 @@ class vhost: return [1, "None"] - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + "223 [IO Error with main config file [createConfigInMainDomainHostFile]]") return [0, "223 [IO Error with main config file [createConfigInMainDomainHostFile]]"] @@ -863,7 +860,7 @@ class vhost: writeDataToFile.writelines(configFile) writeDataToFile.close() return [1, "None"] - except BaseException, msg: + except BaseException as 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/virtualHostUtilities.py b/plogical/virtualHostUtilities.py index 1cd433c3d..2dfd6c8af 100755 --- a/plogical/virtualHostUtilities.py +++ b/plogical/virtualHostUtilities.py @@ -1,21 +1,21 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os import os.path import sys import django +#PACKAGE_PARENT = '..' +#SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__)))) +#sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT))) sys.path.append('/usr/local/CyberCP') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") -try: - django.setup() -except: - pass +django.setup() import shutil import argparse -import installUtilities -import sslUtilities +from plogical import installUtilities +from plogical import sslUtilities from os.path import join from os import listdir, rmdir from shutil import move @@ -23,12 +23,12 @@ from multiprocessing import Process import subprocess import shlex from plogical.mailUtilities import mailUtilities -import CyberCPLogFileWriter as logging -from dnsUtilities import DNS -from vhost import vhost -from applicationInstaller import ApplicationInstaller -from acl import ACLManager -from processUtilities import ProcessUtilities +from plogical import CyberCPLogFileWriter as logging +from plogical.dnsUtilities import DNS +from plogical.vhost import vhost +from plogical.applicationInstaller import ApplicationInstaller +from plogical.acl import ACLManager +from plogical.processUtilities import ProcessUtilities from ApachController.ApacheController import ApacheController from ApachController.ApacheVhosts import ApacheVhost from managePHP.phpManager import PHPManager @@ -50,37 +50,6 @@ class virtualHostUtilities: ols = 2 lsws = 3 - @staticmethod - def EnableCloudLinux(): - if ProcessUtilities.decideServer() == ProcessUtilities.OLS: - confPath = '/usr/local/lsws/conf/httpd_config.conf' - data = open(confPath, 'r').readlines() - - writeToFile = open(confPath, 'w') - - for items in data: - if items.find('priority') > -1: - writeToFile.writelines(items) - writeToFile.writelines('enableLVE 2\n') - else: - writeToFile.writelines(items) - - writeToFile.close() - else: - confPath = '/usr/local/lsws/conf/httpd_config.xml' - data = open(confPath, 'r').readlines() - - writeToFile = open(confPath, 'w') - - for items in data: - if items.find('') > -1: - writeToFile.writelines(items) - writeToFile.writelines(' 2\n') - else: - writeToFile.writelines(items) - - writeToFile.close() - Server_root = "/usr/local/lsws" cyberPanel = "/usr/local/CyberCP" @@ -216,53 +185,24 @@ class virtualHostUtilities: if dkimCheck == 1: DNS.createDKIMRecords(virtualHostName) - cageFSPath = '/home/cyberpanel/cagefs' + # cageFSPath = '/home/cyberpanel/cagefs' + # + # if os.path.exists(cageFSPath): + # command = '/usr/sbin/cagefsctl --enable %s' % (virtualHostUser) + # ProcessUtilities.normalExecutioner(command) - if os.path.exists(cageFSPath): - command = '/usr/sbin/cagefsctl --enable %s' % (virtualHostUser) - ProcessUtilities.normalExecutioner(command) - logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Website successfully created. [200]') CLPath = '/etc/sysconfig/cloudlinux' if os.path.exists(CLPath): - if CLPackages.objects.count() == 0: - package = Package.objects.get(packageName='Default') - clPackage = CLPackages(name='Default', owner=package, speed='100%', vmem='1G', pmem='1G', io='1024', - iops='1024', ep='20', nproc='50', inodessoft='20', inodeshard='20') - clPackage.save() + command = '/usr/share/cloudlinux/hooks/post_modify_user.py create --username %s --owner %s' % (virtualHostUser, virtualHostUser) + ProcessUtilities.executioner(command) - writeToFile = open(CLPath, 'a') - writeToFile.writelines('CUSTOM_GETPACKAGE_SCRIPT=/usr/local/CyberCP/CLManager/CLPackages.py\n') - writeToFile.close() - - command = 'chmod +x /usr/local/CyberCP/CLManager/CLPackages.py' - ProcessUtilities.normalExecutioner(command) - - virtualHostUtilities.EnableCloudLinux() - installUtilities.installUtilities.reStartLiteSpeed() - - command = 'sudo lvectl package-set %s --speed=%s --pmem=%s --io=%s --nproc=%s --iops=%s --vmem=%s --ep=%s' % ( - 'Default', '100%', '1G', '1024', '50', '1024', '1G', '20') - ProcessUtilities.normalExecutioner(command) - - command = 'sudo lvectl apply all' - ProcessUtilities.normalExecutioner(command) - else: - try: - clPackage = CLPackages.objects.get(owner=selectedPackage) - command = 'sudo lvectl package-set %s --speed=%s --pmem=%s --io=%s --nproc=%s --iops=%s --vmem=%s --ep=%s' % ( - clPackage.name, clPackage.speed, clPackage.pmem, clPackage.io, clPackage.np, clPackage.iops, - clPackage.vmem, clPackage.ep) - ProcessUtilities.normalExecutioner(command) - command = 'sudo lvectl apply all' - ProcessUtilities.normalExecutioner(command) - except: - pass + logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Website successfully created. [200]') return 1, 'None' - except BaseException, msg: + except BaseException as msg: vhost.deleteVirtualHostConfigurations(virtualHostName) logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createVirtualHost]") logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, str(msg) + " [404]") @@ -275,18 +215,18 @@ class virtualHostUtilities: retValues = sslUtilities.issueSSLForDomain(virtualHost, adminEmail, path) if retValues[0] == 0: - print "0," + str(retValues[1]) + print("0," + str(retValues[1])) logging.CyberCPLogFileWriter.writeToFile(str(retValues[1])) return 0, str(retValues[1]) installUtilities.installUtilities.reStartLiteSpeed() - print "1,None" + print("1,None") return 1, None - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [issueSSL]") - print "0," + str(msg) + print("0," + str(msg)) return 0, str(msg) @staticmethod @@ -294,7 +234,7 @@ class virtualHostUtilities: try: if os.path.islink(fileName): - print "0, %s file is symlinked." % (fileName) + print("0, %s file is symlinked." % (fileName)) return 0 numberOfTotalLines = int(ProcessUtilities.outputExecutioner('wc -l %s' % (fileName), externalApp).split(" ")[0]) @@ -318,12 +258,12 @@ class virtualHostUtilities: startingAndEnding = "'" + str(start) + "," + str(end) + "p'" command = "sed -n " + startingAndEnding + " " + fileName data = ProcessUtilities.outputExecutioner(command, externalApp) - print data + print(data) return data - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [getAccessLogs]") - print "1,None" + print("1,None") return "1,None" @staticmethod @@ -331,7 +271,7 @@ class virtualHostUtilities: try: if os.path.islink(fileName): - print "0, %s file is symlinked." % (fileName) + print("0, %s file is symlinked." % (fileName)) return 0 numberOfTotalLines = int( @@ -356,12 +296,12 @@ class virtualHostUtilities: startingAndEnding = "'" + str(start) + "," + str(end) + "p'" command = "sed -n " + startingAndEnding + " " + fileName data = ProcessUtilities.outputExecutioner(command, externalApp) - print data + print(data) return data - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [getErrorLogs]") - print "1,None" + print("1,None") return "1,None" @staticmethod @@ -379,19 +319,19 @@ class virtualHostUtilities: installUtilities.installUtilities.reStartLiteSpeed() - print "1,None" + print("1,None") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [saveVHostConfigs]") - print "0," + str(msg) + print("0," + str(msg)) @staticmethod def saveRewriteRules(virtualHost, fileName, tempPath): try: if os.path.islink(fileName): - print "0, .htaccess file is symlinked." + print("0, .htaccess file is symlinked.") return 0 vhost.addRewriteRules(virtualHost, fileName) @@ -406,12 +346,12 @@ class virtualHostUtilities: except: pass - print "1,None" + print("1,None") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [saveRewriteRules]") - print "0," + str(msg) + print("0," + str(msg)) @staticmethod def installWordPress(domainName, finalPath, virtualHostUser, dbName, dbUser, dbPassword): @@ -430,12 +370,12 @@ class virtualHostUtilities: if dirFiles[0] == ".well-known": pass else: - print "0,Target directory should be empty before installation, otherwise data loss could occur." + print("0,Target directory should be empty before installation, otherwise data loss could occur.") return elif len(dirFiles) == 0: pass else: - print "0,Target directory should be empty before installation, otherwise data loss could occur." + print("0,Target directory should be empty before installation, otherwise data loss could occur.") return ## Get wordpress @@ -514,10 +454,10 @@ class virtualHostUtilities: installUtilities.installUtilities.reStartLiteSpeed() - print "1,None" + print("1,None") - except BaseException, msg: + except BaseException as msg: # remove the downloaded files try: @@ -534,7 +474,7 @@ class virtualHostUtilities: cmd = shlex.split(command) res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) - print "0," + str(msg) + print("0," + str(msg)) return @staticmethod @@ -559,7 +499,7 @@ class virtualHostUtilities: background.start() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [installJoomla]') @staticmethod @@ -584,7 +524,7 @@ class virtualHostUtilities: retValues = sslUtilities.issueSSLForDomain(virtualHost, adminEmail, path) if retValues[0] == 0: - print "0," + str(retValues[1]) + print("0," + str(retValues[1])) return 0, retValues[1] ## removing old certs for lscpd @@ -629,13 +569,13 @@ class virtualHostUtilities: cmd = shlex.split(command) subprocess.call(cmd) - print "1,None" + print("1,None") return 1, 'None' - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [issueSSLForHostName]") - print "0," + str(msg) + print("0," + str(msg)) return 0, str(msg) @staticmethod @@ -650,7 +590,7 @@ class virtualHostUtilities: retValues = sslUtilities.issueSSLForDomain(virtualHost, adminEmail, path) if retValues[0] == 0: - print "0," + str(retValues[1]) + print("0," + str(retValues[1])) return 0, retValues[1] ## MailServer specific functions @@ -732,13 +672,13 @@ class virtualHostUtilities: p = Process(target=mailUtilities.restartServices, args=()) p.start() - print "1,None" + print("1,None") return 1, 'None' - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [issueSSLForHostName]") - print "0," + str(msg) + print("0," + str(msg)) return 0, str(msg) @staticmethod @@ -749,7 +689,7 @@ class virtualHostUtilities: DNS.dnsTemplate(aliasDomain, admin) if vhost.checkIfAliasExists(aliasDomain) == 1: - print "0, This domain already exists as vHost or Alias." + print("0, This domain already exists as vHost or Alias.") return if ProcessUtilities.decideServer() == ProcessUtilities.OLS: @@ -762,7 +702,7 @@ class virtualHostUtilities: if items.find("listener") > -1 and items.find("Default") > -1: listenerTrueCheck = 1 if items.find(' ' + masterDomain) > -1 and items.find('map') > -1 and listenerTrueCheck == 1: - data = filter(None, items.split(" ")) + data = [_f for _f in items.split(" ") if _f] if data[1] == masterDomain: writeToFile.writelines(items.rstrip('\n') + ", " + aliasDomain + "\n") listenerTrueCheck = 0 @@ -791,14 +731,14 @@ class virtualHostUtilities: retValues = sslUtilities.issueSSLForDomain(masterDomain, administratorEmail, sslPath, aliasDomain) if ProcessUtilities.decideServer() == ProcessUtilities.OLS: if retValues[0] == 0: - print "0," + str(retValues[1]) + print("0," + str(retValues[1])) return else: vhost.createAliasSSLMap(confPath, masterDomain, aliasDomain) else: retValues = sslUtilities.issueSSLForDomain(masterDomain, administratorEmail, sslPath, aliasDomain) if retValues[0] == 0: - print "0," + str(retValues[1]) + print("0," + str(retValues[1])) return website = Websites.objects.get(domain=masterDomain) @@ -806,11 +746,11 @@ class virtualHostUtilities: newAlias = aliasDomains(master=website, aliasDomain=aliasDomain) newAlias.save() - print "1,None" + print("1,None") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createAlias]") - print "0," + str(msg) + print("0," + str(msg)) @staticmethod def issueAliasSSL(masterDomain, aliasDomain, sslPath, administratorEmail): @@ -821,21 +761,21 @@ class virtualHostUtilities: if ProcessUtilities.decideServer() == ProcessUtilities.OLS: confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") if retValues[0] == 0: - print "0," + str(retValues[1]) + print("0," + str(retValues[1])) return else: vhost.createAliasSSLMap(confPath, masterDomain, aliasDomain) else: if retValues[0] == 0: - print "0," + str(retValues[1]) + print("0," + str(retValues[1])) return - print "1,None" + print("1,None") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [issueAliasSSL]") - print "0," + str(msg) + print("0," + str(msg)) @staticmethod def deleteAlias(masterDomain, aliasDomain): @@ -850,7 +790,7 @@ class virtualHostUtilities: for items in data: if items.find(masterDomain) > -1 and items.find('map') > -1: - data = filter(None, items.split(" ")) + data = [_f for _f in items.split(" ") if _f] if data[1] == masterDomain: length = len(data) for i in range(3, length): @@ -879,10 +819,10 @@ class virtualHostUtilities: delAlias = aliasDomains.objects.get(aliasDomain=aliasDomain) delAlias.delete() - print "1,None" - except BaseException, msg: + print("1,None") + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [deleteAlias]") - print "0," + str(msg) + print("0," + str(msg)) else: try: @@ -903,10 +843,10 @@ class virtualHostUtilities: alias = aliasDomains.objects.get(aliasDomain=aliasDomain) alias.delete() - print "1,None" - except BaseException, msg: + print("1,None") + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [deleteAlias]") - print "0," + str(msg) + print("0," + str(msg)) @staticmethod def changeOpenBasedir(domainName, openBasedirValue): @@ -954,10 +894,10 @@ class virtualHostUtilities: writeToFile.close() installUtilities.installUtilities.reStartLiteSpeed() - print "1,None" - except BaseException, msg: + print("1,None") + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [changeOpenBasedir]") - print "0," + str(msg) + print("0," + str(msg)) else: try: confPath = virtualHostUtilities.Server_root + "/conf/vhosts/" + domainName @@ -1007,10 +947,10 @@ class virtualHostUtilities: writeToFile.close() installUtilities.installUtilities.reStartLiteSpeed() - print "1,None" - except BaseException, msg: + print("1,None") + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [changeOpenBasedir]") - print "0," + str(msg) + print("0," + str(msg)) @staticmethod def saveSSL(virtualHost, keyPath, certPath): @@ -1045,12 +985,12 @@ class virtualHostUtilities: cmd = shlex.split(command) subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) - print "1,None" + print("1,None") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [saveSSL]") - print "0," + str(msg) + print("0," + str(msg)) @staticmethod def createDomain(masterDomain, virtualHostName, phpVersion, path, ssl, dkimCheck, openBasedir, owner, apache, @@ -1191,7 +1131,7 @@ class virtualHostUtilities: logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Domain successfully created. [200]') return 1, "None" - except BaseException, msg: + except BaseException as msg: numberOfWebsites = Websites.objects.count() + ChildDomains.objects.count() vhost.deleteCoreConf(virtualHostName, numberOfWebsites) logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, str(msg) + ". [404]") @@ -1209,13 +1149,13 @@ class virtualHostUtilities: delWebsite.delete() installUtilities.installUtilities.reStartLiteSpeed() - print "1,None" + print("1,None") return 1, 'None' - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [deleteDomain]") - print "0," + str(msg) + print("0," + str(msg)) return 0, str(msg) @staticmethod @@ -1278,7 +1218,7 @@ class virtualHostUtilities: installUtilities.installUtilities.reStartLiteSpeed() logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Successfully converted. [200]') - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, '%s[404]' % str(msg)) logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [switchServer]") @@ -1310,7 +1250,7 @@ class virtualHostUtilities: res = subprocess.call(cmd) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) @staticmethod @@ -1322,7 +1262,7 @@ class virtualHostUtilities: res = subprocess.call(cmd) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) diff --git a/plogical/website.py b/plogical/website.py index 1bf7aef67..db0752fb0 100755 --- a/plogical/website.py +++ b/plogical/website.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os import os.path import sys @@ -8,31 +8,31 @@ sys.path.append('/usr/local/CyberCP') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") django.setup() import json -from acl import ACLManager -import CyberCPLogFileWriter as logging +from plogical.acl import ACLManager +from plogical import CyberCPLogFileWriter as logging from websiteFunctions.models import Websites, ChildDomains -from virtualHostUtilities import virtualHostUtilities +from plogical.virtualHostUtilities import virtualHostUtilities import subprocess import shlex -from installUtilities import installUtilities +from plogical.installUtilities import installUtilities from django.shortcuts import HttpResponse, render from loginSystem.models import Administrator, ACL from packages.models import Package -from mailUtilities import mailUtilities +from plogical.mailUtilities import mailUtilities from random import randint import time import re -from childDomain import ChildDomainManager +from plogical.childDomain import ChildDomainManager from math import ceil from plogical.alias import AliasManager from plogical.applicationInstaller import ApplicationInstaller from databases.models import Databases -import randomPassword as randomPassword +from plogical import randomPassword as randomPassword import hashlib -from mysqlUtilities import mysqlUtilities +from plogical.mysqlUtilities import mysqlUtilities from plogical import hashPassword from emailMarketing.emACL import emACL -from processUtilities import ProcessUtilities +from plogical.processUtilities import ProcessUtilities from managePHP.phpManager import PHPManager from ApachController.ApacheVhosts import ApacheVhost from plogical.vhostConfs import vhostConfs @@ -62,7 +62,7 @@ class WebsiteManager: Data = {'packageList': packagesName, "owernList": adminNames, 'phps': phps} return render(request, 'websiteFunctions/createWebsite.html', Data) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def modifyWebsite(self, request=None, userID=None, data=None): @@ -77,7 +77,7 @@ class WebsiteManager: phps = PHPManager.findPHPVersions() return render(request, 'websiteFunctions/modifyWebsite.html', {'websiteList': websitesName, 'phps': phps}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def deleteWebsite(self, request=None, userID=None, data=None): @@ -89,7 +89,7 @@ class WebsiteManager: websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'websiteFunctions/deleteWebsite.html', {'websiteList': websitesName}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def siteState(self, request=None, userID=None, data=None): @@ -102,7 +102,7 @@ class WebsiteManager: websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'websiteFunctions/suspendWebsite.html', {'websiteList': websitesName}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def listWebsites(self, request=None, userID=None, data=None): @@ -111,7 +111,7 @@ class WebsiteManager: pagination = self.websitePagination(currentACL, userID) return render(request, 'websiteFunctions/listWebsites.html', {"pagination": pagination}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def listCron(self, request=None, userID=None, data=None): @@ -119,7 +119,7 @@ class WebsiteManager: currentACL = ACLManager.loadedACL(userID) websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'websiteFunctions/listCron.html', {'websiteList': websitesName}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def domainAlias(self, request=None, userID=None, data=None): @@ -143,7 +143,7 @@ class WebsiteManager: 'path': path, 'noAlias': noAlias }) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def submitWebsiteCreation(self, userID=None, data=None): @@ -196,7 +196,7 @@ class WebsiteManager: ## Create Configurations - execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "sudo /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " createVirtualHost --virtualHostName " + domain + \ " --administratorEmail " + adminEmail + " --phpVersion '" + phpSelection + \ "' --virtualHostUser " + externalApp + " --ssl " + str(data['ssl']) + " --dkimCheck " \ @@ -212,7 +212,7 @@ class WebsiteManager: return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -270,7 +270,7 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -293,7 +293,7 @@ class WebsiteManager: final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -303,7 +303,7 @@ class WebsiteManager: currentACL = ACLManager.loadedACL(userID) try: json_data = self.searchWebsitesJson(currentACL, userID, data['patternAdded']) - except BaseException, msg: + except BaseException as msg: tempData = {} tempData['page'] = 1 return self.getFurtherAccounts(userID, tempData) @@ -313,7 +313,7 @@ class WebsiteManager: 'pagination': pagination} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -328,7 +328,7 @@ class WebsiteManager: 'pagination': pagination} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -358,7 +358,7 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'websiteDeleteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -383,7 +383,7 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'websiteDeleteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -423,7 +423,7 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'websiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) @@ -491,7 +491,7 @@ class WebsiteManager: final_json = json.dumps(data_ret) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: dic = {'status': 0, 'modifyStatus': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -543,7 +543,7 @@ class WebsiteManager: final_json = json.dumps(data_ret) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -591,7 +591,7 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -633,7 +633,7 @@ class WebsiteManager: output = ProcessUtilities.outputExecutioner(execPath) bwData = output.split(",") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) bwData = [0, 0] @@ -710,7 +710,7 @@ class WebsiteManager: output = ProcessUtilities.outputExecutioner(execPath) bwData = output.split(",") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) bwData = [0, 0] @@ -1121,7 +1121,7 @@ class WebsiteManager: data_ret = {'getWebsiteCron': 1, "user": website.externalApp, "crons": crons} final_json = json.dumps(data_ret) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) dic = {'getWebsiteCron': 0, 'error_message': str(msg)} json_data = json.dumps(dic) @@ -1185,8 +1185,8 @@ class WebsiteManager: "line": line} final_json = json.dumps(data_ret) return HttpResponse(final_json) - except BaseException, msg: - print msg + except BaseException as msg: + print(msg) dic = {'getWebsiteCron': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -1236,7 +1236,7 @@ class WebsiteManager: json_data = json.dumps(dic) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: dic = {'getWebsiteCron': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -1278,7 +1278,7 @@ class WebsiteManager: return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: dic = {'remCronbyLine': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -1334,7 +1334,7 @@ class WebsiteManager: return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: dic = {'addNewCron': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -1386,7 +1386,7 @@ class WebsiteManager: - except BaseException, msg: + except BaseException as msg: data_ret = {'createAliasStatus': 0, 'error_message': str(msg), "existsStatus": 0} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1423,7 +1423,7 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'sslStatus': 0, 'error_message': str(msg), "existsStatus": 0} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1458,7 +1458,7 @@ class WebsiteManager: return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'deleteAlias': 0, 'error_message': str(msg), "existsStatus": 0} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1484,7 +1484,7 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'changeOpenBasedir': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1501,7 +1501,7 @@ class WebsiteManager: return render(request, 'websiteFunctions/installWordPress.html', {'domainName': self.domain}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def installWordpress(self, userID=None, data=None): @@ -1543,7 +1543,7 @@ class WebsiteManager: return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1580,7 +1580,7 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'abort': 1, 'installStatus': 0, 'installationProgress': "0", 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1596,7 +1596,7 @@ class WebsiteManager: return ACLManager.loadError() return render(request, 'websiteFunctions/installJoomla.html', {'domainName': self.domain}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def installJoomla(self, userID=None, data=None): @@ -1627,7 +1627,7 @@ class WebsiteManager: statusFile = open(tempStatusPath, 'w') statusFile.writelines('Setting up paths,0') statusFile.close() - os.chmod(tempStatusPath, 0777) + os.chmod(tempStatusPath, 0o777) finalPath = "" @@ -1738,7 +1738,7 @@ class WebsiteManager: ## Installation ends - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1794,7 +1794,7 @@ IdentityFile /home/%s/.ssh/%s return render(request, 'websiteFunctions/setupGit.html', {'domainName': self.domain, 'deploymentKey': deploymentKey, 'installed': 0}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def setupGitRepo(self, userID=None, data=None): @@ -1831,7 +1831,7 @@ IdentityFile /home/%s/.ssh/%s return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'installStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1849,7 +1849,7 @@ IdentityFile /home/%s/.ssh/%s json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'pulled': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1882,7 +1882,7 @@ IdentityFile /home/%s/.ssh/%s return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1916,7 +1916,7 @@ IdentityFile /home/%s/.ssh/%s return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1932,7 +1932,7 @@ IdentityFile /home/%s/.ssh/%s return ACLManager.loadError() return render(request, 'websiteFunctions/installPrestaShop.html', {'domainName': self.domain}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def prestaShopInstall(self, userID=None, data=None): @@ -1977,7 +1977,7 @@ IdentityFile /home/%s/.ssh/%s ## Installation ends - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -2022,7 +2022,7 @@ IdentityFile /home/%s/.ssh/%s return self.submitWebsiteCreation(admin.pk, data) - except BaseException, msg: + except BaseException as msg: data_ret = {'createWebSiteStatus': 0, 'error_message': str(msg), "existsStatus": 0} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -2039,7 +2039,7 @@ IdentityFile /home/%s/.ssh/%s f = open(ipFile) ipData = f.read() ipAddress = ipData.split('\n', 1)[0] - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile("Failed to read machine IP, error:" + str(msg)) ipAddress = "192.168.100.1" @@ -2074,7 +2074,7 @@ IdentityFile /home/%s/.ssh/%s f = open(ipFile) ipData = f.read() ipAddress = ipData.split('\n', 1)[0] - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile("Failed to read machine IP, error:" + str(msg)) ipAddress = "192.168.100.1" @@ -2178,7 +2178,7 @@ IdentityFile /home/%s/.ssh/%s json_data = json.dumps(data) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -2294,7 +2294,7 @@ IdentityFile /home/%s/.ssh/%s return render(request, 'websiteFunctions/sshAccess.html', {'domainName': self.domain, 'externalApp': externalApp}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def saveSSHAccessChanges(self, userID=None, data=None): @@ -2319,7 +2319,7 @@ IdentityFile /home/%s/.ssh/%s json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) diff --git a/pluginHolder/admin.py b/pluginHolder/admin.py index 13be29d96..4c33e0ec3 100755 --- a/pluginHolder/admin.py +++ b/pluginHolder/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/pluginHolder/apps.py b/pluginHolder/apps.py index 0d4db0b89..bafa6ab19 100755 --- a/pluginHolder/apps.py +++ b/pluginHolder/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/pluginHolder/models.py b/pluginHolder/models.py index 1dfab7604..4e6a8e76d 100755 --- a/pluginHolder/models.py +++ b/pluginHolder/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/pluginHolder/tests.py b/pluginHolder/tests.py index 5982e6bcd..f067dcaac 100755 --- a/pluginHolder/tests.py +++ b/pluginHolder/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/pluginHolder/urls.py b/pluginHolder/urls.py index 0a33bc3c9..b975e079d 100755 --- a/pluginHolder/urls.py +++ b/pluginHolder/urls.py @@ -1,6 +1,6 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ diff --git a/pluginHolder/views.py b/pluginHolder/views.py index 859d48216..44e564fc3 100755 --- a/pluginHolder/views.py +++ b/pluginHolder/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render from plogical.mailUtilities import mailUtilities diff --git a/pluginInstaller/pluginInstaller.py b/pluginInstaller/pluginInstaller.py index e79437ac5..5913eb3d1 100755 --- a/pluginInstaller/pluginInstaller.py +++ b/pluginInstaller/pluginInstaller.py @@ -16,11 +16,11 @@ class pluginInstaller: @staticmethod def stdOut(message): print("\n\n") - print ("[" + time.strftime( - "%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n") - print("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] " + message + "\n") - print ("[" + time.strftime( - "%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n") + print(("[" + time.strftime( + "%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n")) + print(("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] " + message + "\n")) + print(("[" + time.strftime( + "%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n")) ### Functions Related to plugin installation. @@ -93,7 +93,7 @@ class pluginInstaller: os.chdir('/usr/local/CyberCP') - command = "/usr/local/CyberCP/bin/python2 manage.py collectstatic --noinput" + command = "/usr/local/CyberCP/bin/python manage.py collectstatic --noinput" subprocess.call(shlex.split(command)) command = "mv /usr/local/CyberCP/static /usr/local/lscp/cyberpanel" @@ -186,7 +186,7 @@ class pluginInstaller: pluginInstaller.stdOut('Plugin successfully installed.') - except BaseException, msg: + except BaseException as msg: pluginInstaller.stdOut(str(msg)) ### Functions Related to plugin installation. @@ -280,7 +280,7 @@ class pluginInstaller: pluginInstaller.stdOut('Plugin successfully removed.') - except BaseException, msg: + except BaseException as msg: pluginInstaller.stdOut(str(msg)) #### diff --git a/postfixSenderPolicy/accept_traffic.py b/postfixSenderPolicy/accept_traffic.py index 54aec3c94..9c20572d2 100755 --- a/postfixSenderPolicy/accept_traffic.py +++ b/postfixSenderPolicy/accept_traffic.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os,sys sys.path.append('/usr/local/CyberCP') import django @@ -6,11 +6,11 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") django.setup() import threading as multi from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging -from policyConstraint import policyConstraints +from .policyConstraint import policyConstraints from emailPremium.models import DomainLimits, EmailLogs from mailServer.models import Domains, EUsers import time -from cacheManager import cacheManager +from .cacheManager import cacheManager limitThreads = multi.BoundedSemaphore(10) @@ -23,7 +23,7 @@ class HandleRequest(multi.Thread): def __del__(self): try: self.connection.close() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [HandleRequest.__del__]') def run(self): @@ -62,7 +62,7 @@ class HandleRequest(multi.Thread): self.connection.close() break - except BaseException, msg: + except BaseException as msg: logging.writeToFile( str(msg) + ' [HandleRequest.run]') finally: limitThreads.release() @@ -136,6 +136,6 @@ class HandleRequest(multi.Thread): self.connection.sendall('action=dunno\n\n') - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + " [HandleRequest.manageRequest]") self.connection.sendall('action=defer_if_permit Service temporarily unavailable\n\n') diff --git a/postfixSenderPolicy/cacheManager.py b/postfixSenderPolicy/cacheManager.py index 0bf33aa11..4ba188ec9 100755 --- a/postfixSenderPolicy/cacheManager.py +++ b/postfixSenderPolicy/cacheManager.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os,sys sys.path.append('/usr/local/CyberCP') import django @@ -15,14 +15,14 @@ class cacheManager: def flushCache(): try: - for domain, domainOBJ in cacheManager.domains.iteritems(): + for domain, domainOBJ in cacheManager.domains.items(): domaindb = Domains.objects.get(domain=domain) dbDomain = DomainLimits.objects.get(domain=domaindb) dbDomain.monthlyUsed = domainOBJ.monthlyUsed dbDomain.save() - for email, emailOBJ in domainOBJ.emails.iteritems(): + for email, emailOBJ in domainOBJ.emails.items(): emailID = EUsers.objects.get(email=email) dbEmail = EmailLimits.objects.get(email=emailID) @@ -30,7 +30,7 @@ class cacheManager: dbEmail.hourlyUsed = emailOBJ.hourlyUsed dbEmail.save() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.flushCache]') @staticmethod @@ -44,7 +44,7 @@ class cacheManager: emailOBJ = domainOBJ.emails[emailAddress] emailOBJ.logStatus = operationValue - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.disableEnableLogs]') @staticmethod @@ -59,7 +59,7 @@ class cacheManager: emailOBJ = domainOBJ.emails[email] emailOBJ.logStatus = operationVal - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.purgeLog]') @staticmethod @@ -74,7 +74,7 @@ class cacheManager: emailOBJ = domainOBJ.emails[email] emailOBJ.limitStatus = operationVal - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.purgeLimit]') @staticmethod @@ -87,7 +87,7 @@ class cacheManager: domainOBJ = cacheManager.domains[domain] domainOBJ.limitStatus = operationVal - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.purgeLimitDomain]') @staticmethod @@ -100,7 +100,7 @@ class cacheManager: domainOBJ = cacheManager.domains[domain] domainOBJ.monthlyLimits = newLimit - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.updateDomainLimit]') @staticmethod @@ -117,14 +117,14 @@ class cacheManager: emailOBJ.monthlyLimits = monthlyLimit emailOBJ.hourlyLimits = hourlyLimit - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.purgeLimitEmail]') @staticmethod def hourlyCleanUP(): try: - for domain, domainOBJ in cacheManager.domains.iteritems(): - for email, emailOBJ in domainOBJ.emails.iteritems(): + for domain, domainOBJ in cacheManager.domains.items(): + for email, emailOBJ in domainOBJ.emails.items(): emailID = EUsers.objects.get(email=email) dbEmail = EmailLimits.objects.get(email=emailID) @@ -135,19 +135,19 @@ class cacheManager: dbEmail.hourlyUsed = 0 emailOBJ.hourlyUsed = 0 - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.hourlyCleanUP]') @staticmethod def monthlyCleanUP(): try: - for domain, domainOBJ in cacheManager.domains.iteritems(): + for domain, domainOBJ in cacheManager.domains.items(): domaindb = Domains.objects.get(domain=domain) dbDomain = DomainLimits.objects.get(domain=domaindb) - for email, emailOBJ in domainOBJ.emails.iteritems(): + for email, emailOBJ in domainOBJ.emails.items(): emailID = EUsers.objects.get(email=email) dbEmail = EmailLimits.objects.get(email=emailID) @@ -160,7 +160,7 @@ class cacheManager: dbDomain.monthlyUsed = 0 dbDomain.save() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.monthlyCleanUP]') @@ -191,6 +191,6 @@ class cacheManager: cacheManager.monthlyCleanUP() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheManager.handlePurgeRequest]') diff --git a/postfixSenderPolicy/client.py b/postfixSenderPolicy/client.py index 40599be6f..7e1bcadad 100755 --- a/postfixSenderPolicy/client.py +++ b/postfixSenderPolicy/client.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import socket import sys sys.path.append('/usr/local/CyberCP') @@ -17,7 +17,7 @@ class cacheClient: writeToFile.write(command) writeToFile.close() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [cacheClient.handleCachePurgeRequest]') diff --git a/postfixSenderPolicy/policyCTRL.py b/postfixSenderPolicy/policyCTRL.py index a7a29a6b4..5a4554f95 100755 --- a/postfixSenderPolicy/policyCTRL.py +++ b/postfixSenderPolicy/policyCTRL.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import subprocess, signal import shlex import argparse @@ -34,7 +34,7 @@ class policyCTRL: pid = open(path, "r").readlines()[0] try: os.kill(int(pid), signal.SIGTERM) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) diff --git a/postfixSenderPolicy/startServer.py b/postfixSenderPolicy/startServer.py index ab68fb6ca..3ebc612b9 100755 --- a/postfixSenderPolicy/startServer.py +++ b/postfixSenderPolicy/startServer.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os,sys sys.path.append('/usr/local/CyberCP') import django @@ -6,10 +6,10 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") django.setup() import socket import os -import accept_traffic as handle +from . import accept_traffic as handle from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging from signal import * -from cacheManager import cacheManager +from .cacheManager import cacheManager import pwd import grp @@ -39,10 +39,10 @@ class SetupConn: uid = pwd.getpwnam("postfix").pw_uid gid = grp.getgrnam("postfix").gr_gid os.chown(self.server_addr, uid, gid) - os.chmod(self.server_addr, 0755) + os.chmod(self.server_addr, 0o755) logging.writeToFile('CyberPanel Email Policy Server Successfully started!') - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [SetupConn.setup_conn]') def start_listening(self): @@ -63,7 +63,7 @@ class SetupConn: connection, client_address = self.sock.accept() background = handle.HandleRequest(connection) background.start() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [SetupConn.start_listening]') def __del__(self): diff --git a/preUpgrade.sh b/preUpgrade.sh index 8125347df..a29413a9e 100644 --- a/preUpgrade.sh +++ b/preUpgrade.sh @@ -1,11 +1,102 @@ -if [ ! -d "/usr/local/CyberPanel" ]; then - virtualenv --system-site-packages /usr/local/CyberPanel - source /usr/local/CyberPanel/bin/activate - rm -rf requirments.txt - wget https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/requirments.txt - pip install --ignore-installed -r requirments.txt - virtualenv --system-site-packages /usr/local/CyberPanel +SERVER_OS='Undefined' +OUTPUT=$(cat /etc/*release) + +echo -e "\nChecking OS..." +OUTPUT=$(cat /etc/*release) +if echo $OUTPUT | grep -q "CentOS Linux 7" ; then + echo -e "\nDetecting CentOS 7.X...\n" + SERVER_OS="CentOS7" + yum clean all + yum update -y +elif echo $OUTPUT | grep -q "CloudLinux 7" ; then + echo -e "\nDetecting CloudLinux 7.X...\n" + SERVER_OS="CentOS7" + yum clean all + yum update -y +elif echo $OUTPUT | grep -q "CentOS Linux 8" ; then + echo -e "\nDetecting CentOS 8.X...\n" + SERVER_OS="CentOS8" + yum clean all + yum update -y +elif echo $OUTPUT | grep -q "Ubuntu 18.04" ; then + echo -e "\nDetecting Ubuntu 18.04...\n" + SERVER_OS="Ubuntu" +else + cat /etc/*release + echo -e "\nUnable to detect your OS...\n" + echo -e "\nCyberPanel is supported on Ubuntu 18.04, CentOS 7.x, CentOS 8.x and CloudLinux 7.x...\n" + exit 1 fi + +if [[ $SERVER_OS == "CentOS7" ]] ; then + yum -y install yum-utils + yum -y groupinstall development + yum -y install https://centos7.iuscommunity.org/ius-release.rpm + yum -y install python36u python36u-pip python36u-devel +elif [[ $SERVER_OS == "CentOS8" ]] ; then + yum install -y wget strace htop net-tools telnet curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel mariadb-devel curl-devel git platform-python-devel tar + dnf --enablerepo=PowerTools install gpgme-devel -y + dnf install python3 -y +else + apt update -y + DEBIAN_FRONTEND=noninteractive apt upgrade -y + DEBIAN_FRONTEND=noninteracitve apt install -y htop telnet python-mysqldb python-dev libcurl4-gnutls-dev libgnutls28-dev libgcrypt20-dev libattr1 libattr1-dev liblzma-dev libgpgme-dev libmariadbclient-dev libcurl4-gnutls-dev libssl-dev nghttp2 libnghttp2-dev idn2 libidn2-dev libidn2-0-dev librtmp-dev libpsl-dev nettle-dev libgnutls28-dev libldap2-dev libgssapi-krb5-2 libk5crypto3 libkrb5-dev libcomerr2 libldap2-dev python-gpg python python-minimal python-setuptools virtualenv python-dev python-pip git + DEBIAN_FRONTEND=noninteractive apt install -y python3-pip + DEBIAN_FRONTEND=noninteractive apt install -y build-essential libssl-dev libffi-dev python3-dev + DEBIAN_FRONTEND=noninteractive apt install -y python3-venv +fi + +if [[ $SERVER_OS == "Ubuntu" ]] ; then + pip3 install virtualenv +else + pip3.6 install virtualenv +fi + +rm -rf /usr/local/CyberPanel +virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberPanel +source /usr/local/CyberPanel/bin/activate +rm -rf requirments.txt +wget https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/requirments.txt + +if [[ $SERVER_OS == "Ubuntu" ]] ; then + pip3 install --ignore-installed -r requirments.txt +else + pip3.6 install --ignore-installed -r requirments.txt +fi + +virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberPanel rm -rf upgrade.py wget https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/plogical/upgrade.py -/usr/local/CyberPanel/bin/python2 upgrade.py \ No newline at end of file +/usr/local/CyberPanel/bin/python upgrade.py stable + +## + +virtualenv -p /usr/bin/python3 /usr/local/CyberCP +source /usr/local/CyberCP/bin/activate +wget -O requirements.txt https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/requirments.txt +if [[ $SERVER_OS == "Ubuntu" ]] ; then + pip3 install --ignore-installed -r requirments.txt +else + pip3.6 install --ignore-installed -r requirments.txt +fi + + +## + +rm -f wsgi-lsapi-1.4.tgz +rm -rf wsgi-lsapi-1.4 +wget http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.4.tgz +tar xf wsgi-lsapi-1.4.tgz +cd wsgi-lsapi-1.4 +/usr/local/CyberPanel/bin/python ./configure.py +make +cp lswsgi /usr/local/CyberCP/bin/ + +## + +sed -i 's|import views|from . import views|g' /usr/local/CyberCP/configservercsf/urls.py +systemctl restart lscpd + +echo "###################################################################" +echo " CyberPanel Upgraded " +echo "###################################################################" \ No newline at end of file diff --git a/requirments.txt b/requirments.txt index 80894317e..4b1b8bc45 100755 --- a/requirments.txt +++ b/requirments.txt @@ -1,28 +1,27 @@ acme==0.21.1 +asgiref==3.2.3 asn1crypto==0.24.0 Babel==0.9.6 -bcrypt==3.1.7 backports.ssl-match-hostname==3.5.0.1 +bcrypt==3.1.7 boto3==1.9.64 botocore==1.12.64 certbot==0.21.1 certifi==2018.4.16 cffi==1.11.5 chardet==3.0.4 -ConfigArgParse==0.13.0 -configobj==4.7.2 +ConfigArgParse==0.15.2 +configobj==5.0.6 cryptography==2.8 decorator==3.4.0 +Django==3.0.1 docker==3.6.0 docker-pycreds==0.4.0 -Django==1.11 docutils==0.14 enum34==1.1.6 funcsigs==1.0.2 -future==0.16.0 -futures==3.2.0 +future==0.18.2 idna==2.6 -iniparse==0.4 ipaddress==1.0.16 IPy==0.75 Jinja2==2.7.2 @@ -30,36 +29,36 @@ jmespath==0.9.3 josepy==1.1.0 jsonpatch==1.2 jsonpointer==1.9 -kitchen==1.1.1 MarkupSafe==0.11 mock==2.0.0 +mysqlclient==1.4.6 +paramiko==2.6.0 parsedatetime==2.4 pbr==4.0.4 pexpect==4.4.0 prettytable==0.7.2 psutil==5.4.3 ptyprocess==0.6.0 +py3dns==3.2.1 pycparser==2.18 -pycurl==7.19.0 -pydns==2.3.6 pygpgme==0.3 -pyliblzma==0.5.3 +PyNaCl==1.3.0 pyOpenSSL==17.5.0 pyRFC3339==1.1 -pyserial==2.6 -paramiko==2.6.0 -SimpleWebSocketServer==0.1.1 python-dateutil==2.7.5 pytz==2018.4 pyudev==0.15 -pyxattr==0.5.1 +pyxattr==0.7.1 PyYAML==3.10 requests==2.18.4 requests-file==1.4.3 s3transfer==0.1.13 -six==1.9.0 +SimpleWebSocketServer==0.1.1 +six==1.13.0 +sqlparse==0.3.0 tldextract==2.2.0 urllib3==1.22 +websocket-client==0.56.0 zope.component==4.4.1 zope.event==4.3.0 zope.interface==4.5.0 \ No newline at end of file diff --git a/s3Backups/admin.py b/s3Backups/admin.py index 13be29d96..4c33e0ec3 100755 --- a/s3Backups/admin.py +++ b/s3Backups/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/s3Backups/apps.py b/s3Backups/apps.py index 1a31291f0..586d1928a 100755 --- a/s3Backups/apps.py +++ b/s3Backups/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/s3Backups/models.py b/s3Backups/models.py index d57aa8af9..be1e7cdff 100755 --- a/s3Backups/models.py +++ b/s3Backups/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models from loginSystem.models import Administrator diff --git a/s3Backups/s3Backups.py b/s3Backups/s3Backups.py index 6d8aa8f82..dab2cf354 100755 --- a/s3Backups/s3Backups.py +++ b/s3Backups/s3Backups.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python try: import os import os.path @@ -50,7 +50,7 @@ class S3Backups(multi.Thread): self.runAWSBackups() elif self.function == 'forceRunAWSBackupMINIO': self.forceRunAWSBackupMINIO() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [S3Backups.run]') @staticmethod @@ -117,7 +117,7 @@ class S3Backups(multi.Thread): writeToFile.writelines(items + "\n") if cronCheck: - writeToFile.writelines("0 0 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/s3Backups/s3Backups.py > /home/cyberpanel/error-logs.txt 2>&1\n") + writeToFile.writelines("0 0 * * * root /usr/local/CyberCP/bin/python /usr/local/CyberCP/s3Backups/s3Backups.py > /home/cyberpanel/error-logs.txt 2>&1\n") writeToFile.close() @@ -131,7 +131,7 @@ class S3Backups(multi.Thread): os.remove(tempPath) except: pass - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + " [S3Backups.setupCron]") def connectAccount(self): @@ -164,7 +164,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -215,7 +215,7 @@ class S3Backups(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -242,7 +242,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [createPlan]') proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -281,7 +281,7 @@ class S3Backups(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -301,7 +301,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -336,7 +336,7 @@ class S3Backups(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -357,7 +357,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -382,7 +382,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -412,7 +412,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None, data) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajaxPre(0, str(msg)) @@ -516,7 +516,7 @@ class S3Backups(multi.Thread): ] } ) - except BaseException, msg: + except BaseException as msg: BackupLogs(owner=plan, timeStamp=time.strftime("%b %d %Y, %H:%M:%S"), level='ERROR', msg=str(msg)).save() @@ -558,7 +558,7 @@ class S3Backups(multi.Thread): BackupLogs(owner=plan, level='INFO', timeStamp=time.strftime("%b %d %Y, %H:%M:%S"), msg='Backup Process Finished.').save() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [S3Backups.runBackupPlan]') plan = BackupPlan.objects.get(name=self.data['planName']) BackupLogs(owner=plan, timeStamp=time.strftime("%b %d %Y, %H:%M:%S"), level='ERROR', msg=str(msg)).save() @@ -593,7 +593,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -641,7 +641,7 @@ class S3Backups(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg)) proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -672,7 +672,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [createPlanDO]') proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -711,7 +711,7 @@ class S3Backups(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -731,7 +731,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -766,7 +766,7 @@ class S3Backups(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -796,7 +796,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None, data) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajaxPre(0, str(msg)) @@ -817,7 +817,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -843,7 +843,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -898,7 +898,7 @@ class S3Backups(multi.Thread): ] } ) - except BaseException, msg: + except BaseException as msg: BackupLogsDO(owner=plan, timeStamp=time.strftime("%b %d %Y, %H:%M:%S"), level='ERROR', msg=str(msg)).save() @@ -939,7 +939,7 @@ class S3Backups(multi.Thread): BackupLogsDO(owner=plan, level='INFO', timeStamp=time.strftime("%b %d %Y, %H:%M:%S"), msg='Backup Process Finished.').save() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [S3Backups.forceRunAWSBackupDO]') plan = BackupPlanDO.objects.get(name=self.data['planName']) BackupLogsDO(owner=plan, timeStamp=time.strftime("%b %d %Y, %H:%M:%S"), level='ERROR', msg=str(msg)).save() @@ -965,7 +965,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [addMINIONode]') proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -1001,7 +1001,7 @@ class S3Backups(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -1021,7 +1021,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -1051,7 +1051,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [createPlanDO]') proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -1090,7 +1090,7 @@ class S3Backups(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -1110,7 +1110,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -1136,7 +1136,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -1166,7 +1166,7 @@ class S3Backups(multi.Thread): try: client.create_bucket(Bucket=plan.name.lower()) - except BaseException, msg: + except BaseException as msg: BackupLogsMINIO(owner=plan, level='INFO', timeStamp=time.strftime("%b %d %Y, %H:%M:%S"), msg=str(msg)).save() return 0 @@ -1208,7 +1208,7 @@ class S3Backups(multi.Thread): BackupLogsMINIO(owner=plan, level='INFO', timeStamp=time.strftime("%b %d %Y, %H:%M:%S"), msg='Backup Process Finished.').save() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [S3Backups.forceRunAWSBackupMINIO]') plan = BackupPlanMINIO.objects.get(name=self.data['planName']) BackupLogsMINIO(owner=plan, timeStamp=time.strftime("%b %d %Y, %H:%M:%S"), level='ERROR', @@ -1245,7 +1245,7 @@ class S3Backups(multi.Thread): final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -1275,7 +1275,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None, data) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajaxPre(0, str(msg)) @@ -1296,7 +1296,7 @@ class S3Backups(multi.Thread): return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: proc = httpProc(self.request, None, None) return proc.ajax(0, str(msg)) @@ -1374,7 +1374,7 @@ class S3Backups(multi.Thread): self.data['planName'] = plan.name self.forceRunAWSBackupMINIO() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [S3Backups.runAWSBackups]') diff --git a/s3Backups/tests.py b/s3Backups/tests.py index 5982e6bcd..f067dcaac 100755 --- a/s3Backups/tests.py +++ b/s3Backups/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/s3Backups/views.py b/s3Backups/views.py index e784a0bd2..e2a525da4 100755 --- a/s3Backups/views.py +++ b/s3Backups/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render diff --git a/serverLogs/admin.py b/serverLogs/admin.py index 13be29d96..4c33e0ec3 100755 --- a/serverLogs/admin.py +++ b/serverLogs/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/serverLogs/apps.py b/serverLogs/apps.py index 3ff38b65d..80dfd1263 100755 --- a/serverLogs/apps.py +++ b/serverLogs/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/serverLogs/models.py b/serverLogs/models.py index 1dfab7604..4e6a8e76d 100755 --- a/serverLogs/models.py +++ b/serverLogs/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/serverLogs/tests.py b/serverLogs/tests.py index 5982e6bcd..f067dcaac 100755 --- a/serverLogs/tests.py +++ b/serverLogs/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/serverLogs/urls.py b/serverLogs/urls.py index bc7017a36..01a9c2b24 100755 --- a/serverLogs/urls.py +++ b/serverLogs/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^$', views.logsHome, name='logsHome'), diff --git a/serverLogs/views.py b/serverLogs/views.py index 300509a09..70acc2847 100755 --- a/serverLogs/views.py +++ b/serverLogs/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render,redirect from loginSystem.views import loadLoginPage @@ -43,7 +43,7 @@ def accessLogs(request): return render(request,'serverLogs/accessLogs.html') - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]") return redirect(loadLoginPage) @@ -60,7 +60,7 @@ def errorLogs(request): return render(request,'serverLogs/errorLogs.html') - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]") return redirect(loadLoginPage) @@ -76,7 +76,7 @@ def ftplogs(request): return render(request,'serverLogs/ftplogs.html') - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]") return redirect(loadLoginPage) @@ -93,7 +93,7 @@ def emailLogs(request): return render(request,'serverLogs/emailLogs.html') - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]") return redirect(loadLoginPage) @@ -109,7 +109,7 @@ def modSecAuditLogs(request): return render(request,'serverLogs/modSecAuditLog.html') - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]") return redirect(loadLoginPage) @@ -136,7 +136,7 @@ def getLogsFromFile(request): else: fileName = "/var/log/mail.log" elif type == "ftp": - if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos: fileName = "/var/log/messages" else: fileName = "/var/log/syslog" @@ -156,7 +156,7 @@ def getLogsFromFile(request): final_json = json.dumps(status) return HttpResponse(final_json) - except KeyError, msg: + except KeyError as msg: status = {"status": 0, "logstatus":0,"error":"Could not fetch data from log file, please see CyberCP main log file through command line."} logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[getLogsFromFile]") final_json = json.dumps(status) @@ -179,7 +179,7 @@ def clearLogFile(request): fileName = data['fileName'] - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/serverLogs.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/serverLogs.py" execPath = execPath + " cleanLogFile --fileName " + fileName output = ProcessUtilities.outputExecutioner(execPath) @@ -193,12 +193,12 @@ def clearLogFile(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException,msg: + except BaseException as msg: data_ret = {'cleanStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except KeyError,msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) data_ret = {'cleanStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) diff --git a/serverStatus/admin.py b/serverStatus/admin.py index 13be29d96..4c33e0ec3 100755 --- a/serverStatus/admin.py +++ b/serverStatus/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/serverStatus/apps.py b/serverStatus/apps.py index 49b7aa0b7..207a93608 100755 --- a/serverStatus/apps.py +++ b/serverStatus/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/serverStatus/models.py b/serverStatus/models.py index 1dfab7604..4e6a8e76d 100755 --- a/serverStatus/models.py +++ b/serverStatus/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/serverStatus/serverStatusUtil.py b/serverStatus/serverStatusUtil.py index 3014ccc5d..44d19bb54 100755 --- a/serverStatus/serverStatusUtil.py +++ b/serverStatus/serverStatusUtil.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os,sys sys.path.append('/usr/local/CyberCP') import django @@ -29,7 +29,7 @@ class ServerStatusUtil: return 0 else: return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -124,7 +124,7 @@ class ServerStatusUtil: return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -147,7 +147,7 @@ class ServerStatusUtil: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,"Filemanager files are set!\n") return 1 - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -196,7 +196,7 @@ class ServerStatusUtil: cmd = shlex.split(command) subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -233,7 +233,7 @@ class ServerStatusUtil: cmd = shlex.split(command) subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -254,7 +254,7 @@ class ServerStatusUtil: if ServerStatusUtil.createDomain(child) == 0: logging.CyberCPLogFileWriter.writeToFile( 'Error while creating child domain: ' + child.domain) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( 'Error while creating child domain: ' + child.domain + ' . Exact message: ' + str( msg)) @@ -266,14 +266,14 @@ class ServerStatusUtil: aliasDomain = alias.aliasDomain alias.delete() virtualHostUtilities.createAlias(website.domain, aliasDomain, 0, '/home', website.adminEmail, website.admin) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( 'Error while creating alais domain: ' + aliasDomain + ' . Exact message: ' + str( msg)) logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "vhost conf successfully built for: " + website.domain + ".\n", 1) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return 0 @@ -351,7 +351,7 @@ class ServerStatusUtil: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,"Successfully switched to LITESPEED ENTERPRISE WEB SERVER. [200]\n", 1) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "%s. [404]" % (str(msg)), 1) logging.CyberCPLogFileWriter.writeToFile(str(msg)) diff --git a/serverStatus/tests.py b/serverStatus/tests.py index 5982e6bcd..f067dcaac 100755 --- a/serverStatus/tests.py +++ b/serverStatus/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/serverStatus/urls.py b/serverStatus/urls.py index c2c59696b..cdd1224e0 100755 --- a/serverStatus/urls.py +++ b/serverStatus/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^$', views.serverStatusHome, name='serverStatusHome'), diff --git a/serverStatus/views.py b/serverStatus/views.py index 2b3e16e61..dae87051e 100755 --- a/serverStatus/views.py +++ b/serverStatus/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render, redirect from django.http import HttpResponse @@ -13,7 +13,7 @@ from plogical.acl import ACLManager import os from plogical.virtualHostUtilities import virtualHostUtilities import time -import serverStatusUtil +from . import serverStatusUtil from plogical.processUtilities import ProcessUtilities from plogical.httpProc import httpProc from plogical.installUtilities import installUtilities @@ -75,7 +75,7 @@ def litespeedStatus(request): else: loadedModules.append(items) - except BaseException, msg: + except BaseException as 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.", @@ -89,7 +89,7 @@ def litespeedStatus(request): "loadedModules": loadedModules, 'OLS': OLS, 'message': message} return render(request, "serverStatus/litespeedStatus.html", dataForHtml) - except KeyError, msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]") return redirect(loadLoginPage) @@ -123,7 +123,7 @@ def stopOrRestartLitespeed(request): final_json = json.dumps(status) return HttpResponse(final_json) - except KeyError, msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[stopOrRestartLitespeed]") return HttpResponse("Not Logged in as admin") @@ -141,7 +141,7 @@ def cyberCPMainLogFile(request): return render(request, 'serverStatus/cybercpmainlogfile.html') - except KeyError, msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[cyberCPMainLogFile]") return redirect(loadLoginPage) @@ -163,7 +163,7 @@ def getFurtherDataFromLogFile(request): final_json = json.dumps(status) return HttpResponse(final_json) - except KeyError, msg: + except KeyError as msg: status = {"logstatus": 0, "error": "Could not fetch data from log file, please see CyberCP main log file through command line."} logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[getFurtherDataFromLogFile]") @@ -335,11 +335,11 @@ def servicesAction(request): return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'serviceAction': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except KeyError, msg: + except KeyError as msg: final_dic = {'serviceAction': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -373,7 +373,7 @@ def switchTOLSWS(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -402,7 +402,7 @@ def switchTOLSWSStatus(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: command = "sudo rm -f " + serverStatusUtil.ServerStatusUtil.lswsInstallStatusPath ProcessUtilities.popenExecutioner(command) data_ret = {'status': 0,'abort': 1, 'requestStatus': str(msg), 'installed': 0} @@ -431,11 +431,11 @@ def licenseStatus(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'erroMessage': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except KeyError, msg: + except KeyError as msg: final_dic = {'status': 0, 'erroMessage': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -477,11 +477,11 @@ def changeLicense(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'erroMessage': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except KeyError, msg: + except KeyError as msg: final_dic = {'status': 0, 'erroMessage': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -501,7 +501,7 @@ def topProcesses(request): proc = httpProc(request, templateName) return proc.renderPre() - except KeyError, msg: + except KeyError as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]") return redirect(loadLoginPage) @@ -526,19 +526,19 @@ def topProcessesStatus(request): counter = 0 loadAVG = data[0].split(' ') - loadAVG = filter(lambda a: a != '', loadAVG) + loadAVG = [a for a in loadAVG if a != ''] loadNow = data[2].split(' ') - loadNow = filter(lambda a: a != '', loadNow) + loadNow = [a for a in loadNow if a != ''] memory = data[3].split(' ') - memory = filter(lambda a: a != '', memory) + memory = [a for a in memory if a != ''] swap = data[4].split(' ') - swap = filter(lambda a: a != '', swap) + swap = [a for a in swap if a != ''] processes = data[1].split(' ') - processes = filter(lambda a: a != '', processes) + processes = [a for a in processes if a != ''] for items in data: counter = counter + 1 @@ -546,7 +546,7 @@ def topProcessesStatus(request): continue points = items.split(' ') - points = filter(lambda a: a != '', points) + points = [a for a in points if a != ''] dic = {'PID': points[0], 'User': points[1], 'VIRT': points[4], 'RES': points[5], 'S': points[7], 'CPU': points[8], 'MEM': points[9], @@ -623,7 +623,7 @@ def topProcessesStatus(request): final_json = json.dumps(data) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -649,11 +649,11 @@ def killProcess(request): proc = httpProc(request, None) return proc.ajax(1, None) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'erroMessage': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except KeyError, msg: + except KeyError as 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/CLManager/CLManager.js b/static/CLManager/CLManager.js index 547a407d5..ae17f696c 100644 --- a/static/CLManager/CLManager.js +++ b/static/CLManager/CLManager.js @@ -50,7 +50,7 @@ app.controller('installCageFS', function ($scope, $http, $timeout, $window) { }; function getRequestStatus() { - $scope.cyberPanelLoading = false; + $scope.installDockerStatus = false; url = "/serverstatus/switchTOLSWSStatus"; @@ -72,7 +72,7 @@ app.controller('installCageFS', function ($scope, $http, $timeout, $window) { $timeout(getRequestStatus, 1000); } else { // Notifications - $scope.cyberPanelLoading = true; + $scope.installDockerStatus = true; $timeout.cancel(); $scope.requestData = response.data.requestStatus; if (response.data.installed === 1) { @@ -85,7 +85,7 @@ app.controller('installCageFS', function ($scope, $http, $timeout, $window) { } function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; + $scope.installDockerStatus = true; new PNotify({ title: 'Operation Failed!', text: 'Could not connect to server, please refresh this page', diff --git a/test.sh b/test.sh index 8b1378917..e69de29bb 100644 --- a/test.sh +++ b/test.sh @@ -1 +0,0 @@ - diff --git a/tuning/admin.py b/tuning/admin.py index 13be29d96..4c33e0ec3 100755 --- a/tuning/admin.py +++ b/tuning/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/tuning/apps.py b/tuning/apps.py index 01041a7b2..5ecd5d5ed 100755 --- a/tuning/apps.py +++ b/tuning/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/tuning/models.py b/tuning/models.py index 1dfab7604..4e6a8e76d 100755 --- a/tuning/models.py +++ b/tuning/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/tuning/tests.py b/tuning/tests.py index 5982e6bcd..f067dcaac 100755 --- a/tuning/tests.py +++ b/tuning/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase diff --git a/tuning/tuning.py b/tuning/tuning.py index 66776372f..74eedbeed 100755 --- a/tuning/tuning.py +++ b/tuning/tuning.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os.path import sys import django @@ -12,8 +12,6 @@ import plogical.CyberCPLogFileWriter as logging from plogical.tuning import tuning from loginSystem.views import loadLoginPage from plogical.virtualHostUtilities import virtualHostUtilities -import subprocess -import shlex from plogical.acl import ACLManager from plogical.processUtilities import ProcessUtilities @@ -124,7 +122,7 @@ class tuningManager: inMemCache = data['inMemCache'] gzipCompression = data['gzipCompression'] - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/tuning.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/tuning.py" execPath = execPath + " saveTuningDetails --maxConn " + maxConn + " --maxSSLConn " + maxSSLConn + " --connTime " + connTime + " --keepAlive " + keepAlive + " --inMemCache '" + inMemCache + "' --gzipCompression " + gzipCompression output = ProcessUtilities.outputExecutioner(execPath) @@ -137,7 +135,7 @@ class tuningManager: final_json = json.dumps(data_ret) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: data_ret = {'fetch_status': 0, 'error_message': str(msg), 'tuneStatus': 0} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -175,7 +173,7 @@ class tuningManager: procHardLimit = str(data['procHardLimit']) persistConn = data['persistConn'] - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/tuning.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/tuning.py" execPath = execPath + " tunePHP --virtualHost " + domainSelection + " --initTimeout " + initTimeout + " --maxConns " + maxConns + " --memSoftLimit " + memSoftLimit + " --memHardLimit '" + memHardLimit + "' --procSoftLimit " + procSoftLimit + " --procHardLimit " + procHardLimit + " --persistConn " + persistConn output = ProcessUtilities.outputExecutioner(execPath) @@ -190,7 +188,7 @@ class tuningManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'fetch_status': 0, 'error_message': str(msg), 'tuneStatus': 0} logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [tunePHP]]") json_data = json.dumps(data_ret) diff --git a/tuning/urls.py b/tuning/urls.py index b0363f122..8eccf9958 100755 --- a/tuning/urls.py +++ b/tuning/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url,include -import views +from . import views urlpatterns = [ url(r'^$', views.loadTuningHome, name='loadTuningHome'), diff --git a/tuning/views.py b/tuning/views.py index 215047ba3..0e86d44ff 100755 --- a/tuning/views.py +++ b/tuning/views.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import redirect import json from loginSystem.views import loadLoginPage -from tuning import tuningManager +from .tuning import tuningManager # Create your views here. diff --git a/upgrade.sh b/upgrade.sh index 643a625ad..2424f55b8 100755 --- a/upgrade.sh +++ b/upgrade.sh @@ -6,7 +6,7 @@ ## Then run it like below. ## /usr/local/CyberCP/upgrade.sh -cd /usr/local/CyberCP && /usr/local/CyberCP/bin/python2 manage.py collectstatic --no-input +cd /usr/local/CyberCP && /usr/local/CyberCP/bin/python manage.py collectstatic --no-input rm -rf /usr/local/CyberCP/public/static/* cp -R /usr/local/CyberCP/static/* /usr/local/CyberCP/public/static/ mkdir /usr/local/CyberCP/public/static/csf/ diff --git a/userManagment/admin.py b/userManagment/admin.py index 13be29d96..4c33e0ec3 100755 --- a/userManagment/admin.py +++ b/userManagment/admin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin diff --git a/userManagment/apps.py b/userManagment/apps.py index a4cc35103..b023ad107 100755 --- a/userManagment/apps.py +++ b/userManagment/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/userManagment/models.py b/userManagment/models.py index 1dfab7604..4e6a8e76d 100755 --- a/userManagment/models.py +++ b/userManagment/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models diff --git a/userManagment/tests.py b/userManagment/tests.py index 1092e7897..8b214fad1 100755 --- a/userManagment/tests.py +++ b/userManagment/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.test import TestCase, Client from django.urls import reverse diff --git a/userManagment/urls.py b/userManagment/urls.py index 77743648e..ff506accf 100755 --- a/userManagment/urls.py +++ b/userManagment/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ diff --git a/userManagment/views.py b/userManagment/views.py index 86b20a05d..a43049599 100755 --- a/userManagment/views.py +++ b/userManagment/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render, redirect from django.http import HttpResponse @@ -25,7 +25,7 @@ def loadUserHome(request): else: listUsers = currentACL['listUsers'] return render(request, 'userManagment/index.html', {"type": admin.type, 'listUsers': listUsers}) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse(str(msg)) @@ -70,7 +70,7 @@ def createUser(request): else: return ACLManager.loadError() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return redirect(loadLoginPage) @@ -87,7 +87,7 @@ def apiAccess(request): else: return ACLManager.loadError() - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return redirect(loadLoginPage) @@ -118,7 +118,7 @@ def saveChangesAPIAccess(request): finalResponse = {'status': 1} json_data = json.dumps(finalResponse) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)} json_data = json.dumps(finalResponse) return HttpResponse(json_data) @@ -222,7 +222,7 @@ def submitUserCreation(request): final_json = json.dumps(data_ret) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'createStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -292,7 +292,7 @@ def fetchUserDetails(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'fetchStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -352,7 +352,7 @@ def saveModifications(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -414,7 +414,7 @@ def submitUserDeletion(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'deleteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -525,7 +525,7 @@ def createACLFunc(request): json_data = json.dumps(finalResponse) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)} json_data = json.dumps(finalResponse) return HttpResponse(json_data) @@ -566,7 +566,7 @@ def deleteACLFunc(request): json_data = json.dumps(finalResponse) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)} json_data = json.dumps(finalResponse) return HttpResponse(json_data) @@ -672,7 +672,7 @@ def fetchACLDetails(request): json_data = json.dumps(finalResponse) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: finalResponse = {'status': 0, 'errorMessage': str(msg)} json_data = json.dumps(finalResponse) return HttpResponse(json_data) @@ -778,7 +778,7 @@ def submitACLModifications(request): json_data = json.dumps(finalResponse) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)} json_data = json.dumps(finalResponse) return HttpResponse(json_data) @@ -841,7 +841,7 @@ def changeACLFunc(request): json_data = json.dumps(finalResponse) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)} json_data = json.dumps(finalResponse) return HttpResponse(json_data) @@ -914,7 +914,7 @@ def saveResellerChanges(request): finalResponse = {'status': 1} json_data = json.dumps(finalResponse) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: finalResponse = {'status': 0, 'errorMessage': str(msg), 'error_message': str(msg)} json_data = json.dumps(finalResponse) return HttpResponse(json_data) diff --git a/version.txt b/version.txt index 1c0bded6a..01800db5a 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -{"version":"1.9","build":2} \ No newline at end of file +{"version":"1.9","build":3} \ No newline at end of file diff --git a/websiteFunctions/StagingSetup.py b/websiteFunctions/StagingSetup.py index 7693e2fe0..c4b31aa3b 100644 --- a/websiteFunctions/StagingSetup.py +++ b/websiteFunctions/StagingSetup.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import threading as multi from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging from plogical.virtualHostUtilities import virtualHostUtilities @@ -23,7 +23,7 @@ class StagingSetup(multi.Thread): self.startCloning() elif self.function == 'startSyncing': self.startSyncing() - except BaseException, msg: + except BaseException as msg: logging.writeToFile(str(msg) + ' [StagingSetup.run]') def startCloning(self): @@ -42,7 +42,7 @@ class StagingSetup(multi.Thread): logging.statusWriter(tempStatusPath, 'Creating domain for staging environment..,5') phpSelection = 'PHP 7.1' - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " createDomain --masterDomain " + masterDomain + " --virtualHostName " + domain + \ " --phpVersion '" + phpSelection + "' --ssl 0 --dkimCheck 0 --openBasedir 0 --path " + path + ' --websiteOwner ' \ @@ -160,7 +160,7 @@ class StagingSetup(multi.Thread): logging.statusWriter(tempStatusPath, 'Data copied..,[200]') return 0 - except BaseException, msg: + except BaseException as msg: mesg = '%s. [404]' % (str(msg)) logging.statusWriter(self.tempStatusPath, mesg) @@ -239,6 +239,6 @@ class StagingSetup(multi.Thread): logging.statusWriter(tempStatusPath, 'Data copied..,[200]') return 0 - except BaseException, msg: + except BaseException as msg: mesg = '%s. [404]' % (str(msg)) logging.statusWriter(tempStatusPath, mesg) diff --git a/websiteFunctions/admin.py b/websiteFunctions/admin.py index 81305320b..02a92fbcc 100755 --- a/websiteFunctions/admin.py +++ b/websiteFunctions/admin.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.contrib import admin -import models +from . import models # Register your models here. admin.site.register(models.Websites) \ No newline at end of file diff --git a/websiteFunctions/apps.py b/websiteFunctions/apps.py index 38f6437c5..8fc081888 100755 --- a/websiteFunctions/apps.py +++ b/websiteFunctions/apps.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.apps import AppConfig diff --git a/websiteFunctions/models.py b/websiteFunctions/models.py index 5d3476e0a..5858d842a 100755 --- a/websiteFunctions/models.py +++ b/websiteFunctions/models.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models from packages.models import Package @@ -39,7 +39,7 @@ class dest(models.Model): class backupSchedules(models.Model): - dest = models.ForeignKey(dest) + dest = models.ForeignKey(dest, on_delete=models.CASCADE) frequency = models.CharField(max_length=15) diff --git a/websiteFunctions/pluginManager.py b/websiteFunctions/pluginManager.py index 1659ac516..55009cfd6 100755 --- a/websiteFunctions/pluginManager.py +++ b/websiteFunctions/pluginManager.py @@ -1,4 +1,4 @@ -from signals import * +from .signals import * from plogical.pluginManagerGlobal import pluginManagerGlobal class pluginManager: diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js index 493c88488..ee016d01d 100755 --- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js +++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js @@ -376,6 +376,324 @@ app.controller('listWebsites', function ($scope, $http) { }; +}); + +app.controller('listChildDomainsMain', function ($scope, $http, $timeout) { + + + $scope.currentPage = 1; + $scope.recordsToShow = 10; + + $scope.getFurtherWebsitesFromDB = function () { + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + page: $scope.currentPage, + recordsToShow: $scope.recordsToShow + }; + + + dataurl = "/websites/fetchChildDomainsMain"; + + $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); + + + function ListInitialData(response) { + if (response.data.listWebSiteStatus === 1) { + + $scope.WebSitesList = JSON.parse(response.data.data); + $scope.pagination = response.data.pagination; + $scope.clients = JSON.parse(response.data.data); + $("#listFail").hide(); + } else { + $("#listFail").fadeIn(); + $scope.errorMessage = response.data.error_message; + + } + } + + function cantLoadInitialData(response) { + } + + + }; + $scope.getFurtherWebsitesFromDB(); + + $scope.cyberPanelLoading = true; + + $scope.issueSSL = function (virtualHost) { + $scope.cyberPanelLoading = false; + + var url = "/manageSSL/issueSSL"; + + + var data = { + virtualHost: virtualHost + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + if (response.data.SSL === 1) { + new PNotify({ + title: 'Success!', + text: 'SSL successfully issued.', + type: 'success' + }); + } 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' + }); + } + + + }; + + $scope.cyberPanelLoading = true; + + $scope.searchWebsites = function () { + + $scope.cyberPanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + patternAdded: $scope.patternAdded + }; + + dataurl = "/websites/searchWebsites"; + + $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); + + + function ListInitialData(response) { + $scope.cyberPanelLoading = true; + if (response.data.listWebSiteStatus === 1) { + + var finalData = JSON.parse(response.data.data); + $scope.WebSitesList = finalData; + $("#listFail").hide(); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + + } + } + + function cantLoadInitialData(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Connect disrupted, refresh the page.', + type: 'error' + }); + } + + + }; + + $scope.initConvert = function(virtualHost){ + $scope.domainName = virtualHost; + }; + + var statusFile; + + $scope.installationProgress = true; + + $scope.convert = function () { + + $scope.cyberPanelLoading = false; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.goBackDisable = true; + + $scope.currentStatus = "Starting creation.."; + + var ssl, dkimCheck, openBasedir; + + if ($scope.sslCheck === true) { + ssl = 1; + } else { + ssl = 0 + } + + if ($scope.dkimCheck === true) { + dkimCheck = 1; + } else { + dkimCheck = 0 + } + + if ($scope.openBasedir === true) { + openBasedir = 1; + } else { + openBasedir = 0 + } + + url = "/websites/convertDomainToSite"; + + + var data = { + package: $scope.packageForWebsite, + domainName: $scope.domainName, + adminEmail: $scope.adminEmail, + phpSelection: $scope.phpSelection, + websiteOwner: $scope.websiteOwner, + ssl: ssl, + dkimCheck: dkimCheck, + openBasedir: openBasedir + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.createWebSiteStatus === 1) { + statusFile = response.data.tempStatusPath; + getCreationStatus(); + } else { + + $scope.cyberPanelLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.goBackDisable = false; + + $scope.currentStatus = response.data.error_message; + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.cyberPanelLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.goBackDisable = false; + + } + + + }; + $scope.goBack = function () { + $scope.cyberPanelLoading = true; + $scope.installationDetailsForm = false; + $scope.installationProgress = true; + $scope.goBackDisable = true; + $("#installProgress").css("width", "0%"); + }; + + function getCreationStatus() { + + url = "/websites/installWordpressStatus"; + + var data = { + statusFile: statusFile + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.abort === 1) { + + if (response.data.installStatus === 1) { + + $scope.cyberPanelLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.goBackDisable = false; + + $("#installProgress").css("width", "100%"); + $scope.installPercentage = "100"; + $scope.currentStatus = response.data.currentStatus; + $timeout.cancel(); + + } else { + + $scope.cyberPanelLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.goBackDisable = false; + + $scope.currentStatus = response.data.error_message; + + $("#installProgress").css("width", "0%"); + $scope.installPercentage = "0"; + $scope.goBackDisable = false; + + } + + } else { + $("#installProgress").css("width", response.data.installationProgress + "%"); + $scope.installPercentage = response.data.installationProgress; + $scope.currentStatus = response.data.currentStatus; + $timeout(getCreationStatus, 1000); + } + + } + + function cantLoadInitialDatas(response) { + + $scope.cyberPanelLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.goBackDisable = false; + + } + + + } + + }); /* Java script code to list accounts ends here */ diff --git a/websiteFunctions/templates/websiteFunctions/listChildDomains.html b/websiteFunctions/templates/websiteFunctions/listChildDomains.html new file mode 100755 index 000000000..668a9e0e6 --- /dev/null +++ b/websiteFunctions/templates/websiteFunctions/listChildDomains.html @@ -0,0 +1,257 @@ +{% extends "baseTemplate/index.html" %} +{% load i18n %} +{% block title %}{% trans "Child Domains - CyberPanel" %}{% endblock %} +{% block content %} + + {% load static %} + {% get_current_language as LANGUAGE_CODE %} + + + + +
    + +
    +

    {% trans "List Child Domains" %}

    +

    {% trans "On this page you can launch, list, modify and delete child domains from your server." %}

    +
    + +
    + +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +
    + +
    +
    + + +
    +
    + + +
    +
    + + Issue SSL +
    +
    +
    + +
    + + +
    +
    + + +
    + +
    + + Convert to Website + +
    + +
    + +
    + +
    +

    {% trans "Cannot list websites. Error message:" %} {$ errorMessage $}

    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +{% endblock %} diff --git a/websiteFunctions/tests.py b/websiteFunctions/tests.py index cf67fd790..75307d0b4 100755 --- a/websiteFunctions/tests.py +++ b/websiteFunctions/tests.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.test import TestCase import json from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging diff --git a/websiteFunctions/urls.py b/websiteFunctions/urls.py index 5441dddf2..fd0979829 100755 --- a/websiteFunctions/urls.py +++ b/websiteFunctions/urls.py @@ -1,11 +1,12 @@ from django.conf.urls import url -import views +from . import views urlpatterns = [ url(r'^$', views.loadWebsitesHome, name='loadWebsitesHome'), url(r'^createWebsite$', views.createWebsite, name='createWebsite'), url(r'^listWebsites$', views.listWebsites, name='listWebsites'), + url(r'^listChildDomains$', views.listChildDomains, name='listChildDomains'), url(r'^modifyWebsite$', views.modifyWebsite, name='modifyWebsite'), url(r'^deleteWebsite$', views.deleteWebsite, name='deleteWebsite'), url(r'^siteState$', views.siteState, name='siteState'), @@ -18,6 +19,8 @@ urlpatterns = [ url(r'^submitWebsiteDeletion$', views.submitWebsiteDeletion, name='submitWebsiteDeletion'), url(r'^submitWebsiteListing$', views.getFurtherAccounts, name='submitWebsiteListing'), url(r'^fetchWebsitesList$', views.fetchWebsitesList, name='fetchWebsitesList'), + url(r'^fetchChildDomainsMain$', views.fetchChildDomainsMain, name='fetchChildDomainsMain'), + url(r'^convertDomainToSite$', views.convertDomainToSite, name='convertDomainToSite'), url(r'^searchWebsites$', views.searchWebsites, name='searchWebsites'), url(r'^submitWebsiteModification$', views.deleteWebsite, name='submitWebsiteModification'), url(r'^submitWebsiteStatus$', views.submitWebsiteStatus, name='submitWebsiteStatus'), diff --git a/websiteFunctions/views.py b/websiteFunctions/views.py index 0528ee6a7..02aeb7b0e 100755 --- a/websiteFunctions/views.py +++ b/websiteFunctions/views.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.shortcuts import render,redirect from django.http import HttpResponse @@ -31,7 +31,7 @@ def modifyWebsite(request): userID = request.session['userID'] wm = WebsiteManager() return wm.modifyWebsite(request, userID) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) except KeyError: @@ -61,6 +61,14 @@ def listWebsites(request): except KeyError: return redirect(loadLoginPage) +def listChildDomains(request): + try: + userID = request.session['userID'] + wm = WebsiteManager() + return wm.listChildDomains(request, userID) + except KeyError: + return redirect(loadLoginPage) + def submitWebsiteCreation(request): try: userID = request.session['userID'] @@ -133,6 +141,14 @@ def fetchWebsitesList(request): except KeyError: return redirect(loadLoginPage) +def fetchChildDomainsMain(request): + try: + userID = request.session['userID'] + wm = WebsiteManager() + return wm.fetchChildDomainsMain(userID, json.loads(request.body)) + except KeyError: + return redirect(loadLoginPage) + def submitWebsiteDeletion(request): try: userID = request.session['userID'] @@ -173,6 +189,16 @@ def submitDomainDeletion(request): except KeyError: return redirect(loadLoginPage) +def convertDomainToSite(request): + try: + + userID = request.session['userID'] + wm = WebsiteManager() + return wm.convertDomainToSite(userID, request) + + except KeyError: + return redirect(loadLoginPage) + def submitWebsiteStatus(request): try: diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index 3031c6988..b13f80c60 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -1,4 +1,4 @@ -#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python import os import os.path import sys @@ -38,7 +38,7 @@ from plogical.vhostConfs import vhostConfs from plogical.cronUtil import CronUtil from re import match,I,M from plogical import randomPassword -from StagingSetup import StagingSetup +from .StagingSetup import StagingSetup class WebsiteManager: @@ -63,7 +63,7 @@ class WebsiteManager: Data = {'packageList': packagesName, "owernList": adminNames, 'phps': phps} return render(request, 'websiteFunctions/createWebsite.html', Data) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def modifyWebsite(self, request=None, userID=None, data=None): @@ -78,7 +78,7 @@ class WebsiteManager: phps = PHPManager.findPHPVersions() return render(request, 'websiteFunctions/modifyWebsite.html', {'websiteList': websitesName, 'phps': phps}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def deleteWebsite(self, request=None, userID=None, data=None): @@ -90,7 +90,7 @@ class WebsiteManager: websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'websiteFunctions/deleteWebsite.html', {'websiteList': websitesName}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def siteState(self, request=None, userID=None, data=None): @@ -103,7 +103,7 @@ class WebsiteManager: websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'websiteFunctions/suspendWebsite.html', {'websiteList': websitesName}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def listWebsites(self, request=None, userID=None, data=None): @@ -112,7 +112,21 @@ class WebsiteManager: pagination = self.websitePagination(currentACL, userID) return render(request, 'websiteFunctions/listWebsites.html', {"pagination": pagination}) - except BaseException, msg: + except BaseException as msg: + return HttpResponse(str(msg)) + + def listChildDomains(self, request=None, userID=None, data=None): + try: + currentACL = ACLManager.loadedACL(userID) + pagination = self.websitePagination(currentACL, userID) + adminNames = ACLManager.loadAllUsers(userID) + packagesName = ACLManager.loadPackages(userID, currentACL) + phps = PHPManager.findPHPVersions() + + Data = {'packageList': packagesName, "owernList": adminNames, 'phps': phps} + + return render(request, 'websiteFunctions/listChildDomains.html', Data) + except BaseException as msg: return HttpResponse(str(msg)) def listCron(self, request=None, userID=None, data=None): @@ -120,7 +134,7 @@ class WebsiteManager: currentACL = ACLManager.loadedACL(userID) websitesName = ACLManager.findAllSites(currentACL, userID) return render(request, 'websiteFunctions/listCron.html', {'websiteList': websitesName}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def domainAlias(self, request=None, userID=None, data=None): @@ -144,7 +158,7 @@ class WebsiteManager: 'path': path, 'noAlias': noAlias }) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def submitWebsiteCreation(self, userID=None, data=None): @@ -197,7 +211,7 @@ class WebsiteManager: ## Create Configurations - execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "sudo /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " createVirtualHost --virtualHostName " + domain + \ " --administratorEmail " + adminEmail + " --phpVersion '" + phpSelection + \ "' --virtualHostUser " + externalApp + " --ssl " + str(data['ssl']) + " --dkimCheck " \ @@ -213,7 +227,7 @@ class WebsiteManager: return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -255,7 +269,7 @@ class WebsiteManager: except: apacheBackend = "0" - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " createDomain --masterDomain " + masterDomain + " --virtualHostName " + domain + \ " --phpVersion '" + phpSelection + "' --ssl " + str(data['ssl']) + " --dkimCheck " + str( @@ -271,7 +285,7 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -294,7 +308,7 @@ class WebsiteManager: final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -304,7 +318,7 @@ class WebsiteManager: currentACL = ACLManager.loadedACL(userID) try: json_data = self.searchWebsitesJson(currentACL, userID, data['patternAdded']) - except BaseException, msg: + except BaseException as msg: tempData = {} tempData['page'] = 1 return self.getFurtherAccounts(userID, tempData) @@ -314,7 +328,7 @@ class WebsiteManager: 'pagination': pagination} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -329,7 +343,7 @@ class WebsiteManager: 'pagination': pagination} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -350,7 +364,33 @@ class WebsiteManager: 'pagination': pagination} final_json = json.dumps(final_dic) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: + dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)} + json_data = json.dumps(dic) + return HttpResponse(json_data) + + def fetchChildDomainsMain(self, userID=None, data=None): + try: + currentACL = ACLManager.loadedACL(userID) + pageNumber = int(data['page']) + recordsToShow = int(data['recordsToShow']) + + endPageNumber, finalPageNumber = self.recordsPointer(pageNumber, recordsToShow) + websites = ACLManager.findWebsiteObjects(currentACL, userID) + childDomains = [] + + for web in websites: + for child in web.childdomains_set.all(): + childDomains.append(child) + + pagination = self.getPagination(len(childDomains), recordsToShow) + json_data = self.findChildsListJson(childDomains[finalPageNumber:endPageNumber]) + + final_dic = {'status': 1, 'listWebSiteStatus': 1, 'error_message': "None", "data": json_data, + 'pagination': pagination} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + except BaseException as msg: dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -365,7 +405,7 @@ class WebsiteManager: f = open(ipFile) ipData = f.read() ipAddress = ipData.split('\n', 1)[0] - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile("Failed to read machine IP, error:" + str(msg)) ipAddress = "192.168.100.1" @@ -390,6 +430,35 @@ class WebsiteManager: return json_data + def findChildsListJson(self, childs): + + json_data = "[" + checker = 0 + + try: + ipFile = "/etc/cyberpanel/machineIP" + f = open(ipFile) + ipData = f.read() + ipAddress = ipData.split('\n', 1)[0] + except BaseException as msg: + logging.CyberCPLogFileWriter.writeToFile("Failed to read machine IP, error:" + str(msg)) + ipAddress = "192.168.100.1" + + for items in childs: + + dic = {'domain': items.domain, 'masterDomain': items.master.domain, 'adminEmail': items.master.adminEmail, 'ipAddress': ipAddress, + 'admin': items.master.admin.userName, 'package': items.master.package.packageName, 'path': items.path} + + if checker == 0: + json_data = json_data + json.dumps(dic) + checker = 1 + else: + json_data = json_data + ',' + json.dumps(dic) + + json_data = json_data + ']' + + return json_data + def recordsPointer(self, page, toShow): finalPageNumber = ((page * toShow)) - toShow endPageNumber = finalPageNumber + toShow @@ -431,7 +500,7 @@ class WebsiteManager: ## Deleting master domain - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " deleteVirtualHostConfigurations --virtualHostName " + websiteName ProcessUtilities.popenExecutioner(execPath) @@ -439,7 +508,7 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'websiteDeleteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -456,7 +525,7 @@ class WebsiteManager: else: return ACLManager.loadErrorJson('websiteDeleteStatus', 0) - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " deleteDomain --virtualHostName " + websiteName ProcessUtilities.outputExecutioner(execPath) @@ -464,7 +533,7 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'websiteDeleteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -504,7 +573,7 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'websiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) @@ -572,7 +641,7 @@ class WebsiteManager: final_json = json.dumps(data_ret) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: dic = {'status': 0, 'modifyStatus': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -624,7 +693,7 @@ class WebsiteManager: final_json = json.dumps(data_ret) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: dic = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -650,7 +719,7 @@ class WebsiteManager: confPath = virtualHostUtilities.Server_root + "/conf/vhosts/" + domain completePathToConfigFile = confPath + "/vhost.conf" - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " changePHP --phpVersion '" + phpVersion + "' --path " + completePathToConfigFile ProcessUtilities.popenExecutioner(execPath) @@ -672,7 +741,7 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -708,13 +777,13 @@ class WebsiteManager: ## bw usage calculation try: - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " findDomainBW --virtualHostName " + self.domain + " --bandwidth " + str( website.package.bandwidth) output = ProcessUtilities.outputExecutioner(execPath) bwData = output.split(",") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) bwData = [0, 0] @@ -758,14 +827,14 @@ class WebsiteManager: diff = finalDate - now Data['viewSSL'] = 1 Data['days'] = str(diff.days) - Data['authority'] = x509.get_issuer().get_components()[1][1] + Data['authority'] = x509.get_issuer().get_components()[1][1].decode('utf-8') if Data['authority'] == 'Denial': Data['authority'] = '%s has SELF-SIGNED SSL.' % (self.domain) else: Data['authority'] = '%s has SSL from %s.' % (self.domain, Data['authority']) - except BaseException, msg: + except BaseException as msg: Data['viewSSL'] = 0 logging.CyberCPLogFileWriter.writeToFile(str(msg)) @@ -810,13 +879,13 @@ class WebsiteManager: ## bw usage calculation try: - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " findDomainBW --virtualHostName " + self.domain + " --bandwidth " + str( website.package.bandwidth) output = ProcessUtilities.outputExecutioner(execPath) bwData = output.split(",") - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) bwData = [0, 0] @@ -866,14 +935,14 @@ class WebsiteManager: diff = finalDate - now Data['viewSSL'] = 1 Data['days'] = str(diff.days) - Data['authority'] = x509.get_issuer().get_components()[1][1] + Data['authority'] = x509.get_issuer().get_components()[1][1].decode('utf-8') if Data['authority'] == 'Denial': Data['authority'] = '%s has SELF-SIGNED SSL.' % (self.childDomain) else: Data['authority'] = '%s has SSL from %s.' % (self.childDomain, Data['authority']) - except BaseException, msg: + except BaseException as msg: Data['viewSSL'] = 0 logging.CyberCPLogFileWriter.writeToFile(str(msg)) @@ -1027,7 +1096,7 @@ class WebsiteManager: ## save configuration data - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " saveVHostConfigs --path " + filePath + " --tempPath " + tempPath output = ProcessUtilities.outputExecutioner(execPath) @@ -1152,7 +1221,7 @@ class WebsiteManager: ## writing data temporary to file - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " saveSSL --virtualHostName " + self.domain + " --tempKeyPath " + tempKeyPath + " --tempCertPath " + tempCertPath output = ProcessUtilities.outputExecutioner(execPath) @@ -1182,7 +1251,7 @@ class WebsiteManager: confPath = virtualHostUtilities.Server_root + "/conf/vhosts/" + self.domain completePathToConfigFile = confPath + "/vhost.conf" - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " changePHP --phpVersion '" + phpVersion + "' --path " + completePathToConfigFile ProcessUtilities.popenExecutioner(execPath) @@ -1215,7 +1284,7 @@ class WebsiteManager: crons = [] - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/cronUtil.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/cronUtil.py" execPath = execPath + " getWebsiteCron --externalApp " + website.externalApp f = ProcessUtilities.outputExecutioner(execPath, website.externalApp) @@ -1244,7 +1313,7 @@ class WebsiteManager: data_ret = {'getWebsiteCron': 1, "user": website.externalApp, "crons": crons} final_json = json.dumps(data_ret) return HttpResponse(final_json) - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) dic = {'getWebsiteCron': 0, 'error_message': str(msg)} json_data = json.dumps(dic) @@ -1276,7 +1345,7 @@ class WebsiteManager: try: CronUtil.CronPrem(1) - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/cronUtil.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/cronUtil.py" execPath = execPath + " getWebsiteCron --externalApp " + website.externalApp f = ProcessUtilities.outputExecutioner(execPath, website.externalApp) @@ -1308,8 +1377,8 @@ class WebsiteManager: "line": line} final_json = json.dumps(data_ret) return HttpResponse(final_json) - except BaseException, msg: - print msg + except BaseException as msg: + print(msg) dic = {'getWebsiteCron': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -1341,7 +1410,7 @@ class WebsiteManager: CronUtil.CronPrem(1) - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/cronUtil.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/cronUtil.py" execPath = execPath + " saveCronChanges --externalApp " + website.externalApp + " --line " + str( line) + " --finalCron '" + finalCron + "'" output = ProcessUtilities.outputExecutioner(execPath, website.externalApp) @@ -1359,7 +1428,7 @@ class WebsiteManager: json_data = json.dumps(dic) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: dic = {'getWebsiteCron': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -1381,7 +1450,7 @@ class WebsiteManager: CronUtil.CronPrem(1) - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/cronUtil.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/cronUtil.py" execPath = execPath + " remCronbyLine --externalApp " + website.externalApp + " --line " + str( line) output = ProcessUtilities.outputExecutioner(execPath, website.externalApp) @@ -1401,7 +1470,7 @@ class WebsiteManager: return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: dic = {'remCronbyLine': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -1438,7 +1507,7 @@ class WebsiteManager: finalCron = "%s %s %s %s %s %s" % (minute, hour, monthday, month, weekday, command) - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/cronUtil.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/cronUtil.py" execPath = execPath + " addNewCron --externalApp " + website.externalApp + " --finalCron '" + finalCron + "'" output = ProcessUtilities.outputExecutioner(execPath, website.externalApp) @@ -1457,7 +1526,7 @@ class WebsiteManager: return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: dic = {'addNewCron': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) @@ -1487,7 +1556,7 @@ class WebsiteManager: ## Create Configurations - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " createAlias --masterDomain " + self.domain + " --aliasDomain " + aliasDomain + " --ssl " + str( ssl) + " --sslPath " + sslpath + " --administratorEmail " + admin.email + ' --websiteOwner ' + admin.userName @@ -1509,7 +1578,7 @@ class WebsiteManager: - except BaseException, msg: + except BaseException as msg: data_ret = {'createAliasStatus': 0, 'error_message': str(msg), "existsStatus": 0} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1532,7 +1601,7 @@ class WebsiteManager: ## Create Configurations - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " issueAliasSSL --masterDomain " + self.domain + " --aliasDomain " + aliasDomain + " --sslPath " + sslpath + " --administratorEmail " + admin.email output = ProcessUtilities.outputExecutioner(execPath) @@ -1546,7 +1615,7 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'sslStatus': 0, 'error_message': str(msg), "existsStatus": 0} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1567,7 +1636,7 @@ class WebsiteManager: ## Create Configurations - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " deleteAlias --masterDomain " + self.domain + " --aliasDomain " + aliasDomain output = ProcessUtilities.outputExecutioner(execPath) @@ -1581,7 +1650,7 @@ class WebsiteManager: return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'deleteAlias': 0, 'error_message': str(msg), "existsStatus": 0} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1599,7 +1668,7 @@ class WebsiteManager: else: return ACLManager.loadErrorJson('changeOpenBasedir', 0) - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " changeOpenBasedir --virtualHostName '" + self.domain + "' --openBasedirValue " + openBasedirValue output = ProcessUtilities.popenExecutioner(execPath) @@ -1607,7 +1676,7 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'changeOpenBasedir': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1624,7 +1693,7 @@ class WebsiteManager: return render(request, 'websiteFunctions/installWordPress.html', {'domainName': self.domain}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def installWordpress(self, userID=None, data=None): @@ -1666,7 +1735,7 @@ class WebsiteManager: return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1703,7 +1772,7 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'abort': 1, 'installStatus': 0, 'installationProgress': "0", 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1719,7 +1788,7 @@ class WebsiteManager: return ACLManager.loadError() return render(request, 'websiteFunctions/installJoomla.html', {'domainName': self.domain}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def installJoomla(self, userID=None, data=None): @@ -1750,7 +1819,7 @@ class WebsiteManager: statusFile = open(tempStatusPath, 'w') statusFile.writelines('Setting up paths,0') statusFile.close() - os.chmod(tempStatusPath, 0777) + os.chmod(tempStatusPath, 0o777) finalPath = "" @@ -1851,7 +1920,7 @@ class WebsiteManager: ## Installation ends - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1908,7 +1977,7 @@ StrictHostKeyChecking no return render(request, 'websiteFunctions/setupGit.html', {'domainName': self.domain, 'deploymentKey': deploymentKey, 'installed': 0}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def setupGitRepo(self, userID=None, data=None): @@ -1945,7 +2014,7 @@ StrictHostKeyChecking no return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'installStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1963,7 +2032,7 @@ StrictHostKeyChecking no json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'pulled': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1996,7 +2065,7 @@ StrictHostKeyChecking no return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -2030,7 +2099,7 @@ StrictHostKeyChecking no return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -2046,7 +2115,7 @@ StrictHostKeyChecking no return ACLManager.loadError() return render(request, 'websiteFunctions/installPrestaShop.html', {'domainName': self.domain}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def installMagento(self, request=None, userID=None, data=None): @@ -2060,7 +2129,7 @@ StrictHostKeyChecking no return ACLManager.loadError() return render(request, 'websiteFunctions/installMagento.html', {'domainName': self.domain}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def magentoInstall(self, userID=None, data=None): @@ -2105,7 +2174,7 @@ StrictHostKeyChecking no ## Installation ends - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -2152,7 +2221,7 @@ StrictHostKeyChecking no ## Installation ends - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -2206,7 +2275,7 @@ StrictHostKeyChecking no return self.submitWebsiteCreation(admin.pk, data) - except BaseException, msg: + except BaseException as msg: data_ret = {'createWebSiteStatus': 0, 'error_message': str(msg), "existsStatus": 0} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -2223,7 +2292,7 @@ StrictHostKeyChecking no f = open(ipFile) ipData = f.read() ipAddress = ipData.split('\n', 1)[0] - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile("Failed to read machine IP, error:" + str(msg)) ipAddress = "192.168.100.1" @@ -2261,7 +2330,7 @@ StrictHostKeyChecking no f = open(ipFile) ipData = f.read() ipAddress = ipData.split('\n', 1)[0] - except BaseException, msg: + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile("Failed to read machine IP, error:" + str(msg)) ipAddress = "192.168.100.1" @@ -2368,7 +2437,7 @@ StrictHostKeyChecking no json_data = json.dumps(data) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'saveStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -2388,7 +2457,7 @@ StrictHostKeyChecking no tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999)) - execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = execPath + " switchServer --phpVersion '" + phpVersion + "' --server " + str( server) + " --virtualHostName " + domainName + " --tempStatusPath " + tempStatusPath ProcessUtilities.popenExecutioner(execPath) @@ -2484,7 +2553,7 @@ StrictHostKeyChecking no return render(request, 'websiteFunctions/sshAccess.html', {'domainName': self.domain, 'externalApp': externalApp}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) def saveSSHAccessChanges(self, userID=None, data=None): @@ -2515,7 +2584,7 @@ StrictHostKeyChecking no json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -2536,7 +2605,7 @@ StrictHostKeyChecking no return render(request, 'websiteFunctions/setupStaging.html', {'domainName': self.domain, 'externalApp': externalApp}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) @@ -2590,7 +2659,7 @@ StrictHostKeyChecking no json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -2611,7 +2680,7 @@ StrictHostKeyChecking no return render(request, 'websiteFunctions/syncMaster.html', {'domainName': self.domain, 'externalApp': externalApp, 'childDomain': childDomain}) - except BaseException, msg: + except BaseException as msg: return HttpResponse(str(msg)) @@ -2671,7 +2740,26 @@ StrictHostKeyChecking no json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException, msg: + except BaseException as msg: data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) return HttpResponse(json_data) + + + def convertDomainToSite(self, userID=None, request=None): + try: + + extraArgs = {} + extraArgs['request'] = request + extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999)) + background = ApplicationInstaller('convertDomainToSite', extraArgs) + background.start() + + data_ret = {'status': 1, 'createWebSiteStatus': 1, 'tempStatusPath': extraArgs['tempStatusPath']} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + except BaseException as msg: + data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': str(msg)} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) \ No newline at end of file