bug fix: git manager

This commit is contained in:
Usman Nasir
2020-03-30 01:07:46 +05:00
parent f475b6f859
commit 6154500b08
2 changed files with 74 additions and 71 deletions

View File

@@ -126,14 +126,12 @@ class IncScheduler():
data = {} data = {}
data['domain'] = website data['domain'] = website
data['folder'] = finalPath data['folder'] = finalPath
data['commitMessage'] = 'Auto commit by CyberPanel %s cron on %s.' % (type, time.strftime('%m.%d.%Y_%H-%M-%S')) data['commitMessage'] = 'Auto commit by CyberPanel %s cron on %s' % (type, time.strftime('%m-%d-%Y_%H-%M-%S'))
if gitConf['autoCommit'] == type: if gitConf['autoCommit'] == type:
wm = WebsiteManager() wm = WebsiteManager()
resp = wm.commitChanges(1, data) resp = wm.commitChanges(1, data)
logging.writeToFile(resp.content)
resp = json.loads(resp.content) resp = json.loads(resp.content)
message = 'Folder: %s, Status: %s' % (finalPath, resp['commandStatus']) message = 'Folder: %s, Status: %s' % (finalPath, resp['commandStatus'])

View File

@@ -2912,90 +2912,94 @@ StrictHostKeyChecking no
def folderCheck(self): def folderCheck(self):
domainPath = '/home/%s/public_html' % (self.domain)
vhRoot = '/home/%s' % (self.domain)
vmailPath = '/home/vmail/%s' % (self.domain)
##
try: try:
website = Websites.objects.get(domain=self.domain) domainPath = '/home/%s/public_html' % (self.domain)
vhRoot = '/home/%s' % (self.domain)
vmailPath = '/home/vmail/%s' % (self.domain)
self.masterWebsite = website ##
self.masterDomain = website.domain
externalApp = website.externalApp
self.externalAppLocal = website.externalApp
self.adminEmail = website.adminEmail
self.firstName = website.admin.firstName
self.lastName = website.admin.lastName
self.home = 0 try:
if self.folder == '/home/%s/public_html' % (self.domain):
self.home = 1
except: website = Websites.objects.get(domain=self.domain)
website = ChildDomains.objects.get(domain=self.domain) self.masterWebsite = website
self.masterWebsite = website.master self.masterDomain = website.domain
self.masterDomain = website.master.domain externalApp = website.externalApp
externalApp = website.master.externalApp self.externalAppLocal = website.externalApp
self.externalAppLocal = website.master.externalApp self.adminEmail = website.adminEmail
self.adminEmail = website.master.adminEmail self.firstName = website.admin.firstName
self.firstName = website.master.admin.firstName self.lastName = website.admin.lastName
self.lastName = website.master.admin.lastName
self.home = 0 self.home = 0
if self.folder == website.path: if self.folder == '/home/%s/public_html' % (self.domain):
self.home = 1 self.home = 1
## except:
if self.folder == domainPath: website = ChildDomains.objects.get(domain=self.domain)
self.externalApp = externalApp self.masterWebsite = website.master
return 1 self.masterDomain = website.master.domain
externalApp = website.master.externalApp
self.externalAppLocal = website.master.externalApp
self.adminEmail = website.master.adminEmail
self.firstName = website.master.admin.firstName
self.lastName = website.master.admin.lastName
## self.home = 0
if self.folder == website.path:
self.home = 1
if self.folder == vhRoot: ##
self.externalApp = externalApp
return 1
## if self.folder == domainPath:
try:
childDomain = ChildDomains.objects.get(domain=self.domain)
if self.folder == childDomain.path:
self.externalApp = externalApp self.externalApp = externalApp
return 1 return 1
except: ##
pass
## if self.folder == vhRoot:
self.externalApp = externalApp
return 1
if self.folder == vmailPath: ##
self.externalApp = 'vmail'
return 1
try: try:
childDomain = ChildDomains.objects.get(domain=self.domain)
for database in website.databases_set.all(): if self.folder == childDomain.path:
self.externalApp = 'mysql' self.externalApp = externalApp
basePath = '/var/lib/mysql/'
dbPath = '%s%s' % (basePath, database.dbName)
if self.folder == dbPath:
return 1 return 1
except:
for database in website.master.databases_set.all():
self.externalApp = 'mysql'
basePath = '/var/lib/mysql/'
dbPath = '%s%s' % (basePath, database.dbName)
if self.folder == dbPath: except:
return 1 pass
##
if self.folder == vmailPath:
self.externalApp = 'vmail'
return 1
try:
for database in website.databases_set.all():
self.externalApp = 'mysql'
basePath = '/var/lib/mysql/'
dbPath = '%s%s' % (basePath, database.dbName)
if self.folder == dbPath:
return 1
except:
for database in website.master.databases_set.all():
self.externalApp = 'mysql'
basePath = '/var/lib/mysql/'
dbPath = '%s%s' % (basePath, database.dbName)
if self.folder == dbPath:
return 1
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile('%s. [folderCheck:3002]' % (str(msg)))
return 0 return 0
@@ -3355,12 +3359,13 @@ StrictHostKeyChecking no
else: else:
return ACLManager.loadErrorJson() return ACLManager.loadErrorJson()
# security check # security check
if ACLManager.validateInput(self.commitMessage): if ACLManager.validateInput(self.commitMessage):
pass pass
else: else:
return ACLManager.loadErrorJson('status', 'Invalid characters in your input.') return ACLManager.loadErrorJson()
## Check if remote exists ## Check if remote exists
@@ -3371,12 +3376,12 @@ StrictHostKeyChecking no
commandStatus = ProcessUtilities.outputExecutioner(command) commandStatus = ProcessUtilities.outputExecutioner(command)
if commandStatus.find('nothing to commit') == -1: if commandStatus.find('nothing to commit') == -1:
gitConfFolder = '/home/cyberpanel/git/%s' % (self.masterDomain)
finalFile = '%s/%s' % (gitConfFolder, self.folder.split('/')[-1])
gitConf = json.loads(open(finalFile, 'r').read())
try: try:
gitConfFolder = '/home/cyberpanel/git/%s' % (self.masterDomain)
finalFile = '%s/%s' % (gitConfFolder, self.folder.split('/')[-1])
gitConf = json.loads(open(finalFile, 'r').read())
if gitConf['commands'] != 'NONE': if gitConf['commands'] != 'NONE':