From 0d54457db1b2e4d149bddaa77cf3c84dfbe8abc7 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Tue, 11 Feb 2020 21:33:20 +0500 Subject: [PATCH] bug fix: cron path for ubuntu --- plogical/cronUtil.py | 7 +++++-- websiteFunctions/website.py | 9 ++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/plogical/cronUtil.py b/plogical/cronUtil.py index 741823f80..ed52e45af 100755 --- a/plogical/cronUtil.py +++ b/plogical/cronUtil.py @@ -77,9 +77,12 @@ class CronUtil: @staticmethod def addNewCron(externalApp, finalCron): try: - CronPath = '/var/spool/cron/%s' % (externalApp) + if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + cronPath = "/var/spool/cron/" + externalApp + else: + cronPath = "/var/spool/cron/crontabs/" + externalApp - with open(CronPath, "a") as file: + with open(cronPath, "a") as file: file.write(finalCron + "\n") print("1,None") diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index d779ce7c3..7f2dfa613 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -1548,11 +1548,14 @@ class WebsiteManager: website = Websites.objects.get(domain=self.domain) - CronPath = '/var/spool/cron/%s' % (website.externalApp) + if ProcessUtilities.decideDistro() == ProcessUtilities.centos: + cronPath = "/var/spool/cron/" + website.externalApp + else: + cronPath = "/var/spool/cron/crontabs/" + website.externalApp - commandT = 'touch %s' % (CronPath) + commandT = 'touch %s' % (cronPath) ProcessUtilities.executioner(commandT, 'root') - commandT = 'chown %s:%s %s' % (website.externalApp, website.externalApp, CronPath) + commandT = 'chown %s:%s %s' % (website.externalApp, website.externalApp, cronPath) ProcessUtilities.executioner(commandT, 'root') CronUtil.CronPrem(1)