From 4f1a8ad51572bbe1609ab765c98d1d3594261d5f Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Mon, 30 Mar 2020 13:26:17 +0500 Subject: [PATCH] bug fix: auto git commit/push --- plogical/IncScheduler.py | 10 ++++++++-- plogical/vhost.py | 7 ++++++- websiteFunctions/website.py | 8 +++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/plogical/IncScheduler.py b/plogical/IncScheduler.py index 89bda212b..b08f4c9ab 100644 --- a/plogical/IncScheduler.py +++ b/plogical/IncScheduler.py @@ -102,6 +102,10 @@ class IncScheduler(): finalPathInside = '%s/%s' % (IncScheduler.gitFolder, website) for file in os.listdir(finalPathInside): + + if file == website: + continue + if file.find('public_html') > -1: finalPath = '/home/%s/public_html' % (website) finalPathConf = '%s/%s' % (finalPathInside, file) @@ -134,12 +138,14 @@ class IncScheduler(): resp = wm.commitChanges(1, data) resp = json.loads(resp.content) - message = 'Folder: %s, Status: %s' % (finalPath, resp['commandStatus']) - finalText = '%s\n%s' % (finalText, message) if resp['status'] == 1: + message = 'Folder: %s, Status: %s' % (finalPath, resp['commandStatus']) + finalText = '%s\n%s' % (finalText, message) GitLogs(owner=web, type='INFO', message=message).save() else: + message = 'Folder: %s, Status: %s' % (finalPath, resp['commandStatus']) + finalText = '%s\n%s' % (finalText, message) GitLogs(owner=web, type='ERROR', message=message).save() if gitConf['autoPush'] == type: diff --git a/plogical/vhost.py b/plogical/vhost.py index cca7a8705..c8c7d8766 100755 --- a/plogical/vhost.py +++ b/plogical/vhost.py @@ -410,7 +410,12 @@ class vhost: command = 'groupdel %s' % (externalApp) ProcessUtilities.executioner(command) - ## + ## Remove git conf folder if present + + gitPath = '/home/cyberpanel/git/%s' % (virtualHostName) + + if os.path.exists(gitPath): + shutil.rmtree(gitPath) except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [Not able to remove virtual host configuration from main configuration file.]") diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index 1fa63b476..db05af9c8 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -2998,6 +2998,10 @@ StrictHostKeyChecking no if self.folder == dbPath: return 1 + + return 0 + + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile('%s. [folderCheck:3002]' % (str(msg))) @@ -3357,16 +3361,18 @@ StrictHostKeyChecking no if self.folderCheck(): pass else: - return ACLManager.loadErrorJson() + return ACLManager.loadErrorJson('status', 0) # security check + if ACLManager.validateInput(self.commitMessage): pass else: return ACLManager.loadErrorJson() + ## Check if remote exists command = 'git -C %s add -A' % (self.folder)