diff --git a/cloudAPI/cloudManager.py b/cloudAPI/cloudManager.py index ef37bfdcd..a1153878f 100755 --- a/cloudAPI/cloudManager.py +++ b/cloudAPI/cloudManager.py @@ -24,7 +24,7 @@ from containerization.views import * class CloudManager: - def __init__(self, data=None, admin = None): + def __init__(self, data=None, admin=None): self.data = data self.admin = admin @@ -964,14 +964,14 @@ class CloudManager: request.session['userID'] = self.admin.pk - execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/IncScheduler.py forceRunAWSBackup --planName %s" % (self.data['planName']) + execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/IncScheduler.py forceRunAWSBackup --planName %s" % ( + self.data['planName']) ProcessUtilities.popenExecutioner(execPath) return self.ajaxPre(1, None) except BaseException as msg: return self.ajaxPre(0, str(msg)) - def systemStatus(self, request): try: request.session['userID'] = self.admin.pk @@ -979,7 +979,6 @@ class CloudManager: except BaseException as msg: return self.ajaxPre(0, str(msg)) - def killProcess(self, request): try: request.session['userID'] = self.admin.pk @@ -987,7 +986,6 @@ class CloudManager: except BaseException as msg: return self.ajaxPre(0, str(msg)) - def connectAccountDO(self, request): try: request.session['userID'] = self.admin.pk @@ -1004,7 +1002,6 @@ class CloudManager: except BaseException as msg: return self.ajaxPre(0, str(msg)) - def createPlanDO(self, request): try: request.session['userID'] = self.admin.pk @@ -1073,7 +1070,7 @@ class CloudManager: def showStatus(self, request): try: request.session['userID'] = self.admin.pk - currentACL = ACLManager.loadedACL( self.admin.pk) + currentACL = ACLManager.loadedACL(self.admin.pk) if currentACL['admin'] == 0: return self.ajaxPre(0, 'Only administrators can see MySQL status.') @@ -1088,24 +1085,22 @@ class CloudManager: def fetchRam(self, request): try: request.session['userID'] = self.admin.pk - currentACL = ACLManager.loadedACL( self.admin.pk) + currentACL = ACLManager.loadedACL(self.admin.pk) if currentACL['admin'] == 0: return self.ajaxPre(0, 'Only administrators can see MySQL status.') - #if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: + # if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: # return self.ajaxPre(0, 'This feature is currently only available on CentOS.') - from psutil import virtual_memory import math finalData = {} mem = virtual_memory() - inGB = math.ceil(float(mem.total)/float(1024 * 1024 * 1024)) + inGB = math.ceil(float(mem.total) / float(1024 * 1024 * 1024)) finalData['ramInGB'] = inGB - if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: finalData['conf'] = ProcessUtilities.outputExecutioner('sudo cat /etc/my.cnf') else: @@ -1121,7 +1116,7 @@ class CloudManager: def applyMySQLChanges(self, request): try: request.session['userID'] = self.admin.pk - currentACL = ACLManager.loadedACL( self.admin.pk) + currentACL = ACLManager.loadedACL(self.admin.pk) if currentACL['admin'] == 0: return self.ajaxPre(0, 'Only administrators can see MySQL status.') @@ -1139,7 +1134,7 @@ class CloudManager: def restartMySQL(self, request): try: request.session['userID'] = self.admin.pk - currentACL = ACLManager.loadedACL( self.admin.pk) + currentACL = ACLManager.loadedACL(self.admin.pk) if currentACL['admin'] == 0: return self.ajaxPre(0, 'Only administrators can see MySQL status.') @@ -1154,7 +1149,7 @@ class CloudManager: def fetchDatabasesMYSQL(self, request): try: request.session['userID'] = self.admin.pk - currentACL = ACLManager.loadedACL( self.admin.pk) + currentACL = ACLManager.loadedACL(self.admin.pk) if currentACL['admin'] == 0: return self.ajaxPre(0, 'Only administrators can see MySQL status.') @@ -1169,7 +1164,7 @@ class CloudManager: def fetchTables(self, request): try: request.session['userID'] = self.admin.pk - currentACL = ACLManager.loadedACL( self.admin.pk) + currentACL = ACLManager.loadedACL(self.admin.pk) if currentACL['admin'] == 0: return self.ajaxPre(0, 'Only administrators can see MySQL status.') @@ -1184,7 +1179,7 @@ class CloudManager: def deleteTable(self, request): try: request.session['userID'] = self.admin.pk - currentACL = ACLManager.loadedACL( self.admin.pk) + currentACL = ACLManager.loadedACL(self.admin.pk) if currentACL['admin'] == 0: return self.ajaxPre(0, 'Only administrators can see MySQL status.') @@ -1199,7 +1194,7 @@ class CloudManager: def fetchTableData(self, request): try: request.session['userID'] = self.admin.pk - currentACL = ACLManager.loadedACL( self.admin.pk) + currentACL = ACLManager.loadedACL(self.admin.pk) if currentACL['admin'] == 0: return self.ajaxPre(0, 'Only administrators can see MySQL status.') @@ -1214,7 +1209,7 @@ class CloudManager: def fetchStructure(self, request): try: request.session['userID'] = self.admin.pk - currentACL = ACLManager.loadedACL( self.admin.pk) + currentACL = ACLManager.loadedACL(self.admin.pk) if currentACL['admin'] == 0: return self.ajaxPre(0, 'Only administrators can see MySQL status.') @@ -1266,7 +1261,6 @@ class CloudManager: except BaseException as msg: return self.ajaxPre(0, str(msg)) - def deletePlanMINIO(self, request): try: request.session['userID'] = self.admin.pk @@ -1340,7 +1334,6 @@ class CloudManager: except BaseException as msg: return self.ajaxPre(0, str(msg)) - def switchServer(self, request): try: request.session['userID'] = self.admin.pk @@ -1666,9 +1659,9 @@ class CloudManager: except: databases = '0' - execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" - execPath = execPath + " CloudBackup --backupDomain %s --data %s --emails %s --databases %s --tempStoragePath %s" % (self.data['domain'], data, emails, databases, tempStatusPath) + execPath = execPath + " CloudBackup --backupDomain %s --data %s --emails %s --databases %s --tempStoragePath %s" % ( + self.data['domain'], data, emails, databases, tempStatusPath) ProcessUtilities.popenExecutioner(execPath) final_dic = {'status': 1, 'tempStatusPath': tempStatusPath} @@ -1695,7 +1688,7 @@ class CloudManager: counter = 1 for items in backups: - size = str(int(int(os.path.getsize('%s/%s' % (backupsPath, items)))/int(1048576))) + size = str(int(int(os.path.getsize('%s/%s' % (backupsPath, items))) / int(1048576))) dic = {'id': counter, 'file': items, @@ -1782,7 +1775,8 @@ class CloudManager: writeToFile.close() execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" - execPath = execPath + " SubmitCloudBackupRestore --backupDomain %s --backupFile %s --tempStoragePath %s" % (self.data['domain'], self.data['backupFile'], tempStatusPath) + execPath = execPath + " SubmitCloudBackupRestore --backupDomain %s --backupFile %s --tempStoragePath %s" % ( + self.data['domain'], self.data['backupFile'], tempStatusPath) ProcessUtilities.popenExecutioner(execPath) final_dic = {'status': 1, 'tempStatusPath': tempStatusPath} @@ -1874,7 +1868,7 @@ class CloudManager: 's3', aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, - endpoint_url = region + endpoint_url=region ) else: s3 = boto3.resource( @@ -1902,7 +1896,8 @@ class CloudManager: writeToFile.close() execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" - execPath = execPath + " SubmitS3BackupRestore --backupDomain %s --backupFile '%s' --tempStoragePath %s --planName %s" % (self.data['domain'], self.data['backupFile'], tempStatusPath, self.data['planName']) + execPath = execPath + " SubmitS3BackupRestore --backupDomain %s --backupFile '%s' --tempStoragePath %s --planName %s" % ( + self.data['domain'], self.data['backupFile'], tempStatusPath, self.data['planName']) ProcessUtilities.popenExecutioner(execPath) final_dic = {'status': 1, 'tempStatusPath': tempStatusPath} @@ -1910,4 +1905,30 @@ class CloudManager: return HttpResponse(final_json) except BaseException as msg: - return self.ajaxPre(0, str(msg)) \ No newline at end of file + return self.ajaxPre(0, str(msg)) + + def DeployWordPress(self): + try: + + tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999)) + + writeToFile = open(tempStatusPath, 'w') + writeToFile.write('Starting..,0') + writeToFile.close() + + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/applicationInstaller.py" + execPath = execPath + " DeployWordPress --tempStatusPath %s --appsSet '%s' --domain '%s' --email '%s' --password '%s' " \ + "--pluginUpdates '%s' --themeUpdates '%s' --title '%s' --updates '%s' --userName '%s' " \ + "--version '%s'" % ( + tempStatusPath, self.data['appsSet'], self.data['domain'], self.data['email'], self.data['password'], + self.data['pluginUpdates'], self.data['themeUpdates'], self.data['title'], self.data['updates'], + self.data['userName'], self.data['version']) + + ProcessUtilities.popenExecutioner(execPath) + + final_dic = {'status': 1, 'tempStatusPath': tempStatusPath} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + + except BaseException as msg: + return self.ajaxPre(0, str(msg)) diff --git a/cloudAPI/views.py b/cloudAPI/views.py index 77448b142..1bfd9bcab 100755 --- a/cloudAPI/views.py +++ b/cloudAPI/views.py @@ -63,6 +63,8 @@ def router(request): return cm.deleteCloudBackup() elif controller == 'SubmitCloudBackupRestore': return cm.SubmitCloudBackupRestore() + elif controller == 'DeployWordPress': + return cm.DeployWordPress() elif controller == 'getCurrentS3Backups': return cm.getCurrentS3Backups() elif controller == 'deleteS3Backup': diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index a63950d61..7274254bf 100755 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -1,4 +1,5 @@ #!/usr/local/CyberCP/bin/python +import argparse import os, sys sys.path.append('/usr/local/CyberCP') @@ -1217,3 +1218,54 @@ $parameters = array( # statusFile.writelines(str(msg) + " [404]") # statusFile.close() # return 0 + + def DeployWordPress(self): + try: + logging.statusWriter(self.extraArgs['tempStatusPath'], 'Checking if MailServer SSL issued..,10') + + import time + time.sleep(5) + + logging.statusWriter(self.extraArgs['tempStatusPath'], 'Completed [200].') + + except BaseException as msg: + logging.statusWriter(self.extraArgs['tempStatusPath'], '%s [404].' % (str(msg))) + +def main(): + parser = argparse.ArgumentParser(description='CyberPanel Application Installer') + parser.add_argument('function', help='Specify a function to call!') + parser.add_argument('--tempStatusPath', help='') + parser.add_argument('--appsSet', help='') + parser.add_argument('--domain', help='') + parser.add_argument('--email', help='') + parser.add_argument('--password', help='') + parser.add_argument('--pluginUpdates', help='') + parser.add_argument('--themeUpdates', help='') + parser.add_argument('--title', help='') + parser.add_argument('--updates', help='') + parser.add_argument('--userName', help='') + parser.add_argument('--version', help='') + + + args = parser.parse_args() + + if args.function == "DeployWordPress": + + extraArgs = {} + extraArgs['domain'] = args.domain + extraArgs['tempStatusPath'] = args.tempStatusPath + extraArgs['appsSet'] = args.appsSet + extraArgs['email'] = args.email + extraArgs['password'] = args.password + extraArgs['pluginUpdates'] = args.pluginUpdates + extraArgs['themeUpdates'] = args.themeUpdates + extraArgs['title'] = args.title + extraArgs['updates'] = args.updates + extraArgs['userName'] = args.userName + extraArgs['version'] = args.version + ai = ApplicationInstaller(None, extraArgs) + ai.DeployWordPress() + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/plogical/backupUtilities.py b/plogical/backupUtilities.py index d59b9fefe..46655062b 100755 --- a/plogical/backupUtilities.py +++ b/plogical/backupUtilities.py @@ -2085,6 +2085,5 @@ def main(): bu = backupUtilities(extraArgs) bu.SubmitS3BackupRestore() - if __name__ == "__main__": main() diff --git a/s3Backups/s3Backups.py b/s3Backups/s3Backups.py index 9b2c56d9e..19c543916 100755 --- a/s3Backups/s3Backups.py +++ b/s3Backups/s3Backups.py @@ -148,6 +148,7 @@ class S3Backups(multi.Thread): if currentACL['admin'] == 0: return proc.ajax(0, 'Only administrators can use AWS S3 Backups.') + from botocore.client import Config aws_access_key_id, aws_secret_access_key, region = self.fetchAWSKeys() @@ -156,7 +157,8 @@ class S3Backups(multi.Thread): 's3', aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, - endpoint_url=region + endpoint_url=region, + config=Config(signature_version='v4') ) else: s3 = boto3.resource(