mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
add error checking
This commit is contained in:
@@ -2307,16 +2307,25 @@ $parameters = array(
|
|||||||
self.tempPath = '%s/%s' % ('/usr/local/CyberCP/tmp', RandomPath)
|
self.tempPath = '%s/%s' % ('/usr/local/CyberCP/tmp', RandomPath)
|
||||||
|
|
||||||
command = f'mkdir -p {self.tempPath}'
|
command = f'mkdir -p {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
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}'
|
command = f'chown -R {wpsite.owner.externalApp}:{wpsite.owner.externalApp} {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
### Make directory for backup
|
### Make directory for backup
|
||||||
logging.statusWriter(self.tempStatusPath, 'Creating Backup Directory...,40')
|
logging.statusWriter(self.tempStatusPath, 'Creating Backup Directory...,40')
|
||||||
|
|
||||||
command = f"mkdir -p {self.tempPath}/public_html"
|
command = f"mkdir -p {self.tempPath}/public_html"
|
||||||
ProcessUtilities.executioner(command, VHuser)
|
result, stdout = ProcessUtilities.outputExecutioner(command, VHuser, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
config = {}
|
config = {}
|
||||||
config['WPtitle']=wpsite.title
|
config['WPtitle']=wpsite.title
|
||||||
@@ -2404,7 +2413,10 @@ $parameters = array(
|
|||||||
|
|
||||||
|
|
||||||
command = 'mkdir -p /home/backup/'
|
command = 'mkdir -p /home/backup/'
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
command = f"tar -czvf /home/backup/{config['name']}.tar.gz -P {self.tempPath}"
|
command = f"tar -czvf /home/backup/{config['name']}.tar.gz -P {self.tempPath}"
|
||||||
retStatus, result = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
retStatus, result = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
@@ -2420,7 +2432,10 @@ $parameters = array(
|
|||||||
backupobj.save()
|
backupobj.save()
|
||||||
|
|
||||||
command = f'rm -rf {self.tempPath}'
|
command = f'rm -rf {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Completed.[200]')
|
logging.statusWriter(self.tempStatusPath, 'Completed.[200]')
|
||||||
return 1, f"/home/backup/{config['name']}.tar.gz"
|
return 1, f"/home/backup/{config['name']}.tar.gz"
|
||||||
@@ -2434,16 +2449,25 @@ $parameters = array(
|
|||||||
self.tempPath = '%s/%s' % ('/usr/local/CyberCP/tmp', RandomPath)
|
self.tempPath = '%s/%s' % ('/usr/local/CyberCP/tmp', RandomPath)
|
||||||
|
|
||||||
command = f'mkdir -p {self.tempPath}'
|
command = f'mkdir -p {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
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}'
|
command = f'chown -R {wpsite.owner.externalApp}:{wpsite.owner.externalApp} {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
### Make directory for backup
|
### Make directory for backup
|
||||||
logging.statusWriter(self.tempStatusPath, 'Creating Backup Directory...,40')
|
logging.statusWriter(self.tempStatusPath, 'Creating Backup Directory...,40')
|
||||||
|
|
||||||
command = f"mkdir -p {self.tempPath}/public_html"
|
command = f"mkdir -p {self.tempPath}/public_html"
|
||||||
ProcessUtilities.executioner(command, VHuser)
|
result, stdout = ProcessUtilities.outputExecutioner(command, VHuser, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
config = {}
|
config = {}
|
||||||
config['WPtitle'] = wpsite.title
|
config['WPtitle'] = wpsite.title
|
||||||
@@ -2515,7 +2539,10 @@ $parameters = array(
|
|||||||
websitepath = "/home/%s" % websitedomain
|
websitepath = "/home/%s" % websitedomain
|
||||||
|
|
||||||
command = 'mkdir -p /home/backup/'
|
command = 'mkdir -p /home/backup/'
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
command = f"tar -czvf /home/backup/{config['name']}.tar.gz -P {self.tempPath}"
|
command = f"tar -czvf /home/backup/{config['name']}.tar.gz -P {self.tempPath}"
|
||||||
retStatus, result = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
retStatus, result = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
@@ -2530,7 +2557,10 @@ $parameters = array(
|
|||||||
logging.writeToFile(result)
|
logging.writeToFile(result)
|
||||||
|
|
||||||
command = f'rm -rf {self.tempPath}'
|
command = f'rm -rf {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Completed.[200]')
|
logging.statusWriter(self.tempStatusPath, 'Completed.[200]')
|
||||||
return 1, f"/home/backup/{config['name']}.tar.gz"
|
return 1, f"/home/backup/{config['name']}.tar.gz"
|
||||||
@@ -2561,10 +2591,16 @@ $parameters = array(
|
|||||||
self.tempPath = '%s/%s' % ('/usr/local/CyberCP/tmp', RandomPath)
|
self.tempPath = '%s/%s' % ('/usr/local/CyberCP/tmp', RandomPath)
|
||||||
|
|
||||||
command = f'mkdir -p {self.tempPath}'
|
command = f'mkdir -p {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
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}'
|
command = f'chown -R {wpsite.owner.externalApp}:{wpsite.owner.externalApp} {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
### Make directory for backup
|
### Make directory for backup
|
||||||
logging.statusWriter(self.tempStatusPath, 'Creating Backup Directory...,40')
|
logging.statusWriter(self.tempStatusPath, 'Creating Backup Directory...,40')
|
||||||
@@ -2632,7 +2668,10 @@ $parameters = array(
|
|||||||
FinalZipPath = '%s/%s.zip' % (websitepath, RandomPath)
|
FinalZipPath = '%s/%s.zip' % (websitepath, RandomPath)
|
||||||
|
|
||||||
command = 'mkdir -p /home/backup/'
|
command = 'mkdir -p /home/backup/'
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
command = f"tar -czvf /home/backup/{config['name']}.tar.gz -P {self.tempPath}"
|
command = f"tar -czvf /home/backup/{config['name']}.tar.gz -P {self.tempPath}"
|
||||||
retStatus, result = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
retStatus, result = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
@@ -2647,7 +2686,10 @@ $parameters = array(
|
|||||||
logging.writeToFile(result)
|
logging.writeToFile(result)
|
||||||
|
|
||||||
command = f'rm -rf {self.tempPath}'
|
command = f'rm -rf {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Completed.[200]')
|
logging.statusWriter(self.tempStatusPath, 'Completed.[200]')
|
||||||
return 1, f"/home/backup/{config['name']}.tar.gz"
|
return 1, f"/home/backup/{config['name']}.tar.gz"
|
||||||
@@ -2668,9 +2710,11 @@ $parameters = array(
|
|||||||
from managePHP.phpManager import PHPManager
|
from managePHP.phpManager import PHPManager
|
||||||
from websiteFunctions.website import WebsiteManager
|
from websiteFunctions.website import WebsiteManager
|
||||||
from packages.models import Package
|
from packages.models import Package
|
||||||
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
logging.writeToFile("Error Restore WP backup Now ....... start:%s"% self.extraArgs['Domain'])
|
logging.writeToFile("Error Restore WP backup Now ....... start:%s"% self.extraArgs['Domain'])
|
||||||
|
|
||||||
self.tempStatusPath = self.extraArgs['tempStatusPath']
|
self.tempStatusPath = self.extraArgs['tempStatusPath']
|
||||||
logging.statusWriter(self.tempStatusPath, 'Restoring BackUp...,10')
|
logging.statusWriter(self.tempStatusPath, 'Restoring backup...,10')
|
||||||
DesSiteID = self.extraArgs['DesSiteID']
|
DesSiteID = self.extraArgs['DesSiteID']
|
||||||
backupid = self.extraArgs['backupid']
|
backupid = self.extraArgs['backupid']
|
||||||
DomainName = self.extraArgs['Domain']
|
DomainName = self.extraArgs['Domain']
|
||||||
@@ -2710,20 +2754,32 @@ $parameters = array(
|
|||||||
######Get DBname
|
######Get DBname
|
||||||
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config get DB_NAME --skip-plugins --skip-themes --path=%s' % (
|
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)
|
VHuser, FinalPHPPath, newWPpath)
|
||||||
stdout = ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') == -1:
|
||||||
Finaldbname = stdout.rstrip("\n")
|
Finaldbname = stdout.rstrip("\n")
|
||||||
|
else:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
######Get DBuser
|
######Get DBuser
|
||||||
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config get DB_USER --skip-plugins --skip-themes --path=%s' % (
|
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)
|
VHuser, FinalPHPPath, newWPpath)
|
||||||
stdout = ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') == -1:
|
||||||
Finaldbuser = stdout.rstrip("\n")
|
Finaldbuser = stdout.rstrip("\n")
|
||||||
|
else:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
#####Get DBpsswd
|
#####Get DBpsswd
|
||||||
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config get DB_PASSWORD --skip-plugins --skip-themes --path=%s' % (
|
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)
|
VHuser, FinalPHPPath, newWPpath)
|
||||||
stdout = ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') == -1:
|
||||||
Finaldbpasswd = stdout.rstrip("\n")
|
Finaldbpasswd = stdout.rstrip("\n")
|
||||||
|
else:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
### Create secure folder
|
### Create secure folder
|
||||||
|
|
||||||
@@ -2732,60 +2788,97 @@ $parameters = array(
|
|||||||
self.tempPath = '%s/%s' % ('/usr/local/CyberCP/tmp', RandomPath)
|
self.tempPath = '%s/%s' % ('/usr/local/CyberCP/tmp', RandomPath)
|
||||||
|
|
||||||
command = f'mkdir -p {self.tempPath}'
|
command = f'mkdir -p {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
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}'
|
command = f'chown -R {wpsite.owner.externalApp}:{wpsite.owner.externalApp} {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Extracting Backup File...,30')
|
logging.statusWriter(self.tempStatusPath, 'Extracting Backup File...,30')
|
||||||
|
|
||||||
###First copy backup file to temp and then Unzip
|
###First copy backup file to temp and then Unzip
|
||||||
command = "sudo -u %s cp -R /home/backup/%s* %s" % (VHuser, BackUpFileName, self.tempPath)
|
command = "sudo -u %s cp -R /home/backup/%s* %s" % (VHuser, BackUpFileName, self.tempPath)
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
#### Make temp dir ab for unzip
|
#### Make temp dir ab for unzip
|
||||||
command = "sudo -u %s mkdir %s/ab" % (VHuser, self.tempPath)
|
command = "sudo -u %s mkdir %s/ab" % (VHuser, self.tempPath)
|
||||||
ProcessUtilities.executioner(command)
|
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" % (
|
command = "sudo -u %s tar -xvf %s/%s.tar.gz -C %s/ab" % (
|
||||||
VHuser, self.tempPath, BackUpFileName, self.tempPath)
|
VHuser, self.tempPath, BackUpFileName, self.tempPath)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
# dump Mysql file in unzippath path
|
# dump Mysql file in unzippath path
|
||||||
unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName)
|
unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName)
|
||||||
command = "mysql -u root %s < %s" % (Finaldbname, unzippath2)
|
command = "mysql -u root %s < %s" % (Finaldbname, unzippath2)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Restoreing Data Base...,70')
|
logging.statusWriter(self.tempStatusPath, 'Restoreing Data Base...,70')
|
||||||
#####SetUp DataBase Settings
|
#####SetUp DataBase Settings
|
||||||
##set DBName
|
##set DBName
|
||||||
command = "sudo -u %s %s /usr/bin/wp config set DB_NAME %s --skip-plugins --skip-themes --path=%s" % (
|
command = "sudo -u %s %s /usr/bin/wp config set DB_NAME %s --skip-plugins --skip-themes --path=%s" % (
|
||||||
VHuser, FinalPHPPath, Finaldbname, newWPpath)
|
VHuser, FinalPHPPath, Finaldbname, newWPpath)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
##set DBuser
|
##set DBuser
|
||||||
command = "sudo -u %s %s /usr/bin/wp config set DB_USER %s --skip-plugins --skip-themes --path=%s" % (
|
command = "sudo -u %s %s /usr/bin/wp config set DB_USER %s --skip-plugins --skip-themes --path=%s" % (
|
||||||
VHuser, FinalPHPPath, Finaldbuser, newWPpath)
|
VHuser, FinalPHPPath, Finaldbuser, newWPpath)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
|
||||||
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
##set DBpasswd
|
##set DBpasswd
|
||||||
command = "sudo -u %s %s /usr/bin/wp config set DB_PASSWORD %s --skip-plugins --skip-themes --path=%s" % (
|
command = "sudo -u %s %s /usr/bin/wp config set DB_PASSWORD %s --skip-plugins --skip-themes --path=%s" % (
|
||||||
VHuser, FinalPHPPath, Finaldbpasswd, newWPpath)
|
VHuser, FinalPHPPath, Finaldbpasswd, newWPpath)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
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, newurl)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
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"' % (
|
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, newurl, newurl)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
# ##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)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
###Restart Server
|
###Restart Server
|
||||||
|
|
||||||
@@ -2819,24 +2912,39 @@ $parameters = array(
|
|||||||
self.tempPath = '%s/%s' % ('/usr/local/CyberCP/tmp', RandomPath)
|
self.tempPath = '%s/%s' % ('/usr/local/CyberCP/tmp', RandomPath)
|
||||||
|
|
||||||
command = f'mkdir -p {self.tempPath}'
|
command = f'mkdir -p {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
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}'
|
command = f'chown -R {wpsite.owner.externalApp}:{wpsite.owner.externalApp} {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Extracting Backup File...,30')
|
logging.statusWriter(self.tempStatusPath, 'Extracting Backup File...,30')
|
||||||
|
|
||||||
###First copy backup file to temp and then Unzip
|
###First copy backup file to temp and then Unzip
|
||||||
command = "sudo -u %s cp -R /home/backup/%s* %s" % (VHuser, BackUpFileName, self.tempPath)
|
command = "sudo -u %s cp -R /home/backup/%s* %s" % (VHuser, BackUpFileName, self.tempPath)
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
#### Make temp dir ab for unzip
|
#### Make temp dir ab for unzip
|
||||||
command = "sudo -u %s mkdir %s/ab" % (VHuser, self.tempPath)
|
command = "sudo -u %s mkdir %s/ab" % (VHuser, self.tempPath)
|
||||||
ProcessUtilities.executioner(command)
|
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" % (
|
command = "sudo -u %s tar -xvf %s/%s.tar.gz -C %s/ab" % (
|
||||||
VHuser, self.tempPath, BackUpFileName, self.tempPath)
|
VHuser, self.tempPath, BackUpFileName, self.tempPath)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Copying Data File...,50')
|
logging.statusWriter(self.tempStatusPath, 'Copying Data File...,50')
|
||||||
###Copy backup content to newsite
|
###Copy backup content to newsite
|
||||||
@@ -2858,14 +2966,20 @@ $parameters = array(
|
|||||||
b = newWPpath.rstrip('/')
|
b = newWPpath.rstrip('/')
|
||||||
newwebpath = b.rstrip(newpathexta)
|
newwebpath = b.rstrip(newpathexta)
|
||||||
command = "sudo -u %s mkdir %s%s" % (VHuser, newwebpath, pathexta)
|
command = "sudo -u %s mkdir %s%s" % (VHuser, newwebpath, pathexta)
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
Webnewpath = str(newwebpath) + str(pathexta)
|
Webnewpath = str(newwebpath) + str(pathexta)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
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)
|
||||||
###make dir of sub folder in existing site
|
###make dir of sub folder in existing site
|
||||||
command = "sudo -u %s mkdir %s%s" % (VHuser, newWPpath, pathexta)
|
command = "sudo -u %s mkdir %s%s" % (VHuser, newWPpath, pathexta)
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
Webnewpath = str(newWPpath) + str(pathexta)
|
Webnewpath = str(newWPpath) + str(pathexta)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -2874,22 +2988,32 @@ $parameters = array(
|
|||||||
Webnewpath = newWPpath
|
Webnewpath = newWPpath
|
||||||
|
|
||||||
command = "sudo -u %s cp -R %s* %s" % (VHuser, unzippath, Webnewpath)
|
command = "sudo -u %s cp -R %s* %s" % (VHuser, unzippath, Webnewpath)
|
||||||
result = ProcessUtilities.outputExecutioner(command)
|
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)
|
command = "sudo -u %s cp -R %s.[^.]* %s" % (VHuser, unzippath, Webnewpath)
|
||||||
result = ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
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, newurl)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
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"' % (
|
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, newurl, newurl)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
# ##Remove temppath
|
# ##Remove temppath
|
||||||
command = f'rm -rf {self.tempPath}'
|
command = f'rm -rf {self.tempPath}'
|
||||||
@@ -2968,24 +3092,39 @@ $parameters = array(
|
|||||||
self.tempPath = '%s/%s' % ('/usr/local/CyberCP/tmp', RandomPath)
|
self.tempPath = '%s/%s' % ('/usr/local/CyberCP/tmp', RandomPath)
|
||||||
|
|
||||||
command = f'mkdir -p {self.tempPath}'
|
command = f'mkdir -p {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
command = f'chown -R {NewWPsite.owner.externalApp}:{NewWPsite.owner.externalApp} {self.tempPath}'
|
command = f'chown -R {NewWPsite.owner.externalApp}:{NewWPsite.owner.externalApp} {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Extracting Backup File...,40')
|
logging.statusWriter(self.tempStatusPath, 'Extracting Backup File...,40')
|
||||||
|
|
||||||
###First copy backup file to temp and then Unzip
|
###First copy backup file to temp and then Unzip
|
||||||
command = "sudo -u %s cp -R /home/backup/%s* %s" % (VHuser, BackUpFileName, self.tempPath)
|
command = "sudo -u %s cp -R /home/backup/%s* %s" % (VHuser, BackUpFileName, self.tempPath)
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
#### Make temp dir ab for unzip
|
#### Make temp dir ab for unzip
|
||||||
command = "sudo -u %s mkdir %s/ab" % (VHuser, self.tempPath)
|
command = "sudo -u %s mkdir %s/ab" % (VHuser, self.tempPath)
|
||||||
ProcessUtilities.executioner(command)
|
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" % (
|
command = "sudo -u %s tar -xvf %s/%s.tar.gz -C %s/ab" % (
|
||||||
VHuser, self.tempPath, BackUpFileName, self.tempPath)
|
VHuser, self.tempPath, BackUpFileName, self.tempPath)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
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
|
||||||
@@ -2996,10 +3135,16 @@ $parameters = array(
|
|||||||
self.tempPath, oldtemppath)
|
self.tempPath, oldtemppath)
|
||||||
|
|
||||||
command = "sudo -u %s cp -R %s* %s" % (VHuser, unzippath, newWPpath)
|
command = "sudo -u %s cp -R %s* %s" % (VHuser, unzippath, newWPpath)
|
||||||
result = ProcessUtilities.outputExecutioner(command)
|
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, newWPpath)
|
command = "sudo -u %s cp -R %s.[^.]* %s" % (VHuser, unzippath, newWPpath)
|
||||||
result = ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -3007,15 +3152,24 @@ $parameters = array(
|
|||||||
########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, newurl)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
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"' % (
|
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, newurl, newurl)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
##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)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
###Restart Server
|
###Restart Server
|
||||||
|
|
||||||
@@ -3044,9 +3198,6 @@ $parameters = array(
|
|||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
home = "1"
|
home = "1"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### get WPsite Database name and usr
|
### get WPsite Database name and usr
|
||||||
php = PHPManager.getPHPString(PhpVersion)
|
php = PHPManager.getPHPString(PhpVersion)
|
||||||
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
|
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
|
||||||
@@ -3054,18 +3205,34 @@ $parameters = array(
|
|||||||
|
|
||||||
######Get DBname
|
######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)
|
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)
|
||||||
stdout = ProcessUtilities.outputExecutioner(command)
|
|
||||||
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
else:
|
||||||
Finaldbname = stdout.rstrip("\n")
|
Finaldbname = stdout.rstrip("\n")
|
||||||
|
|
||||||
######Get DBuser
|
######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)
|
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)
|
||||||
stdout = ProcessUtilities.outputExecutioner(command)
|
|
||||||
|
|
||||||
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
else:
|
||||||
Finaldbuser = stdout.rstrip("\n")
|
Finaldbuser = stdout.rstrip("\n")
|
||||||
|
|
||||||
|
|
||||||
#####Get DBpsswd
|
#####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)
|
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)
|
||||||
stdout = ProcessUtilities.outputExecutioner(command)
|
|
||||||
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
else:
|
||||||
Finaldbpasswd = stdout.rstrip("\n")
|
Finaldbpasswd = stdout.rstrip("\n")
|
||||||
|
|
||||||
|
|
||||||
@@ -3076,24 +3243,38 @@ $parameters = array(
|
|||||||
self.tempPath = '%s/%s' % ('/usr/local/CyberCP/tmp', RandomPath)
|
self.tempPath = '%s/%s' % ('/usr/local/CyberCP/tmp', RandomPath)
|
||||||
|
|
||||||
command = f'mkdir -p {self.tempPath}'
|
command = f'mkdir -p {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
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}'
|
command = f'chown -R {wpsite.owner.externalApp}:{wpsite.owner.externalApp} {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Extracting Backup File...,30')
|
logging.statusWriter(self.tempStatusPath, 'Extracting Backup File...,30')
|
||||||
|
|
||||||
###First copy backup file to temp and then Unzip
|
###First copy backup file to temp and then Unzip
|
||||||
command = "sudo -u %s cp -R /home/backup/%s* %s" % (VHuser, BackUpFileName, self.tempPath)
|
command = "sudo -u %s cp -R /home/backup/%s* %s" % (VHuser, BackUpFileName, self.tempPath)
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
#### Make temp dir ab for unzip
|
#### Make temp dir ab for unzip
|
||||||
command ="sudo -u %s mkdir %s/ab"%(VHuser,self.tempPath)
|
command ="sudo -u %s mkdir %s/ab"%(VHuser,self.tempPath)
|
||||||
ProcessUtilities.executioner(command)
|
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)
|
command = "sudo -u %s tar -xvf %s/%s.tar.gz -C %s/ab" % (VHuser, self.tempPath, BackUpFileName, self.tempPath)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Copying Data File...,50')
|
logging.statusWriter(self.tempStatusPath, 'Copying Data File...,50')
|
||||||
@@ -3116,14 +3297,20 @@ $parameters = array(
|
|||||||
b = newWPpath.rstrip('/')
|
b = newWPpath.rstrip('/')
|
||||||
newwebpath = b.rstrip(newpathexta)
|
newwebpath = b.rstrip(newpathexta)
|
||||||
command = "sudo -u %s mkdir %s%s" % (VHuser, newwebpath, pathexta)
|
command = "sudo -u %s mkdir %s%s" % (VHuser, newwebpath, pathexta)
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
Webnewpath = str(newwebpath) + str(pathexta)
|
Webnewpath = str(newwebpath) + str(pathexta)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
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)
|
||||||
###make dir of sub folder in existing site
|
###make dir of sub folder in existing site
|
||||||
command = "sudo -u %s mkdir %s%s" % (VHuser, newWPpath, pathexta)
|
command = "sudo -u %s mkdir %s%s" % (VHuser, newWPpath, pathexta)
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
Webnewpath = str(newWPpath) + str(pathexta)
|
Webnewpath = str(newWPpath) + str(pathexta)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -3133,42 +3320,69 @@ $parameters = array(
|
|||||||
|
|
||||||
|
|
||||||
command = "sudo -u %s cp -R %s* %s" % (VHuser, unzippath, Webnewpath)
|
command = "sudo -u %s cp -R %s* %s" % (VHuser, unzippath, Webnewpath)
|
||||||
result = ProcessUtilities.outputExecutioner(command)
|
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)
|
command = "sudo -u %s cp -R %s.[^.]* %s" % (VHuser, unzippath, Webnewpath)
|
||||||
result = ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
|
|
||||||
#dump Mysql file in unzippath path
|
#dump Mysql file in unzippath path
|
||||||
unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName)
|
unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName)
|
||||||
command = "mysql -u root %s < %s" % (Finaldbname, unzippath2)
|
command = "mysql -u root %s < %s" % (Finaldbname, unzippath2)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Restoreing Data Base...,70')
|
logging.statusWriter(self.tempStatusPath, 'Restoreing Data Base...,70')
|
||||||
#####SetUp DataBase Settings
|
#####SetUp DataBase Settings
|
||||||
##set DBName
|
##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)
|
command = "sudo -u %s %s /usr/bin/wp config set DB_NAME %s --skip-plugins --skip-themes --path=%s" % (VHuser, FinalPHPPath, Finaldbname, newWPpath)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
##set DBuser
|
##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)
|
command = "sudo -u %s %s /usr/bin/wp config set DB_USER %s --skip-plugins --skip-themes --path=%s" % (VHuser, FinalPHPPath, Finaldbuser, newWPpath)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
##set DBpasswd
|
##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)
|
command = "sudo -u %s %s /usr/bin/wp config set DB_PASSWORD %s --skip-plugins --skip-themes --path=%s" % (VHuser, FinalPHPPath, Finaldbpasswd, newWPpath)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
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"' % (VHuser, newWPpath, oldurl, newurl)
|
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)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
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)
|
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)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
# ##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)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
###Restart Server
|
###Restart Server
|
||||||
|
|
||||||
@@ -3247,19 +3461,34 @@ $parameters = array(
|
|||||||
######Get DBname
|
######Get DBname
|
||||||
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config get DB_NAME --skip-plugins --skip-themes --path=%s' % (
|
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)
|
VHuser, FinalPHPPath, newWPpath)
|
||||||
stdout = ProcessUtilities.outputExecutioner(command)
|
|
||||||
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
else:
|
||||||
Finaldbname = stdout.rstrip("\n")
|
Finaldbname = stdout.rstrip("\n")
|
||||||
|
|
||||||
######Get DBuser
|
######Get DBuser
|
||||||
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config get DB_USER --skip-plugins --skip-themes --path=%s' % (
|
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)
|
VHuser, FinalPHPPath, newWPpath)
|
||||||
stdout = ProcessUtilities.outputExecutioner(command)
|
|
||||||
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
else:
|
||||||
Finaldbuser = stdout.rstrip("\n")
|
Finaldbuser = stdout.rstrip("\n")
|
||||||
|
|
||||||
#####Get DBpsswd
|
#####Get DBpsswd
|
||||||
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config get DB_PASSWORD --skip-plugins --skip-themes --path=%s' % (
|
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)
|
VHuser, FinalPHPPath, newWPpath)
|
||||||
stdout = ProcessUtilities.outputExecutioner(command)
|
|
||||||
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
else:
|
||||||
Finaldbpasswd = stdout.rstrip("\n")
|
Finaldbpasswd = stdout.rstrip("\n")
|
||||||
|
|
||||||
### Create secure folder
|
### Create secure folder
|
||||||
@@ -3269,24 +3498,39 @@ $parameters = array(
|
|||||||
self.tempPath = '%s/%s' % ('/usr/local/CyberCP/tmp', RandomPath)
|
self.tempPath = '%s/%s' % ('/usr/local/CyberCP/tmp', RandomPath)
|
||||||
|
|
||||||
command = f'mkdir -p {self.tempPath}'
|
command = f'mkdir -p {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
command = f'chown -R {NewWPsite.owner.externalApp}:{NewWPsite.owner.externalApp} {self.tempPath}'
|
command = f'chown -R {NewWPsite.owner.externalApp}:{NewWPsite.owner.externalApp} {self.tempPath}'
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Extracting Backup File...,40')
|
logging.statusWriter(self.tempStatusPath, 'Extracting Backup File...,40')
|
||||||
|
|
||||||
###First copy backup file to temp and then Unzip
|
###First copy backup file to temp and then Unzip
|
||||||
command = "sudo -u %s cp -R /home/backup/%s* %s" % (VHuser, BackUpFileName, self.tempPath)
|
command = "sudo -u %s cp -R /home/backup/%s* %s" % (VHuser, BackUpFileName, self.tempPath)
|
||||||
ProcessUtilities.executioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
#### Make temp dir ab for unzip
|
#### Make temp dir ab for unzip
|
||||||
command = "sudo -u %s mkdir %s/ab" % (VHuser, self.tempPath)
|
command = "sudo -u %s mkdir %s/ab" % (VHuser, self.tempPath)
|
||||||
ProcessUtilities.executioner(command)
|
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" % (
|
command = "sudo -u %s tar -xvf %s/%s.tar.gz -C %s/ab" % (
|
||||||
VHuser, self.tempPath, BackUpFileName, self.tempPath)
|
VHuser, self.tempPath, BackUpFileName, self.tempPath)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Copying Data File...,60')
|
logging.statusWriter(self.tempStatusPath, 'Copying Data File...,60')
|
||||||
@@ -3297,47 +3541,74 @@ $parameters = array(
|
|||||||
unzippath = "%s/ab/usr/local/CyberCP/tmp/%s/public_html/public_html/" % (self.tempPath, oldtemppath)
|
unzippath = "%s/ab/usr/local/CyberCP/tmp/%s/public_html/public_html/" % (self.tempPath, oldtemppath)
|
||||||
|
|
||||||
command = "sudo -u %s cp -R %s* %s" % (VHuser, unzippath, newWPpath)
|
command = "sudo -u %s cp -R %s* %s" % (VHuser, unzippath, newWPpath)
|
||||||
result = ProcessUtilities.outputExecutioner(command)
|
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, newWPpath)
|
command = "sudo -u %s cp -R %s.[^.]* %s" % (VHuser, unzippath, newWPpath)
|
||||||
result = ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if result == 0:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
# dump Mysql file in unzippath path
|
# dump Mysql file in unzippath path
|
||||||
unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName)
|
unzippath2 = "%s/ab/usr/local/CyberCP/tmp/%s/%s" % (self.tempPath, oldtemppath, DumpFileName)
|
||||||
command = "mysql -u root %s < %s" % (Finaldbname, unzippath2)
|
command = "mysql -u root %s < %s" % (Finaldbname, unzippath2)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
logging.statusWriter(self.tempStatusPath, 'Restoreing Data Base...,80')
|
logging.statusWriter(self.tempStatusPath, 'Restoreing Data Base...,80')
|
||||||
#####SetUp DataBase Settings
|
#####SetUp DataBase Settings
|
||||||
##set DBName
|
##set DBName
|
||||||
command = "sudo -u %s %s /usr/bin/wp config set DB_NAME %s --skip-plugins --skip-themes --path=%s" % (
|
command = "sudo -u %s %s /usr/bin/wp config set DB_NAME %s --skip-plugins --skip-themes --path=%s" % (
|
||||||
VHuser, FinalPHPPath, Finaldbname, newWPpath)
|
VHuser, FinalPHPPath, Finaldbname, newWPpath)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
##set DBuser
|
##set DBuser
|
||||||
command = "sudo -u %s %s /usr/bin/wp config set DB_USER %s --skip-plugins --skip-themes --path=%s" % (
|
command = "sudo -u %s %s /usr/bin/wp config set DB_USER %s --skip-plugins --skip-themes --path=%s" % (
|
||||||
VHuser, FinalPHPPath, Finaldbuser, newWPpath)
|
VHuser, FinalPHPPath, Finaldbuser, newWPpath)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
##set DBpasswd
|
##set DBpasswd
|
||||||
command = "sudo -u %s %s /usr/bin/wp config set DB_PASSWORD %s --skip-plugins --skip-themes --path=%s" % (
|
command = "sudo -u %s %s /usr/bin/wp config set DB_PASSWORD %s --skip-plugins --skip-themes --path=%s" % (
|
||||||
VHuser, FinalPHPPath, Finaldbpasswd, newWPpath)
|
VHuser, FinalPHPPath, Finaldbpasswd, newWPpath)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
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, newurl)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
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"' % (
|
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, newurl, newurl)
|
||||||
ProcessUtilities.outputExecutioner(command)
|
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
##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)
|
||||||
|
|
||||||
|
if stdout.find('Error:') > -1:
|
||||||
|
raise BaseException(stdout)
|
||||||
|
|
||||||
###Restart Server
|
###Restart Server
|
||||||
|
|
||||||
|
|||||||
@@ -165,11 +165,11 @@ class WebsiteManager:
|
|||||||
currentACL = ACLManager.loadedACL(userID)
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
admin = Administrator.objects.get(pk=userID)
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
|
||||||
backobj = WPSitesBackup.objects.filter(owner=admin)
|
backobj = WPSitesBackup.objects.filter(owner=admin).order_by('-id')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if DeleteID != None:
|
if DeleteID != None:
|
||||||
DeleteIDobj = WPSitesBackup.objects.get(pk=DeleteID)
|
DeleteIDobj = WPSitesBackup.objects.get(pk=DeleteID, owner=admin)
|
||||||
config = DeleteIDobj.config
|
config = DeleteIDobj.config
|
||||||
conf = json.loads(config)
|
conf = json.loads(config)
|
||||||
FileName = conf['name']
|
FileName = conf['name']
|
||||||
|
|||||||
Reference in New Issue
Block a user