mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-13 16:56:09 +01:00
Merge branch 'v2.3.2-dev' of github.com:usmannasir/cyberpanel into v2.3.2-dev
This commit is contained in:
@@ -2882,24 +2882,23 @@ $parameters = array(
|
|||||||
installUtilities.reStartLiteSpeed()
|
installUtilities.reStartLiteSpeed()
|
||||||
####Check if BAckup type is Only Webdata
|
####Check if BAckup type is Only Webdata
|
||||||
elif BackupType == 'Website Backup':
|
elif BackupType == 'Website Backup':
|
||||||
############## Existing site
|
|
||||||
if (DomainName == "" and int(self.extraArgs['DesSiteID']) != -1):
|
if (DomainName == "" and int(self.extraArgs['DesSiteID']) != -1):
|
||||||
wpsite = WPSites.objects.get(pk=DesSiteID)
|
wpsite = WPSites.objects.get(pk=DesSiteID)
|
||||||
VHuser = wpsite.owner.externalApp
|
webobj = Websites.objects.get(pk=wpsite.owner_id)
|
||||||
newWPpath = wpsite.path
|
ag = WPSites.objects.filter(owner=webobj).count()
|
||||||
newurl = wpsite.FinalURL
|
if ag > 0:
|
||||||
|
###Website found --> Wpsite Found
|
||||||
#### Check If sub dir in web site
|
finalurl = "%s%s" % (webobj.domain, oldurl[oldurl.find('/'):])
|
||||||
try:
|
try:
|
||||||
oldpath = config['WPsitepath']
|
WPobj = WPSites.objects.get(FinalURL=finalurl, owner=webobj)
|
||||||
abc = oldpath.split("/")
|
###Website found --> WPsite Found --> Final URL Match
|
||||||
pathexta = abc[4]
|
#### Do not create Ne site
|
||||||
if pathexta != "":
|
### get WPsite Database name and usr
|
||||||
home = "0"
|
VHuser = wpsite.owner.externalApp
|
||||||
else:
|
PhpVersion = WPobj.owner.phpSelection
|
||||||
home = "1"
|
newWPpath = WPobj.path
|
||||||
except BaseException as msg:
|
php = PHPManager.getPHPString(PhpVersion)
|
||||||
home = "1"
|
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
|
||||||
|
|
||||||
### Create secure folder
|
### Create secure folder
|
||||||
|
|
||||||
@@ -2942,70 +2941,33 @@ $parameters = array(
|
|||||||
if result == 0:
|
if result == 0:
|
||||||
raise BaseException(stdout)
|
raise BaseException(stdout)
|
||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Copying Data File...,50')
|
|
||||||
###Copy backup content to newsite
|
|
||||||
if home == "0":
|
|
||||||
#### Check If sub dir in New web site
|
|
||||||
try:
|
|
||||||
kl = newWPpath.split("/")
|
|
||||||
newpathexta = kl[4]
|
|
||||||
if newpathexta != "":
|
|
||||||
newsubdir = "0"
|
|
||||||
else:
|
|
||||||
newsubdir = "1"
|
|
||||||
except BaseException as msg:
|
|
||||||
newsubdir = "1"
|
|
||||||
|
|
||||||
if newsubdir == "0":
|
|
||||||
unzippath = "%s/ab/usr/local/CyberCP/tmp/%s/public_html/" % (self.tempPath, oldtemppath)
|
unzippath = "%s/ab/usr/local/CyberCP/tmp/%s/public_html/" % (self.tempPath, oldtemppath)
|
||||||
###first split back to publich_html then mak dir and te copy
|
|
||||||
b = newWPpath.rstrip('/')
|
|
||||||
newwebpath = b.rstrip(newpathexta)
|
|
||||||
command = "sudo -u %s mkdir %s%s" % (VHuser, newwebpath, pathexta)
|
|
||||||
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
|
|
||||||
if result == 0:
|
command = "sudo -u %s cp -R %s* %s" % (VHuser, unzippath, newWPpath)
|
||||||
raise BaseException(stdout)
|
|
||||||
Webnewpath = str(newwebpath) + str(pathexta)
|
|
||||||
|
|
||||||
else:
|
|
||||||
unzippath = "%s/ab/usr/local/CyberCP/tmp/%s/public_html/" % (self.tempPath, oldtemppath)
|
|
||||||
###make dir of sub folder in existing site
|
|
||||||
command = "sudo -u %s mkdir %s%s" % (VHuser, newWPpath, pathexta)
|
|
||||||
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
|
|
||||||
if result == 0:
|
|
||||||
raise BaseException(stdout)
|
|
||||||
Webnewpath = str(newWPpath) + str(pathexta)
|
|
||||||
|
|
||||||
else:
|
|
||||||
|
|
||||||
unzippath = "%s/ab/usr/local/CyberCP/tmp/%s/public_html/" % (self.tempPath, oldtemppath)
|
|
||||||
Webnewpath = newWPpath
|
|
||||||
|
|
||||||
command = "sudo -u %s cp -R %s* %s" % (VHuser, unzippath, Webnewpath)
|
|
||||||
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
if result == 0:
|
if result == 0:
|
||||||
raise BaseException(stdout)
|
raise BaseException(stdout)
|
||||||
|
|
||||||
command = "sudo -u %s cp -R %s.[^.]* %s" % (VHuser, unzippath, Webnewpath)
|
command = "sudo -u %s cp -R %s.[^.]* %s" % (VHuser, unzippath, newWPpath)
|
||||||
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
if result == 0:
|
if result == 0:
|
||||||
raise BaseException(stdout)
|
raise BaseException(stdout)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Replacing URLs...,90')
|
logging.statusWriter(self.tempStatusPath, 'Replacing URLs...,90')
|
||||||
########Now Replace URL's
|
########Now Replace URL's
|
||||||
command = 'sudo -u %s /usr/local/lsws/lsphp74/bin/php -d error_reporting=0 /usr/bin/wp search-replace --skip-plugins --skip-themes --path=%s "%s" "%s"' % (
|
command = 'sudo -u %s /usr/local/lsws/lsphp74/bin/php -d error_reporting=0 /usr/bin/wp search-replace --skip-plugins --skip-themes --path=%s "%s" "%s"' % (
|
||||||
VHuser, newWPpath, oldurl, newurl)
|
VHuser, newWPpath, oldurl, finalurl)
|
||||||
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
if stdout.find('Error:') > -1:
|
if stdout.find('Error:') > -1:
|
||||||
raise BaseException(stdout)
|
raise BaseException(stdout)
|
||||||
|
|
||||||
command = 'sudo -u %s /usr/local/lsws/lsphp74/bin/php -d error_reporting=0 /usr/bin/wp search-replace --skip-plugins --skip-themes --allow-root --path=%s "https://www.%s" "http://%s"' % (
|
command = 'sudo -u %s /usr/local/lsws/lsphp74/bin/php -d error_reporting=0 /usr/bin/wp search-replace --skip-plugins --skip-themes --allow-root --path=%s "https://www.%s" "http://%s"' % (
|
||||||
VHuser, newWPpath, newurl, newurl)
|
VHuser, newWPpath, finalurl, finalurl)
|
||||||
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
if stdout.find('Error:') > -1:
|
if stdout.find('Error:') > -1:
|
||||||
@@ -3013,16 +2975,104 @@ $parameters = array(
|
|||||||
|
|
||||||
# ##Remove temppath
|
# ##Remove temppath
|
||||||
command = f'rm -rf {self.tempPath}'
|
command = f'rm -rf {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
###Restart Server
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
from plogical.installUtilities import installUtilities
|
except:
|
||||||
installUtilities.reStartLiteSpeed()
|
####Website found --> WPsite Found --> Final URL Not Match
|
||||||
############## New Site
|
####Create new obj and call wordpressnew
|
||||||
|
Newurl = wpsite.FinalURL
|
||||||
|
WPpath = wpsite.path
|
||||||
|
VHuser = wpsite.owner.externalApp
|
||||||
|
PhpVersion = wpsite.owner.phpSelection
|
||||||
|
php = PHPManager.getPHPString(PhpVersion)
|
||||||
|
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Create secure folder
|
||||||
|
|
||||||
|
ACLManager.CreateSecureDir()
|
||||||
|
RandomPath = str(randint(1000, 9999))
|
||||||
|
self.tempPath = '%s/%s' % ('/usr/local/CyberCP/tmp', RandomPath)
|
||||||
|
|
||||||
|
command = f'mkdir -p {self.tempPath}'
|
||||||
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
|
command = f'chown -R {wpsite.owner.externalApp}:{wpsite.owner.externalApp} {self.tempPath}'
|
||||||
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
|
logging.statusWriter(self.tempStatusPath, 'Extracting Backup File...,30')
|
||||||
|
|
||||||
|
###First copy backup file to temp and then Unzip
|
||||||
|
command = "sudo -u %s cp -R /home/backup/%s* %s" % (
|
||||||
|
VHuser, BackUpFileName, self.tempPath)
|
||||||
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
|
#### Make temp dir ab for unzip
|
||||||
|
command = "sudo -u %s mkdir %s/ab" % (VHuser, self.tempPath)
|
||||||
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
|
command = "sudo -u %s tar -xvf %s/%s.tar.gz -C %s/ab" % (
|
||||||
|
VHuser, self.tempPath, BackUpFileName, self.tempPath)
|
||||||
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
|
unzippath = "%s/ab/usr/local/CyberCP/tmp/%s/public_html/" % (self.tempPath, oldtemppath)
|
||||||
|
|
||||||
|
command = "sudo -u %s cp -R %s* %s" % (VHuser, unzippath, WPpath)
|
||||||
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
|
command = "sudo -u %s cp -R %s.[^.]* %s" % (VHuser, unzippath, WPpath)
|
||||||
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
logging.statusWriter(self.tempStatusPath, 'Replacing URLs...,90')
|
||||||
|
########Now Replace URL's
|
||||||
|
command = 'sudo -u %s /usr/local/lsws/lsphp74/bin/php -d error_reporting=0 /usr/bin/wp search-replace --skip-plugins --skip-themes --path=%s "%s" "%s"' % (
|
||||||
|
VHuser, WPpath, oldurl, Newurl)
|
||||||
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
|
command = 'sudo -u %s /usr/local/lsws/lsphp74/bin/php -d error_reporting=0 /usr/bin/wp search-replace --skip-plugins --skip-themes --allow-root --path=%s "https://www.%s" "http://%s"' % (
|
||||||
|
VHuser, WPpath, Newurl, Newurl)
|
||||||
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
|
# ##Remove temppath
|
||||||
|
command = f'rm -rf {self.tempPath}'
|
||||||
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
elif (DomainName != "" and int(self.extraArgs['DesSiteID']) == -1):
|
elif (DomainName != "" and int(self.extraArgs['DesSiteID']) == -1):
|
||||||
###############Create New WordPressSite First
|
|
||||||
# logging.writeToFile("New Website Domain ....... %s" % str(DomainName))
|
|
||||||
DataToPass = {}
|
DataToPass = {}
|
||||||
|
|
||||||
DataToPass['title'] = config['WPtitle']
|
DataToPass['title'] = config['WPtitle']
|
||||||
@@ -3040,24 +3090,19 @@ $parameters = array(
|
|||||||
oldpath = config['WPsitepath']
|
oldpath = config['WPsitepath']
|
||||||
abc = oldpath.split("/")
|
abc = oldpath.split("/")
|
||||||
newpath = abc[4]
|
newpath = abc[4]
|
||||||
if newpath != "":
|
oldhome = "0"
|
||||||
newurl = "%s/%s" % (DomainName, newpath)
|
|
||||||
else:
|
|
||||||
newurl = DomainName
|
|
||||||
home = "0"
|
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
newpath = ""
|
oldhome = "1"
|
||||||
|
|
||||||
|
if self.extraArgs['path'] == '':
|
||||||
newurl = DomainName
|
newurl = DomainName
|
||||||
home = "1"
|
else:
|
||||||
|
newurl = "%s/%s" % (DomainName, self.extraArgs['path'])
|
||||||
|
|
||||||
DataToPass['path'] = newpath
|
DataToPass['path'] = self.extraArgs['path']
|
||||||
|
|
||||||
DataToPass['home'] = home
|
DataToPass['home'] = self.extraArgs['home']
|
||||||
|
|
||||||
try:
|
|
||||||
website = Websites.objects.get(domain=DomainName)
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Web Site Already Exist.[404]')
|
|
||||||
except:
|
|
||||||
ab = WebsiteManager()
|
ab = WebsiteManager()
|
||||||
coreResult = ab.submitWorpressCreation(userID, DataToPass)
|
coreResult = ab.submitWorpressCreation(userID, DataToPass)
|
||||||
coreResult1 = json.loads((coreResult).content)
|
coreResult1 = json.loads((coreResult).content)
|
||||||
@@ -3070,7 +3115,7 @@ $parameters = array(
|
|||||||
break
|
break
|
||||||
elif lastLine.find('[404]') > -1:
|
elif lastLine.find('[404]') > -1:
|
||||||
logging.statusWriter(self.tempStatusPath,
|
logging.statusWriter(self.tempStatusPath,
|
||||||
'Failed to WordPress: error: %s. [404]' % lastLine)
|
'Failed to Create WordPress: error: %s. [404]' % lastLine)
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
logging.statusWriter(self.tempStatusPath, 'Creating WordPress....,20')
|
logging.statusWriter(self.tempStatusPath, 'Creating WordPress....,20')
|
||||||
@@ -3079,8 +3124,16 @@ $parameters = array(
|
|||||||
logging.statusWriter(self.tempStatusPath, 'Restoring site ....,30')
|
logging.statusWriter(self.tempStatusPath, 'Restoring site ....,30')
|
||||||
NewWPsite = WPSites.objects.get(FinalURL=newurl)
|
NewWPsite = WPSites.objects.get(FinalURL=newurl)
|
||||||
VHuser = NewWPsite.owner.externalApp
|
VHuser = NewWPsite.owner.externalApp
|
||||||
|
PhpVersion = NewWPsite.owner.phpSelection
|
||||||
newWPpath = NewWPsite.path
|
newWPpath = NewWPsite.path
|
||||||
|
|
||||||
|
###### Same code already used in Existing site
|
||||||
|
|
||||||
|
### get WPsite Database name and usr
|
||||||
|
php = PHPManager.getPHPString(PhpVersion)
|
||||||
|
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
|
||||||
|
|
||||||
|
|
||||||
### Create secure folder
|
### Create secure folder
|
||||||
|
|
||||||
ACLManager.CreateSecureDir()
|
ACLManager.CreateSecureDir()
|
||||||
@@ -3124,7 +3177,7 @@ $parameters = array(
|
|||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Copying Data File...,60')
|
logging.statusWriter(self.tempStatusPath, 'Copying Data File...,60')
|
||||||
###Copy backup content to newsite
|
###Copy backup content to newsite
|
||||||
if home == "0":
|
if oldhome == "0":
|
||||||
unzippath = "%s/ab/usr/local/CyberCP/tmp/%s/public_html/" % (self.tempPath, oldtemppath)
|
unzippath = "%s/ab/usr/local/CyberCP/tmp/%s/public_html/" % (self.tempPath, oldtemppath)
|
||||||
else:
|
else:
|
||||||
unzippath = "%s/ab/usr/local/CyberCP/tmp/%s/public_html/public_html/" % (
|
unzippath = "%s/ab/usr/local/CyberCP/tmp/%s/public_html/public_html/" % (
|
||||||
@@ -3164,13 +3217,14 @@ $parameters = array(
|
|||||||
command = f'rm -rf {self.tempPath}'
|
command = f'rm -rf {self.tempPath}'
|
||||||
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
if result == 0:
|
if stdout.find('Error:') > -1:
|
||||||
raise BaseException(stdout)
|
raise BaseException(stdout)
|
||||||
|
|
||||||
###Restart Server
|
###Restart Server
|
||||||
|
|
||||||
from plogical.installUtilities import installUtilities
|
from plogical.installUtilities import installUtilities
|
||||||
installUtilities.reStartLiteSpeed()
|
installUtilities.reStartLiteSpeed()
|
||||||
|
|
||||||
####Check if backup type is Both web and DB
|
####Check if backup type is Both web and DB
|
||||||
else:
|
else:
|
||||||
############## Existing site
|
############## Existing site
|
||||||
@@ -3488,284 +3542,13 @@ $parameters = array(
|
|||||||
if stdout.find('Error:') > -1:
|
if stdout.find('Error:') > -1:
|
||||||
raise BaseException(stdout)
|
raise BaseException(stdout)
|
||||||
|
|
||||||
# # ##Remove temppath
|
# ##Remove temppath
|
||||||
# command = f'rm -rf {self.tempPath}'
|
command = f'rm -rf {self.tempPath}'
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
#
|
|
||||||
# if result == 0:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
|
|
||||||
#################################################################
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# VHuser = wpsite.owner.externalApp
|
|
||||||
# PhpVersion = wpsite.owner.phpSelection
|
|
||||||
# newWPpath = wpsite.path
|
|
||||||
# newurl = wpsite.FinalURL
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# #### Check If sub dir in old web site
|
|
||||||
# try:
|
|
||||||
# oldpath = config['WPsitepath']
|
|
||||||
# abc = oldpath.split("/")
|
|
||||||
# pathexta = abc[4]
|
|
||||||
# if pathexta != "":
|
|
||||||
# oldhome = "0"
|
|
||||||
# else:
|
|
||||||
# oldhome = "1"
|
|
||||||
# except BaseException as msg:
|
|
||||||
# oldhome = "1"
|
|
||||||
#
|
|
||||||
# ### get WPsite Database name and usr
|
|
||||||
# php = PHPManager.getPHPString(PhpVersion)
|
|
||||||
# FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# ######Get DBname
|
|
||||||
# command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config get DB_NAME --skip-plugins --skip-themes --path=%s' % (VHuser, FinalPHPPath, newWPpath)
|
|
||||||
#
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if stdout.find('Error:') > -1:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
# else:
|
|
||||||
# Finaldbname = stdout.rstrip("\n")
|
|
||||||
#
|
|
||||||
# ######Get DBuser
|
|
||||||
# command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config get DB_USER --skip-plugins --skip-themes --path=%s' % (VHuser, FinalPHPPath, newWPpath)
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if stdout.find('Error:') > -1:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
# else:
|
|
||||||
# Finaldbuser = stdout.rstrip("\n")
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# #####Get DBpsswd
|
|
||||||
# command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config get DB_PASSWORD --skip-plugins --skip-themes --path=%s' % (VHuser, FinalPHPPath, newWPpath)
|
|
||||||
#
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if stdout.find('Error:') > -1:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
# else:
|
|
||||||
# Finaldbpasswd = stdout.rstrip("\n")
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# ### Create secure folder
|
|
||||||
#
|
|
||||||
# ACLManager.CreateSecureDir()
|
|
||||||
# RandomPath = str(randint(1000, 9999))
|
|
||||||
# self.tempPath = '%s/%s' % ('/usr/local/CyberCP/tmp', RandomPath)
|
|
||||||
#
|
|
||||||
# command = f'mkdir -p {self.tempPath}'
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if result == 0:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
#
|
|
||||||
# command = f'chown -R {wpsite.owner.externalApp}:{wpsite.owner.externalApp} {self.tempPath}'
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if result == 0:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
#
|
|
||||||
# logging.statusWriter(self.tempStatusPath, 'Extracting Backup File...,30')
|
|
||||||
#
|
|
||||||
# ###First copy backup file to temp and then Unzip
|
|
||||||
# command = "sudo -u %s cp -R /home/backup/%s* %s" % (VHuser, BackUpFileName, self.tempPath)
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if result == 0:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
#
|
|
||||||
# #### Make temp dir ab for unzip
|
|
||||||
# command ="sudo -u %s mkdir %s/ab"%(VHuser,self.tempPath)
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if result == 0:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
#
|
|
||||||
# command = "sudo -u %s tar -xvf %s/%s.tar.gz -C %s/ab" % (VHuser, self.tempPath, BackUpFileName, self.tempPath)
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if result == 0:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
#
|
|
||||||
# logging.writeToFile("oldhome......%s"%oldhome)
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# logging.statusWriter(self.tempStatusPath, 'Copying Data File...,50')
|
|
||||||
# ###Copy backup content to newsite
|
|
||||||
# if oldhome == "0":
|
|
||||||
# #### Check If sub dir in New web site
|
|
||||||
# try:
|
|
||||||
# kl = newWPpath.split("/")
|
|
||||||
# newpathexta = kl[4]
|
|
||||||
# if newpathexta != "":
|
|
||||||
# newsubdir = "0"
|
|
||||||
# else:
|
|
||||||
# newsubdir = "1"
|
|
||||||
# except BaseException as msg:
|
|
||||||
# newsubdir = "1"
|
|
||||||
#
|
|
||||||
# logging.writeToFile("newsubdir......%s" % newsubdir)
|
|
||||||
#
|
|
||||||
# if newsubdir == "0":
|
|
||||||
# unzippath = "%s/ab/usr/local/CyberCP/tmp/%s/public_html/" % (self.tempPath, oldtemppath)
|
|
||||||
# ###first split back to publich_html then mak dir and te copy
|
|
||||||
# b = newWPpath.rstrip('/')
|
|
||||||
# newwebpath = b.rstrip(newpathexta)
|
|
||||||
# command = "sudo -u %s mkdir %s%s" % (VHuser, newwebpath, pathexta)
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if result == 0:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
# Webnewpath = str(newwebpath) + str(pathexta)
|
|
||||||
#
|
|
||||||
# else:
|
|
||||||
# unzippath = "%s/ab/usr/local/CyberCP/tmp/%s/public_html/" % (self.tempPath, oldtemppath)
|
|
||||||
# ###make dir of sub folder in existing site
|
|
||||||
# command = "sudo -u %s mkdir %s%s" % (VHuser, newWPpath, pathexta)
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if result == 0:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
# Webnewpath = str(newWPpath) + str(pathexta)
|
|
||||||
#
|
|
||||||
# try:
|
|
||||||
# oldFurl = config['WPFinalURL']
|
|
||||||
# oldownerid = config['WPowner_id']
|
|
||||||
# newFurl = "%s/%s"%(wpsite.FinalURL, pathexta)
|
|
||||||
# getwpobj = WPSites.objects.get(FinalURL=newFurl)
|
|
||||||
# except:
|
|
||||||
# newFurl = "%s/%s" % (wpsite.FinalURL, pathexta)
|
|
||||||
# string = config['WPsitepath'].split("/")
|
|
||||||
# extrapathold = string[4]
|
|
||||||
# string2 = newWPpath.split("/")
|
|
||||||
# extrapathnew = string2[4]
|
|
||||||
# a = wpsite.path
|
|
||||||
# b = a.rstrip('/')
|
|
||||||
# cutpathnew = b.rstrip(extrapathnew)
|
|
||||||
# newmpath = '%s/%s'%(cutpathnew, extrapathold)
|
|
||||||
#
|
|
||||||
# DataToPass = {}
|
|
||||||
#
|
|
||||||
# DataToPass['title'] = config['WPtitle']
|
|
||||||
# DataToPass['domain'] = newFurl
|
|
||||||
# DataToPass['WPVersion'] = "6.0"
|
|
||||||
# DataToPass['adminUser'] = config['WebVHuser']
|
|
||||||
# DataToPass['Email'] = config['WebadminEmail']
|
|
||||||
# DataToPass['PasswordByPass'] = config['DatabaseUser']
|
|
||||||
# DataToPass['AutomaticUpdates'] = config['WPAutoUpdates']
|
|
||||||
# DataToPass['Plugins'] = config['WPPluginUpdates']
|
|
||||||
# DataToPass['Themes'] = config['WPThemeUpdates']
|
|
||||||
# DataToPass['websiteOwner'] = WebOwner
|
|
||||||
# DataToPass['package'] = packegs
|
|
||||||
# DataToPass['path'] = newmpath
|
|
||||||
# DataToPass['home'] = "0"
|
|
||||||
#
|
|
||||||
# try:
|
|
||||||
# website = Websites.objects.get(domain=DomainName)
|
|
||||||
# logging.statusWriter(self.tempStatusPath, 'Web Site Already Exist.[404]')
|
|
||||||
# except:
|
|
||||||
# ab = WebsiteManager()
|
|
||||||
# coreResult = ab.submitWorpressCreation(userID, DataToPass)
|
|
||||||
# coreResult1 = json.loads((coreResult).content)
|
|
||||||
# logging.writeToFile("WP Creating website result....%s" % coreResult1)
|
|
||||||
# reutrntempath = coreResult1['tempStatusPath']
|
|
||||||
# while (1):
|
|
||||||
# lastLine = open(reutrntempath, 'r').read()
|
|
||||||
# logging.writeToFile("Error WP creating lastline ....... %s" % lastLine)
|
|
||||||
# if lastLine.find('[200]') > -1:
|
|
||||||
# break
|
|
||||||
# elif lastLine.find('[404]') > -1:
|
|
||||||
# logging.statusWriter(self.tempStatusPath,
|
|
||||||
# 'Failed to WordPress: error: %s. [404]' % lastLine)
|
|
||||||
# return 0
|
|
||||||
# else:
|
|
||||||
# logging.statusWriter(self.tempStatusPath, 'Creating WordPress....,20')
|
|
||||||
# time.sleep(2)
|
|
||||||
#
|
|
||||||
# else:
|
|
||||||
# unzippath = "%s/ab/usr/local/CyberCP/tmp/%s/public_html/" % (self.tempPath, oldtemppath)
|
|
||||||
# Webnewpath = newWPpath
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# command = "sudo -u %s cp -R %s* %s" % (VHuser, unzippath, Webnewpath)
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if result == 0:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
#
|
|
||||||
# command = "sudo -u %s cp -R %s.[^.]* %s" % (VHuser, unzippath, Webnewpath)
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if result == 0:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# #dump Mysql file in unzippath path
|
|
||||||
# unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName)
|
|
||||||
# command = "mysql -u root %s < %s" % (Finaldbname, unzippath2)
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if result == 0:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
#
|
|
||||||
# logging.statusWriter(self.tempStatusPath, 'Restoreing Data Base...,70')
|
|
||||||
# #####SetUp DataBase Settings
|
|
||||||
# ##set DBName
|
|
||||||
# command = "sudo -u %s %s /usr/bin/wp config set DB_NAME %s --skip-plugins --skip-themes --path=%s" % (VHuser, FinalPHPPath, Finaldbname, newWPpath)
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if stdout.find('Error:') > -1:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
#
|
|
||||||
# ##set DBuser
|
|
||||||
# command = "sudo -u %s %s /usr/bin/wp config set DB_USER %s --skip-plugins --skip-themes --path=%s" % (VHuser, FinalPHPPath, Finaldbuser, newWPpath)
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if stdout.find('Error:') > -1:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
#
|
|
||||||
# ##set DBpasswd
|
|
||||||
# command = "sudo -u %s %s /usr/bin/wp config set DB_PASSWORD %s --skip-plugins --skip-themes --path=%s" % (VHuser, FinalPHPPath, Finaldbpasswd, newWPpath)
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if stdout.find('Error:') > -1:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
#
|
|
||||||
# logging.statusWriter(self.tempStatusPath, 'Replacing URLs...,90')
|
|
||||||
# ########Now Replace URL's
|
|
||||||
# command = 'sudo -u %s /usr/local/lsws/lsphp74/bin/php -d error_reporting=0 /usr/bin/wp search-replace --skip-plugins --skip-themes --path=%s "%s" "%s"' % (VHuser, newWPpath, oldurl, newurl)
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if stdout.find('Error:') > -1:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
#
|
|
||||||
# command = 'sudo -u %s /usr/local/lsws/lsphp74/bin/php -d error_reporting=0 /usr/bin/wp search-replace --skip-plugins --skip-themes --allow-root --path=%s "https://www.%s" "http://%s"' % (VHuser, newWPpath, newurl, newurl)
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if stdout.find('Error:') > -1:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
#
|
|
||||||
# # ##Remove temppath
|
|
||||||
# command = f'rm -rf {self.tempPath}'
|
|
||||||
# result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
|
||||||
#
|
|
||||||
# if result == 0:
|
|
||||||
# raise BaseException(stdout)
|
|
||||||
#
|
|
||||||
# ###Restart Server
|
|
||||||
#
|
|
||||||
# from plogical.installUtilities import installUtilities
|
|
||||||
# installUtilities.reStartLiteSpeed()
|
|
||||||
############## New Site
|
############## New Site
|
||||||
elif(DomainName != "" and int(self.extraArgs['DesSiteID']) == -1):
|
elif(DomainName != "" and int(self.extraArgs['DesSiteID']) == -1):
|
||||||
###############Create New WordPressSite First
|
###############Create New WordPressSite First
|
||||||
|
|||||||
@@ -1599,12 +1599,16 @@ app.controller('RestoreWPBackup', function ($scope, $http, $timeout, $window) {
|
|||||||
$scope.currentStatus = "Start Restoring WordPress..";
|
$scope.currentStatus = "Start Restoring WordPress..";
|
||||||
|
|
||||||
var Domain = $('#wprestoresubdirdomain').val()
|
var Domain = $('#wprestoresubdirdomain').val()
|
||||||
var path = $('#wprestoresubdirpath').val()
|
var path = $('#wprestoresubdirpath').val();
|
||||||
var home = "1";
|
var home = "1";
|
||||||
|
|
||||||
if (typeof path != 'undefined' || path != '') {
|
if (typeof path != 'undefined' || path != '') {
|
||||||
home = "0";
|
home = "0";
|
||||||
}
|
}
|
||||||
|
if (typeof path == 'undefined' ) {
|
||||||
|
path = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var backuptype = $('#backuptype').html();
|
var backuptype = $('#backuptype').html();
|
||||||
var data;
|
var data;
|
||||||
|
|||||||
Reference in New Issue
Block a user