bug fix: if domain exists as cd

This commit is contained in:
usmannasir
2024-01-27 12:02:50 +05:00
parent fc2925e945
commit c083ec6203

View File

@@ -158,46 +158,50 @@ class virtualHostUtilities:
### create site if not there ### create site if not there
try: try:
website = Websites.objects.get(domain=Domain) website = Websites.objects.get(domain=Domain)
except: except:
DataToPass = {} try:
child = ChildDomains.objects.get(domain=Domain)
except:
DataToPass = {}
currentTemp = tempStatusPath currentTemp = tempStatusPath
DataToPass['domainName'] = Domain DataToPass['domainName'] = Domain
DataToPass['adminEmail'] = admin.email DataToPass['adminEmail'] = admin.email
DataToPass['phpSelection'] = "PHP 8.0" DataToPass['phpSelection'] = "PHP 8.0"
DataToPass['websiteOwner'] = "admin" DataToPass['websiteOwner'] = "admin"
DataToPass['package'] = "Default" DataToPass['package'] = "Default"
DataToPass['ssl'] = 1 DataToPass['ssl'] = 1
DataToPass['dkimCheck'] = 1 DataToPass['dkimCheck'] = 1
DataToPass['openBasedir'] = 0 DataToPass['openBasedir'] = 0
DataToPass['mailDomain'] = 0 DataToPass['mailDomain'] = 0
DataToPass['apacheBackend'] = 0 DataToPass['apacheBackend'] = 0
UserID = admin.pk UserID = admin.pk
from websiteFunctions.website import WebsiteManager from websiteFunctions.website import WebsiteManager
ab = WebsiteManager() ab = WebsiteManager()
coreResult = ab.submitWebsiteCreation(admin.id, DataToPass) coreResult = ab.submitWebsiteCreation(admin.id, DataToPass)
coreResult1 = json.loads((coreResult).content) coreResult1 = json.loads((coreResult).content)
logging.CyberCPLogFileWriter.writeToFile("Creating website result....%s" % coreResult1) logging.CyberCPLogFileWriter.writeToFile("Creating website result....%s" % coreResult1)
reutrntempath = coreResult1['tempStatusPath'] reutrntempath = coreResult1['tempStatusPath']
while (1): while (1):
lastLine = open(reutrntempath, 'r').read() lastLine = open(reutrntempath, 'r').read()
if os.path.exists(ProcessUtilities.debugPath): if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile("Info web creating lastline ....... %s" % lastLine) logging.CyberCPLogFileWriter.writeToFile("Info web creating lastline ....... %s" % lastLine)
if lastLine.find('[200]') > -1: if lastLine.find('[200]') > -1:
break break
elif lastLine.find('[404]') > -1: elif lastLine.find('[404]') > -1:
statusFile = open(currentTemp, 'w') statusFile = open(currentTemp, 'w')
statusFile.writelines('Failed to Create Website: error: %s. [404]' % lastLine) statusFile.writelines('Failed to Create Website: error: %s. [404]' % lastLine)
statusFile.close() statusFile.close()
return 0 return 0
else: else:
statusFile = open(currentTemp, 'w') statusFile = open(currentTemp, 'w')
statusFile.writelines('Creating Website....,20') statusFile.writelines('Creating Website....,20')
statusFile.close() statusFile.close()
time.sleep(2) time.sleep(2)
### Case 2 where postfix hostname either does not exist or does not match with server hostname or ### Case 2 where postfix hostname either does not exist or does not match with server hostname or
### hostname does not exists at all ### hostname does not exists at all