mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-10 15:26:13 +01:00
bug fix to backups and manage services
This commit is contained in:
@@ -46,6 +46,8 @@ urlpatterns = [
|
|||||||
|
|
||||||
url(r'^cancelRemoteBackup', views.cancelRemoteBackup, name='cancelRemoteBackup'),
|
url(r'^cancelRemoteBackup', views.cancelRemoteBackup, name='cancelRemoteBackup'),
|
||||||
|
|
||||||
|
url(r'^localInitiate$', views.localInitiate, name='localInitiate'),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ from django.shortcuts import redirect
|
|||||||
from backup.backupManager import BackupManager
|
from backup.backupManager import BackupManager
|
||||||
from backup.pluginManager import pluginManager
|
from backup.pluginManager import pluginManager
|
||||||
from loginSystem.views import loadLoginPage
|
from loginSystem.views import loadLoginPage
|
||||||
|
import os
|
||||||
|
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||||
|
from django.shortcuts import HttpResponse
|
||||||
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
|
||||||
def loadBackupHome(request):
|
def loadBackupHome(request):
|
||||||
try:
|
try:
|
||||||
@@ -45,7 +48,6 @@ def getCurrentBackups(request):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def submitBackupCreation(request):
|
def submitBackupCreation(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -59,8 +61,8 @@ def submitBackupCreation(request):
|
|||||||
|
|
||||||
return coreResult
|
return coreResult
|
||||||
|
|
||||||
except KeyError:
|
except BaseException, msg:
|
||||||
return redirect(loadLoginPage)
|
logging.writeToFile(str(msg))
|
||||||
|
|
||||||
|
|
||||||
def backupStatus(request):
|
def backupStatus(request):
|
||||||
@@ -324,3 +326,16 @@ def cancelRemoteBackup(request):
|
|||||||
return wm.cancelRemoteBackup(userID, json.loads(request.body))
|
return wm.cancelRemoteBackup(userID, json.loads(request.body))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
|
@csrf_exempt
|
||||||
|
def localInitiate(request):
|
||||||
|
try:
|
||||||
|
data = json.loads(request.body)
|
||||||
|
randomFile = data['randomFile']
|
||||||
|
|
||||||
|
if os.path.exists(randomFile):
|
||||||
|
wm = BackupManager()
|
||||||
|
return wm.submitBackupCreation(1, json.loads(request.body))
|
||||||
|
except BaseException, msg:
|
||||||
|
logging.writeToFile(str(msg))
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ from plogical.mailUtilities import mailUtilities
|
|||||||
from plogical.ftpUtilities import FTPUtilities
|
from plogical.ftpUtilities import FTPUtilities
|
||||||
from plogical.sslUtilities import sslUtilities
|
from plogical.sslUtilities import sslUtilities
|
||||||
from plogical.processUtilities import ProcessUtilities
|
from plogical.processUtilities import ProcessUtilities
|
||||||
|
from plogical.backupSchedule import backupSchedule
|
||||||
|
|
||||||
# All that we see or seem is but a dream within a dream.
|
# All that we see or seem is but a dream within a dream.
|
||||||
|
|
||||||
@@ -323,37 +324,11 @@ class cyberPanel:
|
|||||||
|
|
||||||
def createBackup(self, virtualHostName):
|
def createBackup(self, virtualHostName):
|
||||||
try:
|
try:
|
||||||
website = Websites.objects.get(domain=virtualHostName)
|
backupLogPath = "/usr/local/lscp/logs/backup_log."+time.strftime("%I-%M-%S-%a-%b-%Y")
|
||||||
|
|
||||||
## defining paths
|
print 'Backup logs to be generated in %s' % (backupLogPath)
|
||||||
|
|
||||||
## /home/example.com/backup
|
|
||||||
backupPath = os.path.join("/home", virtualHostName, "backup/")
|
|
||||||
domainUser = website.externalApp
|
|
||||||
backupName = 'backup-' + domainUser + "-" + time.strftime("%I-%M-%S-%a-%b-%Y")
|
|
||||||
|
|
||||||
## /home/example.com/backup/backup-example-06-50-03-Thu-Feb-2018
|
|
||||||
tempStoragePath = os.path.join(backupPath, backupName)
|
|
||||||
|
|
||||||
backupUtilities.submitBackupCreation(tempStoragePath, backupName, backupPath, virtualHostName)
|
|
||||||
|
|
||||||
finalData = json.dumps({'websiteToBeBacked': virtualHostName})
|
|
||||||
|
|
||||||
while (1):
|
|
||||||
r = requests.post("http://localhost:5003/backup/backupStatus", data=finalData)
|
|
||||||
time.sleep(2)
|
|
||||||
data = json.loads(r.text)
|
|
||||||
|
|
||||||
if data['backupStatus'] == 0:
|
|
||||||
print 'Failed to generate backup, Error message : ' + data['error_message'] + '\n'
|
|
||||||
break
|
|
||||||
elif data['abort'] == 1:
|
|
||||||
print 'Backup successfully generated.\n'
|
|
||||||
print 'File Location: ' + tempStoragePath + ".tar.gz\n"
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
print 'Waiting for backup to complete. Current status: ' + data['status']
|
|
||||||
|
|
||||||
|
backupSchedule.createLocalBackup(virtualHostName, backupLogPath)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
logger.writeforCLI(str(msg), "Error", stack()[0][3])
|
logger.writeforCLI(str(msg), "Error", stack()[0][3])
|
||||||
|
|||||||
@@ -191,6 +191,8 @@ def saveStatus(request):
|
|||||||
slaveServer.save()
|
slaveServer.save()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
pdns.save()
|
||||||
|
|
||||||
if data['dnsMode'] != 'Default':
|
if data['dnsMode'] != 'Default':
|
||||||
data['type'] = data['dnsMode']
|
data['type'] = data['dnsMode']
|
||||||
|
|||||||
@@ -13,10 +13,11 @@ import time
|
|||||||
from backupUtilities import backupUtilities
|
from backupUtilities import backupUtilities
|
||||||
from re import match,I,M
|
from re import match,I,M
|
||||||
from websiteFunctions.models import Websites, Backups
|
from websiteFunctions.models import Websites, Backups
|
||||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
|
||||||
from plogical.processUtilities import ProcessUtilities
|
from plogical.processUtilities import ProcessUtilities
|
||||||
from multiprocessing import Process
|
from multiprocessing import Process
|
||||||
import plogical.backupUtilities as backupUtil
|
import plogical.backupUtilities as backupUtil
|
||||||
|
from random import randint
|
||||||
|
import json, requests
|
||||||
|
|
||||||
class backupSchedule:
|
class backupSchedule:
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ class backupSchedule:
|
|||||||
try:
|
try:
|
||||||
file = open(fileName,'a')
|
file = open(fileName,'a')
|
||||||
file.writelines("[" + time.strftime("%I-%M-%S-%a-%b-%Y") + "] "+ message + "\n")
|
file.writelines("[" + time.strftime("%I-%M-%S-%a-%b-%Y") + "] "+ message + "\n")
|
||||||
|
print ("[" + time.strftime("%I-%M-%S-%a-%b-%Y") + "] "+ message + "\n")
|
||||||
file.close()
|
file.close()
|
||||||
except IOError,msg:
|
except IOError,msg:
|
||||||
return "Can not write to error file."
|
return "Can not write to error file."
|
||||||
@@ -34,28 +36,22 @@ class backupSchedule:
|
|||||||
try:
|
try:
|
||||||
|
|
||||||
backupSchedule.remoteBackupLogging(backupLogPath, "Starting local backup for: " + virtualHost)
|
backupSchedule.remoteBackupLogging(backupLogPath, "Starting local backup for: " + virtualHost)
|
||||||
website = Websites.objects.get(domain=virtualHost)
|
|
||||||
# defining paths
|
|
||||||
|
|
||||||
## /home/example.com/backup
|
###
|
||||||
backupPath = os.path.join("/home", virtualHost, "backup/")
|
|
||||||
domainUser = website.externalApp
|
|
||||||
backupName = 'backup-' + domainUser + "-" + time.strftime("%I-%M-%S-%a-%b-%Y")
|
|
||||||
|
|
||||||
## /home/example.com/backup/backup-example-06-50-03-Thu-Feb-2018
|
pathToFile = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||||
tempStoragePath = os.path.join(backupPath, backupName)
|
file = open(pathToFile, "w+")
|
||||||
|
file.close()
|
||||||
|
|
||||||
p = Process(target=backupUtil.submitBackupCreation,
|
finalData = json.dumps({'randomFile': pathToFile, 'websiteToBeBacked': virtualHost})
|
||||||
args=(tempStoragePath, backupName, backupPath, virtualHost))
|
r = requests.post("https://localhost:8090/backup/localInitiate", data=finalData, verify=False)
|
||||||
p.start()
|
|
||||||
|
|
||||||
time.sleep(2)
|
data = json.loads(r.text)
|
||||||
|
tempStoragePath = data['tempStorage']
|
||||||
|
|
||||||
backupSchedule.remoteBackupLogging(backupLogPath, "Waiting for backup to complete.. ")
|
backupSchedule.remoteBackupLogging(backupLogPath, "Waiting for backup to complete.. ")
|
||||||
|
|
||||||
|
|
||||||
while (1):
|
while (1):
|
||||||
|
|
||||||
backupDomain = virtualHost
|
backupDomain = virtualHost
|
||||||
status = os.path.join("/home", backupDomain, "backup/status")
|
status = os.path.join("/home", backupDomain, "backup/status")
|
||||||
backupFileNamePath = os.path.join("/home", backupDomain, "backup/backupFileName")
|
backupFileNamePath = os.path.join("/home", backupDomain, "backup/backupFileName")
|
||||||
@@ -71,6 +67,8 @@ class backupSchedule:
|
|||||||
|
|
||||||
if os.path.exists(status):
|
if os.path.exists(status):
|
||||||
status = open(status, 'r').read()
|
status = open(status, 'r').read()
|
||||||
|
print status
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
if status.find("Completed") > -1:
|
if status.find("Completed") > -1:
|
||||||
|
|
||||||
@@ -86,9 +84,12 @@ class backupSchedule:
|
|||||||
ProcessUtilities.normalExecutioner(command)
|
ProcessUtilities.normalExecutioner(command)
|
||||||
|
|
||||||
backupSchedule.remoteBackupLogging(backupLogPath, "Backup Completed for: " + virtualHost)
|
backupSchedule.remoteBackupLogging(backupLogPath, "Backup Completed for: " + virtualHost)
|
||||||
|
try:
|
||||||
|
os.remove(pathToFile)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
return 1, tempStoragePath
|
return 1, tempStoragePath
|
||||||
|
|
||||||
|
|
||||||
elif status.find("[5009]") > -1:
|
elif status.find("[5009]") > -1:
|
||||||
## removing status file, so that backup can re-run
|
## removing status file, so that backup can re-run
|
||||||
try:
|
try:
|
||||||
@@ -109,9 +110,13 @@ class backupSchedule:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
backupSchedule.remoteBackupLogging(backupLogPath, "An error occurred, Error message: " + status)
|
backupSchedule.remoteBackupLogging(backupLogPath, "An error occurred, Error message: " + status)
|
||||||
|
try:
|
||||||
|
os.remove(pathToFile)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
return 0, tempStoragePath
|
return 0, tempStoragePath
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [119:startBackup]")
|
||||||
return 0, "None"
|
return 0, "None"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -181,7 +186,7 @@ class backupSchedule:
|
|||||||
os.remove(backupPath)
|
os.remove(backupPath)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [189:startBackup]")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def prepare():
|
def prepare():
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class backupScheduleLocal:
|
|||||||
writeToFile.close()
|
writeToFile.close()
|
||||||
|
|
||||||
except BaseException,msg:
|
except BaseException,msg:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [214:startBackup]")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
backupScheduleLocal.prepare()
|
backupScheduleLocal.prepare()
|
||||||
|
|||||||
@@ -17,26 +17,34 @@ from multiprocessing import Process
|
|||||||
import signal
|
import signal
|
||||||
from installUtilities import installUtilities
|
from installUtilities import installUtilities
|
||||||
import argparse
|
import argparse
|
||||||
from virtualHostUtilities import virtualHostUtilities
|
try:
|
||||||
from sslUtilities import sslUtilities
|
from virtualHostUtilities import virtualHostUtilities
|
||||||
from websiteFunctions.models import Websites, ChildDomains, Backups
|
from sslUtilities import sslUtilities
|
||||||
from databases.models import Databases
|
from plogical.mailUtilities import mailUtilities
|
||||||
from loginSystem.models import Administrator
|
except:
|
||||||
from dnsUtilities import DNS
|
pass
|
||||||
|
|
||||||
from xml.etree.ElementTree import Element, SubElement
|
from xml.etree.ElementTree import Element, SubElement
|
||||||
from xml.etree import ElementTree
|
from xml.etree import ElementTree
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
from backup.models import DBUsers
|
|
||||||
from mailServer.models import Domains as eDomains
|
|
||||||
import time
|
import time
|
||||||
from plogical.mailUtilities import mailUtilities
|
|
||||||
from shutil import copy
|
from shutil import copy
|
||||||
from random import randint
|
from random import randint
|
||||||
from plogical.processUtilities import ProcessUtilities
|
from plogical.processUtilities import ProcessUtilities
|
||||||
|
try:
|
||||||
|
from websiteFunctions.models import Websites, ChildDomains, Backups
|
||||||
|
from databases.models import Databases
|
||||||
|
from loginSystem.models import Administrator
|
||||||
|
from dnsUtilities import DNS
|
||||||
|
from mailServer.models import Domains as eDomains
|
||||||
|
from backup.models import DBUsers
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
## I am not the monster that you think I am..
|
## I am not the monster that you think I am..
|
||||||
|
|
||||||
class backupUtilities:
|
class backupUtilities:
|
||||||
|
Server_root = "/usr/local/lsws"
|
||||||
|
|
||||||
completeKeyPath = "/home/cyberpanel/.ssh"
|
completeKeyPath = "/home/cyberpanel/.ssh"
|
||||||
destinationsPath = "/home/cyberpanel/destinations"
|
destinationsPath = "/home/cyberpanel/destinations"
|
||||||
@@ -46,6 +54,10 @@ class backupUtilities:
|
|||||||
def prepareBackupMeta(backupDomain, backupName, tempStoragePath, backupPath):
|
def prepareBackupMeta(backupDomain, backupName, tempStoragePath, backupPath):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
status = os.path.join(backupPath, 'status')
|
||||||
|
|
||||||
|
logging.CyberCPLogFileWriter.statusWriter(status, 'Setting up meta data..')
|
||||||
|
|
||||||
website = Websites.objects.get(domain=backupDomain)
|
website = Websites.objects.get(domain=backupDomain)
|
||||||
|
|
||||||
######### Generating meta
|
######### Generating meta
|
||||||
@@ -194,10 +206,13 @@ class backupUtilities:
|
|||||||
size=0, status=1)
|
size=0, status=1)
|
||||||
newBackup.save()
|
newBackup.save()
|
||||||
|
|
||||||
|
logging.CyberCPLogFileWriter.statusWriter(status, 'Meta data us ready..')
|
||||||
|
|
||||||
return 1,'None', metaPath
|
return 1,'None', metaPath
|
||||||
|
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
|
logging.CyberCPLogFileWriter.statusWriter(status, "%s [207][5009]" % (str(msg)))
|
||||||
return 0,str(msg)
|
return 0,str(msg)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -207,12 +222,6 @@ class backupUtilities:
|
|||||||
## /home/example.com/backup/backup-example-06-50-03-Thu-Feb-2018 -- tempStoragePath
|
## /home/example.com/backup/backup-example-06-50-03-Thu-Feb-2018 -- tempStoragePath
|
||||||
## /home/example.com/backup - backupPath
|
## /home/example.com/backup - backupPath
|
||||||
|
|
||||||
if not os.path.exists(backupPath):
|
|
||||||
os.mkdir(backupPath)
|
|
||||||
|
|
||||||
if not os.path.exists(tempStoragePath):
|
|
||||||
os.mkdir(tempStoragePath)
|
|
||||||
|
|
||||||
##### Writing the name of backup file.
|
##### Writing the name of backup file.
|
||||||
|
|
||||||
## /home/example.com/backup/backupFileName
|
## /home/example.com/backup/backupFileName
|
||||||
@@ -246,7 +255,7 @@ class backupUtilities:
|
|||||||
|
|
||||||
## Saving original vhost conf file
|
## Saving original vhost conf file
|
||||||
|
|
||||||
completPathToConf = virtualHostUtilities.Server_root + '/conf/vhosts/' + domainName + '/vhost.conf'
|
completPathToConf = backupUtilities.Server_root + '/conf/vhosts/' + domainName + '/vhost.conf'
|
||||||
|
|
||||||
if os.path.exists(backupUtilities.licenseKey):
|
if os.path.exists(backupUtilities.licenseKey):
|
||||||
copy(completPathToConf, tempStoragePath + '/vhost.conf')
|
copy(completPathToConf, tempStoragePath + '/vhost.conf')
|
||||||
@@ -279,7 +288,7 @@ class backupUtilities:
|
|||||||
actualChildDomain = childDomain.find('domain').text
|
actualChildDomain = childDomain.find('domain').text
|
||||||
|
|
||||||
if os.path.exists(backupUtilities.licenseKey):
|
if os.path.exists(backupUtilities.licenseKey):
|
||||||
completPathToConf = virtualHostUtilities.Server_root + '/conf/vhosts/' + actualChildDomain + '/vhost.conf'
|
completPathToConf = backupUtilities.Server_root + '/conf/vhosts/' + actualChildDomain + '/vhost.conf'
|
||||||
copy(completPathToConf, tempStoragePath + '/' + actualChildDomain + '.vhost.conf')
|
copy(completPathToConf, tempStoragePath + '/' + actualChildDomain + '.vhost.conf')
|
||||||
|
|
||||||
### Storing SSL for child domainsa
|
### Storing SSL for child domainsa
|
||||||
@@ -299,25 +308,25 @@ class backupUtilities:
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
pass
|
||||||
|
|
||||||
logging.CyberCPLogFileWriter.statusWriter(status, "Backing up databases.")
|
logging.CyberCPLogFileWriter.statusWriter(status, "Backing up databases..")
|
||||||
print '1,None'
|
print '1,None'
|
||||||
|
|
||||||
except BaseException,msg:
|
except BaseException,msg:
|
||||||
try:
|
try:
|
||||||
os.remove(os.path.join(backupPath,backupName+".tar.gz"))
|
os.remove(os.path.join(backupPath,backupName+".tar.gz"))
|
||||||
except:
|
except:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
rmtree(tempStoragePath)
|
rmtree(tempStoragePath)
|
||||||
except:
|
except:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
pass
|
||||||
|
|
||||||
status = os.path.join(backupPath, 'status')
|
status = os.path.join(backupPath, 'status')
|
||||||
logging.CyberCPLogFileWriter.statusWriter(status, "Aborted, "+ str(msg) + ".[365] [5009]")
|
logging.CyberCPLogFileWriter.statusWriter(status, "Aborted, "+ str(msg) + ".[365] [5009]")
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
print ("Aborted, "+ str(msg) + ".[365] [5009]")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def BackupRoot(tempStoragePath, backupName, backupPath, metaPath=None):
|
def BackupRoot(tempStoragePath, backupName, backupPath, metaPath=None):
|
||||||
@@ -331,16 +340,16 @@ class backupUtilities:
|
|||||||
|
|
||||||
if os.path.islink(status) or os.path.islink(tempStoragePath or os.path.islink(backupPath)) or os.path.islink(metaPath):
|
if os.path.islink(status) or os.path.islink(tempStoragePath or os.path.islink(backupPath)) or os.path.islink(metaPath):
|
||||||
logging.CyberCPLogFileWriter.writeToFile('symlinked.')
|
logging.CyberCPLogFileWriter.writeToFile('symlinked.')
|
||||||
|
logging.CyberCPLogFileWriter.statusWriter(status, 'Symlink attack. [5009]')
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
## backup email accounts
|
## backup email accounts
|
||||||
|
|
||||||
logging.CyberCPLogFileWriter.statusWriter(status, "Backing up email accounts!\n")
|
logging.CyberCPLogFileWriter.statusWriter(status, "Backing up email accounts..\n")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
make_archive(os.path.join(tempStoragePath, domainName), 'gztar', os.path.join("/home", "vmail", domainName))
|
make_archive(os.path.join(tempStoragePath, domainName), 'gztar', os.path.join("/home", "vmail", domainName))
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
print str(msg)
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@@ -576,7 +585,7 @@ class backupUtilities:
|
|||||||
|
|
||||||
if os.path.exists(backupUtilities.licenseKey):
|
if os.path.exists(backupUtilities.licenseKey):
|
||||||
if os.path.exists(completPath + '/' + domain + '.vhost.conf'):
|
if os.path.exists(completPath + '/' + domain + '.vhost.conf'):
|
||||||
completPathToConf = virtualHostUtilities.Server_root + '/conf/vhosts/' + domain + '/vhost.conf'
|
completPathToConf = backupUtilities.Server_root + '/conf/vhosts/' + domain + '/vhost.conf'
|
||||||
copy(completPath + '/' + domain + '.vhost.conf', completPathToConf)
|
copy(completPath + '/' + domain + '.vhost.conf', completPathToConf)
|
||||||
|
|
||||||
sslStoragePath = completPath + "/" + domain + ".cert.pem"
|
sslStoragePath = completPath + "/" + domain + ".cert.pem"
|
||||||
@@ -688,7 +697,7 @@ class backupUtilities:
|
|||||||
## emails extracted
|
## emails extracted
|
||||||
|
|
||||||
if os.path.exists(backupUtilities.licenseKey):
|
if os.path.exists(backupUtilities.licenseKey):
|
||||||
completPathToConf = virtualHostUtilities.Server_root + '/conf/vhosts/' + masterDomain + '/vhost.conf'
|
completPathToConf = backupUtilities.Server_root + '/conf/vhosts/' + masterDomain + '/vhost.conf'
|
||||||
if os.path.exists(completPath + '/vhost.conf'):
|
if os.path.exists(completPath + '/vhost.conf'):
|
||||||
copy(completPath + '/vhost.conf', completPathToConf)
|
copy(completPath + '/vhost.conf', completPathToConf)
|
||||||
|
|
||||||
@@ -996,20 +1005,48 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
|
|||||||
## /home/cyberpanel/1047.xml - metaPath
|
## /home/cyberpanel/1047.xml - metaPath
|
||||||
|
|
||||||
status = os.path.join(backupPath, 'status')
|
status = os.path.join(backupPath, 'status')
|
||||||
|
website = Websites.objects.get(domain=backupDomain)
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
command = 'mkdir -p %s' % (backupPath)
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
|
command = 'chown -R %s:%s %s' % (website.externalApp, website.externalApp, backupPath)
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
command = 'mkdir -p %s' % (tempStoragePath)
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
|
command = 'chown -R %s:%s %s' % (website.externalApp, website.externalApp, tempStoragePath)
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
command = 'chown cyberpanel:cyberpanel %s' % (status)
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
result = backupUtilities.prepareBackupMeta(backupDomain, backupName, tempStoragePath, backupPath)
|
result = backupUtilities.prepareBackupMeta(backupDomain, backupName, tempStoragePath, backupPath)
|
||||||
|
|
||||||
if result[0] == 0:
|
|
||||||
logging.CyberCPLogFileWriter.writeToFile(result[1] + ' [5009]')
|
|
||||||
logging.CyberCPLogFileWriter.statusWriter(status, result[1] + ' [5009]')
|
|
||||||
return
|
|
||||||
|
|
||||||
website = Websites.objects.get(domain=backupDomain)
|
if result[0] == 0:
|
||||||
|
logging.CyberCPLogFileWriter.statusWriter(status, str(result[1]) + ' [5009]')
|
||||||
|
return 0
|
||||||
|
|
||||||
|
command = 'chown %s:%s %s' % (website.externalApp, website.externalApp, status)
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
execPath = "sudo nice -n 10 python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
|
execPath = "sudo nice -n 10 python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
|
||||||
execPath = execPath + " startBackup --tempStoragePath " + tempStoragePath + " --backupName " \
|
execPath = execPath + " startBackup --tempStoragePath " + tempStoragePath + " --backupName " \
|
||||||
+ backupName + " --backupPath " + backupPath + ' --backupDomain ' + backupDomain + ' --metaPath %s' % (result[2])
|
+ backupName + " --backupPath " + backupPath + ' --backupDomain ' + backupDomain + ' --metaPath %s' % (result[2])
|
||||||
|
|
||||||
ProcessUtilities.executioner(execPath, website.externalApp)
|
output = ProcessUtilities.outputExecutioner(execPath, website.externalApp)
|
||||||
|
if output.find('[5009') > -1:
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile(output)
|
||||||
|
return 0
|
||||||
|
|
||||||
## Backing up databases
|
## Backing up databases
|
||||||
|
|
||||||
@@ -1034,13 +1071,19 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
|
|||||||
|
|
||||||
##
|
##
|
||||||
|
|
||||||
if ProcessUtilities.outputExecutioner(execPath, website.externalApp).find('1,None') > -1:
|
output = ProcessUtilities.outputExecutioner(execPath, website.externalApp)
|
||||||
|
if output.find('1,None') > -1:
|
||||||
execPath = "sudo nice -n 10 python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
|
execPath = "sudo nice -n 10 python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
|
||||||
execPath = execPath + " BackupRoot --tempStoragePath " + tempStoragePath + " --backupName " \
|
execPath = execPath + " BackupRoot --tempStoragePath " + tempStoragePath + " --backupName " \
|
||||||
+ backupName + " --backupPath " + backupPath + ' --backupDomain ' + backupDomain + ' --metaPath %s' % (
|
+ backupName + " --backupPath " + backupPath + ' --backupDomain ' + backupDomain + ' --metaPath %s' % (
|
||||||
result[2])
|
result[2])
|
||||||
|
|
||||||
ProcessUtilities.executioner(execPath, 'root')
|
ProcessUtilities.executioner(execPath, 'root')
|
||||||
|
else:
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile(output)
|
||||||
|
|
||||||
|
command = 'chown -R %s:%s %s' % (website.externalApp, website.externalApp, backupPath)
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
command = 'rm -f %s' % (result[2])
|
command = 'rm -f %s' % (result[2])
|
||||||
ProcessUtilities.executioner(command, 'cyberpanel')
|
ProcessUtilities.executioner(command, 'cyberpanel')
|
||||||
|
|||||||
@@ -3,13 +3,19 @@ import os,sys
|
|||||||
sys.path.append('/usr/local/CyberCP')
|
sys.path.append('/usr/local/CyberCP')
|
||||||
import django
|
import django
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||||
django.setup()
|
try:
|
||||||
|
django.setup()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
import CyberCPLogFileWriter as logging
|
import CyberCPLogFileWriter as logging
|
||||||
import subprocess
|
import subprocess
|
||||||
import shlex
|
import shlex
|
||||||
from dns.models import Domains,Records
|
try:
|
||||||
from processUtilities import ProcessUtilities
|
from dns.models import Domains,Records
|
||||||
from manageServices.models import PDNSStatus, SlaveServers
|
from processUtilities import ProcessUtilities
|
||||||
|
from manageServices.models import PDNSStatus, SlaveServers
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
class DNS:
|
class DNS:
|
||||||
|
|
||||||
|
|||||||
@@ -2,20 +2,26 @@ import os,sys
|
|||||||
sys.path.append('/usr/local/CyberCP')
|
sys.path.append('/usr/local/CyberCP')
|
||||||
import django
|
import django
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||||
django.setup()
|
try:
|
||||||
|
django.setup()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
import os.path
|
import os.path
|
||||||
import shutil
|
import shutil
|
||||||
import CyberCPLogFileWriter as logging
|
import CyberCPLogFileWriter as logging
|
||||||
import subprocess
|
import subprocess
|
||||||
import argparse
|
import argparse
|
||||||
import shlex
|
import shlex
|
||||||
from mailServer.models import Domains,EUsers
|
|
||||||
from emailPremium.models import DomainLimits, EmailLimits
|
|
||||||
from websiteFunctions.models import Websites, ChildDomains
|
|
||||||
from processUtilities import ProcessUtilities
|
from processUtilities import ProcessUtilities
|
||||||
import os, getpass
|
import os, getpass
|
||||||
import hashlib
|
import hashlib
|
||||||
import bcrypt
|
import bcrypt
|
||||||
|
try:
|
||||||
|
from mailServer.models import Domains, EUsers
|
||||||
|
from emailPremium.models import DomainLimits, EmailLimits
|
||||||
|
from websiteFunctions.models import Websites, ChildDomains
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
class mailUtilities:
|
class mailUtilities:
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,11 @@ except:
|
|||||||
import CyberCPLogFileWriter as logging
|
import CyberCPLogFileWriter as logging
|
||||||
import subprocess
|
import subprocess
|
||||||
import shlex
|
import shlex
|
||||||
from websiteFunctions.models import Websites
|
try:
|
||||||
from databases.models import Databases
|
from websiteFunctions.models import Websites
|
||||||
|
from databases.models import Databases
|
||||||
|
except:
|
||||||
|
pass
|
||||||
import MySQLdb as mysql
|
import MySQLdb as mysql
|
||||||
import json
|
import json
|
||||||
from random import randint
|
from random import randint
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ class remoteBackup:
|
|||||||
writeToFile.writelines("\n")
|
writeToFile.writelines("\n")
|
||||||
|
|
||||||
except BaseException,msg:
|
except BaseException,msg:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [214:startBackup]")
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ import shlex
|
|||||||
import subprocess
|
import subprocess
|
||||||
import socket
|
import socket
|
||||||
from plogical.processUtilities import ProcessUtilities
|
from plogical.processUtilities import ProcessUtilities
|
||||||
from websiteFunctions.models import ChildDomains, Websites
|
try:
|
||||||
|
from websiteFunctions.models import ChildDomains, Websites
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
class sslUtilities:
|
class sslUtilities:
|
||||||
|
|
||||||
|
|||||||
@@ -5,14 +5,17 @@ import sys
|
|||||||
import django
|
import django
|
||||||
sys.path.append('/usr/local/CyberCP')
|
sys.path.append('/usr/local/CyberCP')
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||||
django.setup()
|
try:
|
||||||
|
django.setup()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
import shutil
|
import shutil
|
||||||
import installUtilities
|
import installUtilities
|
||||||
from websiteFunctions.models import Websites, ChildDomains, aliasDomains
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import shlex
|
import shlex
|
||||||
import CyberCPLogFileWriter as logging
|
import CyberCPLogFileWriter as logging
|
||||||
from databases.models import Databases
|
|
||||||
from mysqlUtilities import mysqlUtilities
|
from mysqlUtilities import mysqlUtilities
|
||||||
from dnsUtilities import DNS
|
from dnsUtilities import DNS
|
||||||
from random import randint
|
from random import randint
|
||||||
@@ -20,6 +23,11 @@ from processUtilities import ProcessUtilities
|
|||||||
from managePHP.phpManager import PHPManager
|
from managePHP.phpManager import PHPManager
|
||||||
from vhostConfs import vhostConfs
|
from vhostConfs import vhostConfs
|
||||||
from ApachController.ApacheVhosts import ApacheVhost
|
from ApachController.ApacheVhosts import ApacheVhost
|
||||||
|
try:
|
||||||
|
from websiteFunctions.models import Websites, ChildDomains, aliasDomains
|
||||||
|
from databases.models import Databases
|
||||||
|
except:
|
||||||
|
pass
|
||||||
## If you want justice, you have come to the wrong place.
|
## If you want justice, you have come to the wrong place.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ import sys
|
|||||||
import django
|
import django
|
||||||
sys.path.append('/usr/local/CyberCP')
|
sys.path.append('/usr/local/CyberCP')
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||||
django.setup()
|
try:
|
||||||
|
django.setup()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
import shutil
|
import shutil
|
||||||
import argparse
|
import argparse
|
||||||
import installUtilities
|
import installUtilities
|
||||||
@@ -14,9 +17,6 @@ from os.path import join
|
|||||||
from os import listdir, rmdir
|
from os import listdir, rmdir
|
||||||
from shutil import move
|
from shutil import move
|
||||||
from multiprocessing import Process
|
from multiprocessing import Process
|
||||||
from websiteFunctions.models import Websites, ChildDomains, aliasDomains
|
|
||||||
from loginSystem.models import Administrator
|
|
||||||
from packages.models import Package
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import shlex
|
import shlex
|
||||||
from plogical.mailUtilities import mailUtilities
|
from plogical.mailUtilities import mailUtilities
|
||||||
@@ -29,7 +29,14 @@ from processUtilities import ProcessUtilities
|
|||||||
from ApachController.ApacheController import ApacheController
|
from ApachController.ApacheController import ApacheController
|
||||||
from ApachController.ApacheVhosts import ApacheVhost
|
from ApachController.ApacheVhosts import ApacheVhost
|
||||||
from managePHP.phpManager import PHPManager
|
from managePHP.phpManager import PHPManager
|
||||||
from CLManager.models import CLPackages
|
|
||||||
|
try:
|
||||||
|
from websiteFunctions.models import Websites, ChildDomains, aliasDomains
|
||||||
|
from loginSystem.models import Administrator
|
||||||
|
from packages.models import Package
|
||||||
|
from CLManager.models import CLPackages
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
## If you want justice, you have come to the wrong place.
|
## If you want justice, you have come to the wrong place.
|
||||||
|
|
||||||
|
|||||||
@@ -301,6 +301,13 @@ class ServerStatusUtil:
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if os.path.exists('/etc/redhat-release'):
|
||||||
|
command = 'yum remove -y openlitespeed'
|
||||||
|
else:
|
||||||
|
command = "apt-get -y remove openlitespeed"
|
||||||
|
|
||||||
|
ServerStatusUtil.executioner(command, FNULL)
|
||||||
|
|
||||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||||
"OpenLiteSpeed removed.\n", 1)
|
"OpenLiteSpeed removed.\n", 1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user