mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
cloud backups
This commit is contained in:
@@ -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
|
||||
@@ -1096,7 +1093,6 @@ class CloudManager:
|
||||
# if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
# return self.ajaxPre(0, 'This feature is currently only available on CentOS.')
|
||||
|
||||
|
||||
from psutil import virtual_memory
|
||||
import math
|
||||
|
||||
@@ -1105,7 +1101,6 @@ class CloudManager:
|
||||
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:
|
||||
@@ -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}
|
||||
@@ -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}
|
||||
@@ -1902,7 +1896,34 @@ 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}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException as msg:
|
||||
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}
|
||||
|
||||
@@ -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':
|
||||
|
||||
@@ -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()
|
||||
@@ -2085,6 +2085,5 @@ def main():
|
||||
bu = backupUtilities(extraArgs)
|
||||
bu.SubmitS3BackupRestore()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user