@@ -1659,12 +1659,31 @@ def SubmitCloudBackup(self):
16591659 except :
16601660 databases = '0'
16611661
1662+ try :
1663+ port = str (self .data ['port' ])
1664+ except :
1665+ port = '0'
1666+
1667+ try :
1668+ ip = str (self .data ['ip' ])
1669+ except :
1670+ ip = '0'
1671+
1672+ try :
1673+ destinationDomain = self .data ['destinationDomain' ]
1674+ except :
1675+ destinationDomain = ''
1676+
1677+ import time
1678+ BackupPath = '/home/cyberpanel/backups/%s/backup-' % (self .data ['domain' ]) + self .data ['domain' ] + "-" + time .strftime ("%m.%d.%Y_%H-%M-%S" )
1679+
16621680 execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities .cyberPanel + "/plogical/backupUtilities.py"
1663- execPath = execPath + " CloudBackup --backupDomain %s --data %s --emails %s --databases %s --tempStoragePath %s" % (
1664- self .data ['domain' ], data , emails , databases , tempStatusPath )
1681+ execPath = execPath + " CloudBackup --backupDomain %s --data %s --emails %s --databases %s --tempStoragePath %s " \
1682+ "--path %s --port %s --ip %s --destinationDomain %s" % (
1683+ self .data ['domain' ], data , emails , databases , tempStatusPath , BackupPath , port , ip , destinationDomain )
16651684 ProcessUtilities .popenExecutioner (execPath )
16661685
1667- final_dic = {'status' : 1 , 'tempStatusPath' : tempStatusPath }
1686+ final_dic = {'status' : 1 , 'tempStatusPath' : tempStatusPath , 'path' : '%s.tar.gz' % ( BackupPath ) }
16681687 final_json = json .dumps (final_dic )
16691688 return HttpResponse (final_json )
16701689
@@ -1774,9 +1793,14 @@ def SubmitCloudBackupRestore(self):
17741793 writeToFile .write ('Starting..,0' )
17751794 writeToFile .close ()
17761795
1796+ try :
1797+ sourceDomain = self .data ['sourceDomain' ]
1798+ except :
1799+ sourceDomain = 'None'
1800+
17771801 execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities .cyberPanel + "/plogical/backupUtilities.py"
1778- execPath = execPath + " SubmitCloudBackupRestore --backupDomain %s --backupFile %s --tempStoragePath %s" % (
1779- self .data ['domain' ], self .data ['backupFile' ], tempStatusPath )
1802+ execPath = execPath + " SubmitCloudBackupRestore --backupDomain %s --backupFile %s --sourceDomain %s -- tempStoragePath %s" % (
1803+ self .data ['domain' ], self .data ['backupFile' ],sourceDomain , tempStatusPath )
17801804 ProcessUtilities .popenExecutioner (execPath )
17811805
17821806 final_dic = {'status' : 1 , 'tempStatusPath' : tempStatusPath }
@@ -1993,11 +2017,8 @@ def FetchWordPressDetails(self):
19932017
19942018 ## Get title
19952019
1996- from cloudAPI .models import WPDeployments
1997- import json
1998- wpd = WPDeployments .objects .get (owner = website )
1999- config = json .loads (wpd .config )
2000- finalDic ['title' ] = config ['title' ]
2020+ command = 'wp option get blogname --path=/home/%s/public_html' % (domain )
2021+ finalDic ['title' ] = ProcessUtilities .outputExecutioner (command , website .externalApp )
20012022
20022023 ##
20032024
@@ -2320,4 +2341,62 @@ def DeleteThemes(self):
23202341 except BaseException as msg :
23212342 final_dic = {'status' : 0 , 'fetchStatus' : 0 , 'error_message' : str (msg )}
23222343 final_json = json .dumps (final_dic )
2323- return HttpResponse (final_json )
2344+ return HttpResponse (final_json )
2345+
2346+ def GetServerPublicSSHkey (self ):
2347+ try :
2348+
2349+ path = '/root/.ssh/cyberpanel.pub'
2350+ command = 'cat %s' % (path )
2351+ key = ProcessUtilities .outputExecutioner (command )
2352+
2353+ final_dic = {'status' : 1 , 'key' : key }
2354+ final_json = json .dumps (final_dic )
2355+ return HttpResponse (final_json )
2356+
2357+ except BaseException as msg :
2358+ final_dic = {'status' : 0 , 'fetchStatus' : 0 , 'error_message' : str (msg )}
2359+ final_json = json .dumps (final_dic )
2360+ return HttpResponse (final_json )
2361+
2362+ def SubmitPublicKey (self ):
2363+ try :
2364+
2365+ fm = FirewallManager ()
2366+ fm .addSSHKey (self .admin .pk , self .data )
2367+
2368+ ## Create backup path so that file can be sent here later.
2369+
2370+ BackupPath = '/home/cyberpanel/backups/%s' % (self .data ['domain' ])
2371+ command = 'mkdir -p %s' % (BackupPath )
2372+ ProcessUtilities .executioner (command , 'cyberpanel' )
2373+
2374+ ###
2375+
2376+ from WebTerminal .CPWebSocket import SSHServer
2377+ SSHServer .findSSHPort ()
2378+
2379+ final_dic = {'status' : 1 , 'port' : SSHServer .DEFAULT_PORT }
2380+ final_json = json .dumps (final_dic )
2381+ return HttpResponse (final_json )
2382+
2383+ except BaseException as msg :
2384+ final_dic = {'status' : 0 , 'fetchStatus' : 0 , 'error_message' : str (msg )}
2385+ final_json = json .dumps (final_dic )
2386+ return HttpResponse (final_json )
2387+
2388+ def CreateStaging (self , request ):
2389+ try :
2390+ request .session ['userID' ] = self .admin .pk
2391+ wm = WebsiteManager ()
2392+ return wm .startCloning (self .admin .pk , self .data )
2393+ except BaseException as msg :
2394+ return self .ajaxPre (0 , str (msg ))
2395+
2396+ def startSync (self , request ):
2397+ try :
2398+ request .session ['userID' ] = self .admin .pk
2399+ wm = WebsiteManager ()
2400+ return wm .startSync (self .admin .pk , self .data )
2401+ except BaseException as msg :
2402+ return self .ajaxPre (0 , str (msg ))
0 commit comments