From 84ded63fe5fad94ed94fbc0fb2541289d399b11c Mon Sep 17 00:00:00 2001 From: Gilles BOUVIER Date: Sat, 26 Dec 2020 14:15:24 -0800 Subject: [PATCH 1/6] =?UTF-8?q?=E2=80=A2=20Add=20From=20header=20to=20emai?= =?UTF-8?q?l=20message=20if=20missing.=20=20=20Gmail=20rejects=20messages?= =?UTF-8?q?=20without=20a=20From=20header,=20with=20this=20error:=20=20=20?= =?UTF-8?q?"Our=20system=20has=20detected=20that=20this=20message=20is=205?= =?UTF-8?q?.7.1=20not=20RFC=205322=20=20=20=20compliant:=205.7.1=20'From'?= =?UTF-8?q?=20header=20is=20missing."?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plogical/CyberCPLogFileWriter.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plogical/CyberCPLogFileWriter.py b/plogical/CyberCPLogFileWriter.py index 46bcacf8e..a3ff8acde 100755 --- a/plogical/CyberCPLogFileWriter.py +++ b/plogical/CyberCPLogFileWriter.py @@ -7,6 +7,18 @@ import smtplib class CyberCPLogFileWriter: fileName = "/home/cyberpanel/error-logs.txt" + @staticmethod + def AddFromHeader(sender, message): + try: + import re + + if not re.search('^From: ', message, re.MULTILINE): + message = 'From: {}\n{}'.format(sender, message) + + return message + except BaseException as msg: + return "Can not add From header to message." + @staticmethod def SendEmail(sender, receivers, message, subject=None, type=None): try: @@ -29,9 +41,12 @@ class CyberCPLogFileWriter: if subject != None: message = 'Subject: {}\n\n{}'.format(subject, message) + message = CyberCPLogFileWriter.AddFromHeader(sender, message) smtpServer.sendmail(smtpUserName, receivers, message) else: smtpObj = smtplib.SMTP('localhost') + + message = CyberCPLogFileWriter.AddFromHeader(sender, message) smtpObj.sendmail(sender, receivers, message) except BaseException as msg: CyberCPLogFileWriter.writeToFile(str(msg)) @@ -107,4 +122,4 @@ Subject: %s statusFile.writelines(mesg + '\n') statusFile.close() except BaseException as msg: - CyberCPLogFileWriter.writeToFile(str(msg) + ' [statusWriter]') \ No newline at end of file + CyberCPLogFileWriter.writeToFile(str(msg) + ' [statusWriter]') From bfc57ec036bb58f67e8c05b44572edc1e39fbc22 Mon Sep 17 00:00:00 2001 From: Gilles BOUVIER Date: Sun, 27 Dec 2020 11:34:59 -0800 Subject: [PATCH 2/6] =?UTF-8?q?=E2=80=A2=20Use=20writeToFile=20in=20except?= =?UTF-8?q?ion=20clause=20(suggestion=20from=20@furkansandal).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plogical/CyberCPLogFileWriter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plogical/CyberCPLogFileWriter.py b/plogical/CyberCPLogFileWriter.py index a3ff8acde..18410e788 100755 --- a/plogical/CyberCPLogFileWriter.py +++ b/plogical/CyberCPLogFileWriter.py @@ -17,7 +17,7 @@ class CyberCPLogFileWriter: return message except BaseException as msg: - return "Can not add From header to message." + CyberCPLogFileWriter.writeToFile(str(msg) + ' [AddFromHeader]') @staticmethod def SendEmail(sender, receivers, message, subject=None, type=None): From 11969008f9496406218690449bba74b53cde79ab Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Thu, 15 Apr 2021 16:25:44 +0500 Subject: [PATCH 3/6] bug fix: cluster path for centos --- plogical/ClusterManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plogical/ClusterManager.py b/plogical/ClusterManager.py index d91bfc119..e3c83ad66 100644 --- a/plogical/ClusterManager.py +++ b/plogical/ClusterManager.py @@ -48,7 +48,7 @@ class ClusterManager: def FetchMySQLConfigFile(self): if ProcessUtilities.decideDistro() == ProcessUtilities.centos: - return '/etc/mysql/conf.d/cluster.cnf' + return '/etc/my.cnf.d/cluster.cnf' else: return '/etc/mysql/conf.d/cluster.cnf' From 765359b2b1574842fe212a4bf28e1465780f7f85 Mon Sep 17 00:00:00 2001 From: Michael Ramsey Date: Thu, 15 Apr 2021 19:47:12 -0400 Subject: [PATCH 4/6] Adjust spelling for consistency --- .gitignore | 1 + IncBackups/views.py | 18 +++++++-------- backup/backupManager.py | 22 +++++++++---------- backup/templates/backup/index.html | 2 +- .../baseTemplate/custom-js/system-status.js | 4 ++-- .../templates/baseTemplate/index.html | 2 +- loginSystem/models.py | 2 +- plogical/acl.py | 8 +++---- plogical/upgrade.py | 12 +++++----- .../baseTemplate/custom-js/system-status.js | 4 ++-- static/userManagment/userManagment.js | 16 +++++++------- .../static/userManagment/userManagment.js | 16 +++++++------- .../templates/userManagment/createACL.html | 2 +- .../templates/userManagment/modifyACL.html | 2 +- userManagment/tests.py | 4 ++-- 15 files changed, 58 insertions(+), 57 deletions(-) diff --git a/.gitignore b/.gitignore index 184684c84..dffc08ca3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ *.pyc .idea venv +/.venv/ diff --git a/IncBackups/views.py b/IncBackups/views.py index 399cd0bfd..27968b0de 100644 --- a/IncBackups/views.py +++ b/IncBackups/views.py @@ -500,7 +500,7 @@ def restore_point(request): def schedule_backups(request): try: user_id, current_acl = _get_user_acl(request) - if ACLManager.currentContextPermission(current_acl, 'scheDuleBackups') == 0: + if ACLManager.currentContextPermission(current_acl, 'scheduleBackups') == 0: return ACLManager.loadError() websites = ACLManager.findAllSites(current_acl, user_id) @@ -508,7 +508,7 @@ def schedule_backups(request): destinations = _get_destinations(local=True) return def_renderer(request, 'IncBackups/backupSchedule.html', - {'websiteList': websites, 'destinations': destinations}, 'scheDuleBackups') + {'websiteList': websites, 'destinations': destinations}, 'scheduleBackups') except BaseException as msg: logging.writeToFile(str(msg)) return redirect(loadLoginPage) @@ -517,7 +517,7 @@ def schedule_backups(request): def submit_backup_schedule(request): try: user_id, current_acl = _get_user_acl(request) - if ACLManager.currentContextPermission(current_acl, 'scheDuleBackups') == 0: + if ACLManager.currentContextPermission(current_acl, 'scheduleBackups') == 0: return ACLManager.loadErrorJson('scheduleStatus', 0) data = json.loads(request.body) @@ -548,7 +548,7 @@ def submit_backup_schedule(request): def get_current_backup_schedules(request): try: user_id, current_acl = _get_user_acl(request) - if ACLManager.currentContextPermission(current_acl, 'scheDuleBackups') == 0: + if ACLManager.currentContextPermission(current_acl, 'scheduleBackups') == 0: return ACLManager.loadErrorJson('fetchStatus', 0) records = BackupJob.objects.all() @@ -571,7 +571,7 @@ def get_current_backup_schedules(request): def fetch_sites(request): try: user_id, current_acl = _get_user_acl(request) - if ACLManager.currentContextPermission(current_acl, 'scheDuleBackups') == 0: + if ACLManager.currentContextPermission(current_acl, 'scheduleBackups') == 0: return ACLManager.loadErrorJson('fetchStatus', 0) data = json.loads(request.body) @@ -596,7 +596,7 @@ def fetch_sites(request): def schedule_delete(request): try: user_id, current_acl = _get_user_acl(request) - if ACLManager.currentContextPermission(current_acl, 'scheDuleBackups') == 0: + if ACLManager.currentContextPermission(current_acl, 'scheduleBackups') == 0: return ACLManager.loadErrorJson('scheduleStatus', 0) data = json.loads(request.body) @@ -633,7 +633,7 @@ def restore_remote_backups(request): def save_changes(request): try: user_id, current_acl = _get_user_acl(request) - if ACLManager.currentContextPermission(current_acl, 'scheDuleBackups') == 0: + if ACLManager.currentContextPermission(current_acl, 'scheduleBackups') == 0: return ACLManager.loadErrorJson('scheduleStatus', 0) data = json.loads(request.body) @@ -661,7 +661,7 @@ def save_changes(request): def remove_site(request): try: _, current_acl = _get_user_acl(request) - if ACLManager.currentContextPermission(current_acl, 'scheDuleBackups') == 0: + if ACLManager.currentContextPermission(current_acl, 'scheduleBackups') == 0: return ACLManager.loadErrorJson('scheduleStatus', 0) data = json.loads(request.body) @@ -682,7 +682,7 @@ def remove_site(request): def add_website(request): try: _, current_acl = _get_user_acl(request) - if ACLManager.currentContextPermission(current_acl, 'scheDuleBackups') == 0: + if ACLManager.currentContextPermission(current_acl, 'scheduleBackups') == 0: return ACLManager.loadErrorJson('scheduleStatus', 0) data = json.loads(request.body) diff --git a/backup/backupManager.py b/backup/backupManager.py index db0bbf542..da92d6198 100755 --- a/backup/backupManager.py +++ b/backup/backupManager.py @@ -845,14 +845,14 @@ class BackupManager: dests.append(dest.name) websitesName = ACLManager.findAllSites(currentACL, userID) proc = httpProc(request, 'backup/backupSchedule.html', {'destinations': dests, 'websites': websitesName}, - 'scheDuleBackups') + 'scheduleBackups') return proc.render() def getCurrentBackupSchedules(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) - if ACLManager.currentContextPermission(currentACL, 'scheDuleBackups') == 0: + if ACLManager.currentContextPermission(currentACL, 'scheduleBackups') == 0: return ACLManager.loadErrorJson('fetchStatus', 0) records = backupSchedules.objects.all() @@ -889,7 +889,7 @@ class BackupManager: currentACL = ACLManager.loadedACL(userID) - if ACLManager.currentContextPermission(currentACL, 'scheDuleBackups') == 0: + if ACLManager.currentContextPermission(currentACL, 'scheduleBackups') == 0: return ACLManager.loadErrorJson('scheduleStatus', 0) nbd = NormalBackupDests.objects.get(name=selectedAccount) @@ -910,7 +910,7 @@ class BackupManager: try: currentACL = ACLManager.loadedACL(userID) - if ACLManager.currentContextPermission(currentACL, 'scheDuleBackups') == 0: + if ACLManager.currentContextPermission(currentACL, 'scheduleBackups') == 0: return ACLManager.loadErrorJson('scheduleStatus', 0) backupDest = data['destLoc'] @@ -1413,7 +1413,7 @@ class BackupManager: page = int(str(data['page']).strip('\n')) - if ACLManager.currentContextPermission(currentACL, 'scheDuleBackups') == 0: + if ACLManager.currentContextPermission(currentACL, 'scheduleBackups') == 0: return ACLManager.loadErrorJson('scheduleStatus', 0) nbd = NormalBackupJobs.objects.get(name=selectedAccount) @@ -1499,7 +1499,7 @@ class BackupManager: nbd = NormalBackupDests.objects.get(name=selectedAccount) - if ACLManager.currentContextPermission(currentACL, 'scheDuleBackups') == 0: + if ACLManager.currentContextPermission(currentACL, 'scheduleBackups') == 0: return ACLManager.loadErrorJson('scheduleStatus', 0) allJobs = nbd.normalbackupjobs_set.all() @@ -1526,7 +1526,7 @@ class BackupManager: data = json.loads(request.body) - if ACLManager.currentContextPermission(currentACL, 'scheDuleBackups') == 0: + if ACLManager.currentContextPermission(currentACL, 'scheduleBackups') == 0: return ACLManager.loadErrorJson('scheduleStatus', 0) selectedJob = data['selectedJob'] @@ -1587,7 +1587,7 @@ class BackupManager: nbj = NormalBackupJobs.objects.get(name=selectedJob) website = Websites.objects.get(domain=selectedWebsite) - if ACLManager.currentContextPermission(currentACL, 'scheDuleBackups') == 0: + if ACLManager.currentContextPermission(currentACL, 'scheduleBackups') == 0: return ACLManager.loadErrorJson('scheduleStatus', 0) try: @@ -1618,7 +1618,7 @@ class BackupManager: nbj = NormalBackupJobs.objects.get(name=selectedJob) - if ACLManager.currentContextPermission(currentACL, 'scheDuleBackups') == 0: + if ACLManager.currentContextPermission(currentACL, 'scheduleBackups') == 0: return ACLManager.loadErrorJson('scheduleStatus', 0) config = json.loads(nbj.config) @@ -1649,7 +1649,7 @@ class BackupManager: nbj = NormalBackupJobs.objects.get(name=selectedJob) - if ACLManager.currentContextPermission(currentACL, 'scheDuleBackups') == 0: + if ACLManager.currentContextPermission(currentACL, 'scheduleBackups') == 0: return ACLManager.loadErrorJson('scheduleStatus', 0) nbj.delete() @@ -1676,7 +1676,7 @@ class BackupManager: recordsToShow = int(data['recordsToShow']) page = int(str(data['page']).strip('\n')) - if ACLManager.currentContextPermission(currentACL, 'scheDuleBackups') == 0: + if ACLManager.currentContextPermission(currentACL, 'scheduleBackups') == 0: return ACLManager.loadErrorJson('scheduleStatus', 0) nbj = NormalBackupJobs.objects.get(name=selectedJob) diff --git a/backup/templates/backup/index.html b/backup/templates/backup/index.html index f0cd19819..ca6869781 100755 --- a/backup/templates/backup/index.html +++ b/backup/templates/backup/index.html @@ -69,7 +69,7 @@ {% endif %} - {% if scheDuleBackups or admin %} + {% if scheduleBackups or admin %}
diff --git a/baseTemplate/static/baseTemplate/custom-js/system-status.js b/baseTemplate/static/baseTemplate/custom-js/system-status.js index 1f6fe8d9d..00807bd6b 100755 --- a/baseTemplate/static/baseTemplate/custom-js/system-status.js +++ b/baseTemplate/static/baseTemplate/custom-js/system-status.js @@ -317,8 +317,8 @@ app.controller('adminController', function ($scope, $http, $timeout) { $('.addDeleteDestinations').hide(); } - if (!Boolean(response.data.scheDuleBackups)) { - $('.scheDuleBackups').hide(); + if (!Boolean(response.data.scheduleBackups)) { + $('.scheduleBackups').hide(); } if (!Boolean(response.data.remoteBackups)) { diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html index 99a31600d..e6cfac182 100755 --- a/baseTemplate/templates/baseTemplate/index.html +++ b/baseTemplate/templates/baseTemplate/index.html @@ -657,7 +657,7 @@ title="{% trans 'Add Destination' %}">{% trans "Add/Delete Destination" %} {% endif %} - {% if admin or scheDuleBackups %} + {% if admin or scheduleBackups %}
  • {% trans "Schedule Back up" %}
  • diff --git a/loginSystem/models.py b/loginSystem/models.py index 35089bca1..ec8a00208 100755 --- a/loginSystem/models.py +++ b/loginSystem/models.py @@ -64,7 +64,7 @@ class ACL(models.Model): createBackup = models.IntegerField(default=1) restoreBackup = models.IntegerField(default=0) addDeleteDestinations = models.IntegerField(default=0) - scheDuleBackups = models.IntegerField(default=0) + scheduleBackups = models.IntegerField(default=0) remoteBackups = models.IntegerField(default=0) ## SSL Management diff --git a/plogical/acl.py b/plogical/acl.py index 310dcb7a8..9928e4102 100644 --- a/plogical/acl.py +++ b/plogical/acl.py @@ -23,7 +23,7 @@ class ACLManager: '"listDatabases": 1, "createNameServer": 1, "createDNSZone": 1, "deleteZone": 1, "addDeleteRecords": 1, ' \ '"createEmail": 1, "listEmails": 1, "deleteEmail": 1, "emailForwarding": 1, "changeEmailPassword": 1, ' \ '"dkimManager": 1, "createFTPAccount": 1, "deleteFTPAccount": 1, "listFTPAccounts": 1, "createBackup": 1,' \ - ' "restoreBackup": 1, "addDeleteDestinations": 1, "scheDuleBackups": 1, "remoteBackups": 1, "googleDriveBackups": 1, "manageSSL": 1, ' \ + ' "restoreBackup": 1, "addDeleteDestinations": 1, "scheduleBackups": 1, "remoteBackups": 1, "googleDriveBackups": 1, "manageSSL": 1, ' \ '"hostnameSSL": 1, "mailServerSSL": 1 }' ResellerACL = '{"adminStatus":0, "versionManagement": 1, "createNewUser": 1, "listUsers": 1, "deleteUser": 1 , "resellerCenter": 1, ' \ @@ -32,7 +32,7 @@ class ACLManager: '"listDatabases": 1, "createNameServer": 1, "createDNSZone": 1, "deleteZone": 1, "addDeleteRecords": 1, ' \ '"createEmail": 1, "listEmails": 1, "deleteEmail": 1, "emailForwarding": 1, "changeEmailPassword": 1, ' \ '"dkimManager": 1, "createFTPAccount": 1, "deleteFTPAccount": 1, "listFTPAccounts": 1, "createBackup": 1,' \ - ' "restoreBackup": 1, "addDeleteDestinations": 0, "scheDuleBackups": 0, "remoteBackups": 0, "googleDriveBackups": 1, "manageSSL": 1, ' \ + ' "restoreBackup": 1, "addDeleteDestinations": 0, "scheduleBackups": 0, "remoteBackups": 0, "googleDriveBackups": 1, "manageSSL": 1, ' \ '"hostnameSSL": 0, "mailServerSSL": 0 }' UserACL = '{"adminStatus":0, "versionManagement": 1, "createNewUser": 0, "listUsers": 0, "deleteUser": 0 , "resellerCenter": 0, ' \ @@ -41,7 +41,7 @@ class ACLManager: '"listDatabases": 1, "createNameServer": 0, "createDNSZone": 1, "deleteZone": 1, "addDeleteRecords": 1, ' \ '"createEmail": 1, "listEmails": 1, "deleteEmail": 1, "emailForwarding": 1, "changeEmailPassword": 1, ' \ '"dkimManager": 1, "createFTPAccount": 1, "deleteFTPAccount": 1, "listFTPAccounts": 1, "createBackup": 1,' \ - ' "restoreBackup": 0, "addDeleteDestinations": 0, "scheDuleBackups": 0, "remoteBackups": 0, "googleDriveBackups": 1, "manageSSL": 1, ' \ + ' "restoreBackup": 0, "addDeleteDestinations": 0, "scheduleBackups": 0, "remoteBackups": 0, "googleDriveBackups": 1, "manageSSL": 1, ' \ '"hostnameSSL": 0, "mailServerSSL": 0 }' @staticmethod def FindIfChild(): @@ -180,7 +180,7 @@ class ACLManager: finalResponse['googleDriveBackups'] = config['googleDriveBackups'] finalResponse['restoreBackup'] = config['restoreBackup'] finalResponse['addDeleteDestinations'] = config['addDeleteDestinations'] - finalResponse['scheDuleBackups'] = config['scheDuleBackups'] + finalResponse['scheduleBackups'] = config['scheduleBackups'] finalResponse['remoteBackups'] = config['remoteBackups'] ## SSL Management diff --git a/plogical/upgrade.py b/plogical/upgrade.py index ff831b221..e1116d943 100755 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -39,7 +39,7 @@ class Upgrade: '"listDatabases": 1, "createNameServer": 1, "createDNSZone": 1, "deleteZone": 1, "addDeleteRecords": 1, ' \ '"createEmail": 1, "listEmails": 1, "deleteEmail": 1, "emailForwarding": 1, "changeEmailPassword": 1, ' \ '"dkimManager": 1, "createFTPAccount": 1, "deleteFTPAccount": 1, "listFTPAccounts": 1, "createBackup": 1,' \ - ' "restoreBackup": 1, "addDeleteDestinations": 1, "scheDuleBackups": 1, "remoteBackups": 1, "googleDriveBackups": 1, "manageSSL": 1, ' \ + ' "restoreBackup": 1, "addDeleteDestinations": 1, "scheduleBackups": 1, "remoteBackups": 1, "googleDriveBackups": 1, "manageSSL": 1, ' \ '"hostnameSSL": 1, "mailServerSSL": 1 }' ResellerACL = '{"adminStatus":0, "versionManagement": 1, "createNewUser": 1, "listUsers": 1, "deleteUser": 1 , "resellerCenter": 1, ' \ @@ -48,7 +48,7 @@ class Upgrade: '"listDatabases": 1, "createNameServer": 1, "createDNSZone": 1, "deleteZone": 1, "addDeleteRecords": 1, ' \ '"createEmail": 1, "listEmails": 1, "deleteEmail": 1, "emailForwarding": 1, "changeEmailPassword": 1, ' \ '"dkimManager": 1, "createFTPAccount": 1, "deleteFTPAccount": 1, "listFTPAccounts": 1, "createBackup": 1,' \ - ' "restoreBackup": 1, "addDeleteDestinations": 0, "scheDuleBackups": 0, "remoteBackups": 0, "googleDriveBackups": 1, "manageSSL": 1, ' \ + ' "restoreBackup": 1, "addDeleteDestinations": 0, "scheduleBackups": 0, "remoteBackups": 0, "googleDriveBackups": 1, "manageSSL": 1, ' \ '"hostnameSSL": 0, "mailServerSSL": 0 }' UserACL = '{"adminStatus":0, "versionManagement": 1, "createNewUser": 0, "listUsers": 0, "deleteUser": 0 , "resellerCenter": 0, ' \ @@ -57,7 +57,7 @@ class Upgrade: '"listDatabases": 1, "createNameServer": 0, "createDNSZone": 1, "deleteZone": 1, "addDeleteRecords": 1, ' \ '"createEmail": 1, "listEmails": 1, "deleteEmail": 1, "emailForwarding": 1, "changeEmailPassword": 1, ' \ '"dkimManager": 1, "createFTPAccount": 1, "deleteFTPAccount": 1, "listFTPAccounts": 1, "createBackup": 1,' \ - ' "restoreBackup": 0, "addDeleteDestinations": 0, "scheDuleBackups": 0, "remoteBackups": 0, "googleDriveBackups": 1, "manageSSL": 1, ' \ + ' "restoreBackup": 0, "addDeleteDestinations": 0, "scheduleBackups": 0, "remoteBackups": 0, "googleDriveBackups": 1, "manageSSL": 1, ' \ '"hostnameSSL": 0, "mailServerSSL": 0 }' @staticmethod @@ -602,7 +602,7 @@ imap_folder_list_limit = 0 try: cursor.execute( - 'CREATE TABLE `loginSystem_acl` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(50) NOT NULL UNIQUE, `adminStatus` integer NOT NULL DEFAULT 0, `versionManagement` integer NOT NULL DEFAULT 0, `createNewUser` integer NOT NULL DEFAULT 0, `deleteUser` integer NOT NULL DEFAULT 0, `resellerCenter` integer NOT NULL DEFAULT 0, `changeUserACL` integer NOT NULL DEFAULT 0, `createWebsite` integer NOT NULL DEFAULT 0, `modifyWebsite` integer NOT NULL DEFAULT 0, `suspendWebsite` integer NOT NULL DEFAULT 0, `deleteWebsite` integer NOT NULL DEFAULT 0, `createPackage` integer NOT NULL DEFAULT 0, `deletePackage` integer NOT NULL DEFAULT 0, `modifyPackage` integer NOT NULL DEFAULT 0, `createDatabase` integer NOT NULL DEFAULT 0, `deleteDatabase` integer NOT NULL DEFAULT 0, `listDatabases` integer NOT NULL DEFAULT 0, `createNameServer` integer NOT NULL DEFAULT 0, `createDNSZone` integer NOT NULL DEFAULT 0, `deleteZone` integer NOT NULL DEFAULT 0, `addDeleteRecords` integer NOT NULL DEFAULT 0, `createEmail` integer NOT NULL DEFAULT 0, `deleteEmail` integer NOT NULL DEFAULT 0, `emailForwarding` integer NOT NULL DEFAULT 0, `changeEmailPassword` integer NOT NULL DEFAULT 0, `dkimManager` integer NOT NULL DEFAULT 0, `createFTPAccount` integer NOT NULL DEFAULT 0, `deleteFTPAccount` integer NOT NULL DEFAULT 0, `listFTPAccounts` integer NOT NULL DEFAULT 0, `createBackup` integer NOT NULL DEFAULT 0, `restoreBackup` integer NOT NULL DEFAULT 0, `addDeleteDestinations` integer NOT NULL DEFAULT 0, `scheDuleBackups` integer NOT NULL DEFAULT 0, `remoteBackups` integer NOT NULL DEFAULT 0, `manageSSL` integer NOT NULL DEFAULT 0, `hostnameSSL` integer NOT NULL DEFAULT 0, `mailServerSSL` integer NOT NULL DEFAULT 0)') + 'CREATE TABLE `loginSystem_acl` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(50) NOT NULL UNIQUE, `adminStatus` integer NOT NULL DEFAULT 0, `versionManagement` integer NOT NULL DEFAULT 0, `createNewUser` integer NOT NULL DEFAULT 0, `deleteUser` integer NOT NULL DEFAULT 0, `resellerCenter` integer NOT NULL DEFAULT 0, `changeUserACL` integer NOT NULL DEFAULT 0, `createWebsite` integer NOT NULL DEFAULT 0, `modifyWebsite` integer NOT NULL DEFAULT 0, `suspendWebsite` integer NOT NULL DEFAULT 0, `deleteWebsite` integer NOT NULL DEFAULT 0, `createPackage` integer NOT NULL DEFAULT 0, `deletePackage` integer NOT NULL DEFAULT 0, `modifyPackage` integer NOT NULL DEFAULT 0, `createDatabase` integer NOT NULL DEFAULT 0, `deleteDatabase` integer NOT NULL DEFAULT 0, `listDatabases` integer NOT NULL DEFAULT 0, `createNameServer` integer NOT NULL DEFAULT 0, `createDNSZone` integer NOT NULL DEFAULT 0, `deleteZone` integer NOT NULL DEFAULT 0, `addDeleteRecords` integer NOT NULL DEFAULT 0, `createEmail` integer NOT NULL DEFAULT 0, `deleteEmail` integer NOT NULL DEFAULT 0, `emailForwarding` integer NOT NULL DEFAULT 0, `changeEmailPassword` integer NOT NULL DEFAULT 0, `dkimManager` integer NOT NULL DEFAULT 0, `createFTPAccount` integer NOT NULL DEFAULT 0, `deleteFTPAccount` integer NOT NULL DEFAULT 0, `listFTPAccounts` integer NOT NULL DEFAULT 0, `createBackup` integer NOT NULL DEFAULT 0, `restoreBackup` integer NOT NULL DEFAULT 0, `addDeleteDestinations` integer NOT NULL DEFAULT 0, `scheduleBackups` integer NOT NULL DEFAULT 0, `remoteBackups` integer NOT NULL DEFAULT 0, `manageSSL` integer NOT NULL DEFAULT 0, `hostnameSSL` integer NOT NULL DEFAULT 0, `mailServerSSL` integer NOT NULL DEFAULT 0)') except: pass try: @@ -2412,7 +2412,7 @@ vmail if acl.name == 'admin' or acl.name == 'reseller' or acl.name == 'user': continue elif acl.config == '{}': - acl.config = '{"adminStatus":%s, "versionManagement": %s, "createNewUser": %s, "listUsers": %s, "deleteUser": %s, "resellerCenter": %s, "changeUserACL": %s, "createWebsite": %s, "modifyWebsite": %s, "suspendWebsite": %s, "deleteWebsite": %s, "createPackage": %s, "listPackages": %s, "deletePackage": %s, "modifyPackage": %s, "createDatabase": %s, "deleteDatabase": %s, "listDatabases": %s, "createNameServer": %s, "createDNSZone": %s, "deleteZone": %s, "addDeleteRecords": %s, "createEmail": %s, "listEmails": %s, "deleteEmail": %s, "emailForwarding": %s, "changeEmailPassword": %s, "dkimManager": %s, "createFTPAccount": %s, "deleteFTPAccount": %s, "listFTPAccounts": %s, "createBackup": %s, "restoreBackup": %s, "addDeleteDestinations": %s, "scheDuleBackups": %s, "remoteBackups": %s, "googleDriveBackups": %s, "manageSSL": %s, "hostnameSSL": %s, "mailServerSSL": %s }' \ + acl.config = '{"adminStatus":%s, "versionManagement": %s, "createNewUser": %s, "listUsers": %s, "deleteUser": %s, "resellerCenter": %s, "changeUserACL": %s, "createWebsite": %s, "modifyWebsite": %s, "suspendWebsite": %s, "deleteWebsite": %s, "createPackage": %s, "listPackages": %s, "deletePackage": %s, "modifyPackage": %s, "createDatabase": %s, "deleteDatabase": %s, "listDatabases": %s, "createNameServer": %s, "createDNSZone": %s, "deleteZone": %s, "addDeleteRecords": %s, "createEmail": %s, "listEmails": %s, "deleteEmail": %s, "emailForwarding": %s, "changeEmailPassword": %s, "dkimManager": %s, "createFTPAccount": %s, "deleteFTPAccount": %s, "listFTPAccounts": %s, "createBackup": %s, "restoreBackup": %s, "addDeleteDestinations": %s, "scheduleBackups": %s, "remoteBackups": %s, "googleDriveBackups": %s, "manageSSL": %s, "hostnameSSL": %s, "mailServerSSL": %s }' \ % (str(acl.adminStatus), str(acl.versionManagement), str(acl.createNewUser), str(acl.listUsers), str(acl.deleteUser), str(acl.resellerCenter), str(acl.changeUserACL), str(acl.createWebsite), str(acl.modifyWebsite), str(acl.suspendWebsite), str(acl.deleteWebsite), @@ -2421,7 +2421,7 @@ vmail str(acl.createDNSZone), str(acl.deleteZone), str(acl.addDeleteRecords), str(acl.createEmail), str(acl.listEmails), str(acl.deleteEmail), str(acl.emailForwarding), str(acl.changeEmailPassword), str(acl.dkimManager), str(acl.createFTPAccount), str(acl.deleteFTPAccount), str(acl.listFTPAccounts), - str(acl.createBackup), str(acl.restoreBackup), str(acl.addDeleteDestinations), str(acl.scheDuleBackups), str(acl.remoteBackups), '1', + str(acl.createBackup), str(acl.restoreBackup), str(acl.addDeleteDestinations), str(acl.scheduleBackups), str(acl.remoteBackups), '1', str(acl.manageSSL), str(acl.hostnameSSL), str(acl.mailServerSSL)) acl.save() diff --git a/static/baseTemplate/custom-js/system-status.js b/static/baseTemplate/custom-js/system-status.js index 1f6fe8d9d..00807bd6b 100644 --- a/static/baseTemplate/custom-js/system-status.js +++ b/static/baseTemplate/custom-js/system-status.js @@ -317,8 +317,8 @@ app.controller('adminController', function ($scope, $http, $timeout) { $('.addDeleteDestinations').hide(); } - if (!Boolean(response.data.scheDuleBackups)) { - $('.scheDuleBackups').hide(); + if (!Boolean(response.data.scheduleBackups)) { + $('.scheduleBackups').hide(); } if (!Boolean(response.data.remoteBackups)) { diff --git a/static/userManagment/userManagment.js b/static/userManagment/userManagment.js index 221d0e34b..2e6b3d189 100644 --- a/static/userManagment/userManagment.js +++ b/static/userManagment/userManagment.js @@ -524,7 +524,7 @@ app.controller('createACLCTRL', function ($scope, $http) { $scope.googleDriveBackups = true; $scope.restoreBackup = false; $scope.addDeleteDestinations = false; - $scope.scheDuleBackups = false; + $scope.scheduleBackups = false; $scope.remoteBackups = false; @@ -605,7 +605,7 @@ app.controller('createACLCTRL', function ($scope, $http) { googleDriveBackups: $scope.googleDriveBackups, restoreBackup: $scope.restoreBackup, addDeleteDestinations: $scope.addDeleteDestinations, - scheDuleBackups: $scope.scheDuleBackups, + scheduleBackups: $scope.scheduleBackups, remoteBackups: $scope.remoteBackups, // SSL Management @@ -727,7 +727,7 @@ app.controller('createACLCTRL', function ($scope, $http) { $scope.createBackup = true; $scope.restoreBackup = true; $scope.addDeleteDestinations = true; - $scope.scheDuleBackups = true; + $scope.scheduleBackups = true; $scope.remoteBackups = true; // SSL Management @@ -798,7 +798,7 @@ app.controller('createACLCTRL', function ($scope, $http) { $scope.createBackup = true; $scope.restoreBackup = false; $scope.addDeleteDestinations = false; - $scope.scheDuleBackups = false; + $scope.scheduleBackups = false; $scope.remoteBackups = false; // SSL Management @@ -983,7 +983,7 @@ app.controller('modifyACLCtrl', function ($scope, $http) { $scope.googleDriveBackups = Boolean(response.data.googleDriveBackups); $scope.restoreBackup = Boolean(response.data.restoreBackup); $scope.addDeleteDestinations = Boolean(response.data.addDeleteDestinations); - $scope.scheDuleBackups = Boolean(response.data.scheDuleBackups); + $scope.scheduleBackups = Boolean(response.data.scheduleBackups); $scope.remoteBackups = Boolean(response.data.remoteBackups); // SSL Management @@ -1084,7 +1084,7 @@ app.controller('modifyACLCtrl', function ($scope, $http) { googleDriveBackups: $scope.googleDriveBackups, restoreBackup: $scope.restoreBackup, addDeleteDestinations: $scope.addDeleteDestinations, - scheDuleBackups: $scope.scheDuleBackups, + scheduleBackups: $scope.scheduleBackups, remoteBackups: $scope.remoteBackups, // SSL Management @@ -1206,7 +1206,7 @@ app.controller('modifyACLCtrl', function ($scope, $http) { $scope.createBackup = true; $scope.restoreBackup = true; $scope.addDeleteDestinations = true; - $scope.scheDuleBackups = true; + $scope.scheduleBackups = true; $scope.remoteBackups = true; // SSL Management @@ -1277,7 +1277,7 @@ app.controller('modifyACLCtrl', function ($scope, $http) { $scope.createBackup = true; $scope.restoreBackup = false; $scope.addDeleteDestinations = false; - $scope.scheDuleBackups = false; + $scope.scheduleBackups = false; $scope.remoteBackups = false; // SSL Management diff --git a/userManagment/static/userManagment/userManagment.js b/userManagment/static/userManagment/userManagment.js index 221d0e34b..2e6b3d189 100755 --- a/userManagment/static/userManagment/userManagment.js +++ b/userManagment/static/userManagment/userManagment.js @@ -524,7 +524,7 @@ app.controller('createACLCTRL', function ($scope, $http) { $scope.googleDriveBackups = true; $scope.restoreBackup = false; $scope.addDeleteDestinations = false; - $scope.scheDuleBackups = false; + $scope.scheduleBackups = false; $scope.remoteBackups = false; @@ -605,7 +605,7 @@ app.controller('createACLCTRL', function ($scope, $http) { googleDriveBackups: $scope.googleDriveBackups, restoreBackup: $scope.restoreBackup, addDeleteDestinations: $scope.addDeleteDestinations, - scheDuleBackups: $scope.scheDuleBackups, + scheduleBackups: $scope.scheduleBackups, remoteBackups: $scope.remoteBackups, // SSL Management @@ -727,7 +727,7 @@ app.controller('createACLCTRL', function ($scope, $http) { $scope.createBackup = true; $scope.restoreBackup = true; $scope.addDeleteDestinations = true; - $scope.scheDuleBackups = true; + $scope.scheduleBackups = true; $scope.remoteBackups = true; // SSL Management @@ -798,7 +798,7 @@ app.controller('createACLCTRL', function ($scope, $http) { $scope.createBackup = true; $scope.restoreBackup = false; $scope.addDeleteDestinations = false; - $scope.scheDuleBackups = false; + $scope.scheduleBackups = false; $scope.remoteBackups = false; // SSL Management @@ -983,7 +983,7 @@ app.controller('modifyACLCtrl', function ($scope, $http) { $scope.googleDriveBackups = Boolean(response.data.googleDriveBackups); $scope.restoreBackup = Boolean(response.data.restoreBackup); $scope.addDeleteDestinations = Boolean(response.data.addDeleteDestinations); - $scope.scheDuleBackups = Boolean(response.data.scheDuleBackups); + $scope.scheduleBackups = Boolean(response.data.scheduleBackups); $scope.remoteBackups = Boolean(response.data.remoteBackups); // SSL Management @@ -1084,7 +1084,7 @@ app.controller('modifyACLCtrl', function ($scope, $http) { googleDriveBackups: $scope.googleDriveBackups, restoreBackup: $scope.restoreBackup, addDeleteDestinations: $scope.addDeleteDestinations, - scheDuleBackups: $scope.scheDuleBackups, + scheduleBackups: $scope.scheduleBackups, remoteBackups: $scope.remoteBackups, // SSL Management @@ -1206,7 +1206,7 @@ app.controller('modifyACLCtrl', function ($scope, $http) { $scope.createBackup = true; $scope.restoreBackup = true; $scope.addDeleteDestinations = true; - $scope.scheDuleBackups = true; + $scope.scheduleBackups = true; $scope.remoteBackups = true; // SSL Management @@ -1277,7 +1277,7 @@ app.controller('modifyACLCtrl', function ($scope, $http) { $scope.createBackup = true; $scope.restoreBackup = false; $scope.addDeleteDestinations = false; - $scope.scheDuleBackups = false; + $scope.scheduleBackups = false; $scope.remoteBackups = false; // SSL Management diff --git a/userManagment/templates/userManagment/createACL.html b/userManagment/templates/userManagment/createACL.html index 111cc9deb..e86dd7781 100755 --- a/userManagment/templates/userManagment/createACL.html +++ b/userManagment/templates/userManagment/createACL.html @@ -388,7 +388,7 @@
    diff --git a/userManagment/templates/userManagment/modifyACL.html b/userManagment/templates/userManagment/modifyACL.html index 9c1f3156d..63c093d7e 100755 --- a/userManagment/templates/userManagment/modifyACL.html +++ b/userManagment/templates/userManagment/modifyACL.html @@ -392,7 +392,7 @@
    diff --git a/userManagment/tests.py b/userManagment/tests.py index 8b214fad1..6aad97e29 100755 --- a/userManagment/tests.py +++ b/userManagment/tests.py @@ -155,7 +155,7 @@ class TestUserManagement(TestCase): 'createBackup': 1, 'restoreBackup': 1, 'addDeleteDestinations': 1, - 'scheDuleBackups': 1, + 'scheduleBackups': 1, 'remoteBackups': 1, 'manageSSL': 1, 'hostnameSSL': 1, @@ -221,7 +221,7 @@ class TestUserManagement(TestCase): 'createBackup': 1, 'restoreBackup': 1, 'addDeleteDestinations': 1, - 'scheDuleBackups': 1, + 'scheduleBackups': 1, 'remoteBackups': 1, 'manageSSL': 1, 'hostnameSSL': 1, From d0edbc3e68a4eb10ef2df3a16a301d6e96556837 Mon Sep 17 00:00:00 2001 From: Michael Ramsey Date: Thu, 15 Apr 2021 22:08:48 -0400 Subject: [PATCH 5/6] Updated to add BackupRetention to IncBackup and Backup models and script for future use --- IncBackups/models.py | 7 +++---- IncBackups/static/IncBackups/IncBackups.js | 1 + .../templates/IncBackups/backupSchedule.html | 14 +++++++++++++- IncBackups/views.py | 5 ++++- backup/backupManager.py | 11 ++++++++++- backup/static/backup/backup.js | 9 ++++++--- backup/templates/backup/backupSchedule.html | 17 ++++++++++++++--- 7 files changed, 51 insertions(+), 13 deletions(-) diff --git a/IncBackups/models.py b/IncBackups/models.py index f75aafaaf..0b806b6d7 100644 --- a/IncBackups/models.py +++ b/IncBackups/models.py @@ -1,13 +1,13 @@ - - from django.db import models from websiteFunctions.models import Websites from datetime import datetime + class IncJob(models.Model): website = models.ForeignKey(Websites, on_delete=models.CASCADE) date = models.DateTimeField(default=datetime.now, blank=True) + class JobSnapshots(models.Model): job = models.ForeignKey(IncJob, on_delete=models.CASCADE) type = models.CharField(max_length=300) @@ -21,10 +21,9 @@ class BackupJob(models.Model): websiteData = models.IntegerField() websiteDatabases = models.IntegerField() websiteDataEmails = models.IntegerField() + retention = models.IntegerField() class JobSites(models.Model): job = models.ForeignKey(BackupJob, on_delete=models.CASCADE) website = models.CharField(max_length=300) - - diff --git a/IncBackups/static/IncBackups/IncBackups.js b/IncBackups/static/IncBackups/IncBackups.js index 9031c393d..79b13571e 100644 --- a/IncBackups/static/IncBackups/IncBackups.js +++ b/IncBackups/static/IncBackups/IncBackups.js @@ -599,6 +599,7 @@ app.controller('scheduleBackupInc', function ($scope, $http) { var data = { backupDestinations: $scope.backupDest, backupFreq: $scope.backupFreq, + backupRetention: $scope.backupRetention, websiteData: $scope.websiteData, websiteEmails: $scope.websiteEmails, websiteDatabases: $scope.websiteDatabases, diff --git a/IncBackups/templates/IncBackups/backupSchedule.html b/IncBackups/templates/IncBackups/backupSchedule.html index 7724ca483..54827c781 100755 --- a/IncBackups/templates/IncBackups/backupSchedule.html +++ b/IncBackups/templates/IncBackups/backupSchedule.html @@ -10,7 +10,7 @@
    -

    {% trans "Schedule Back up" %} - {% trans "Schedule Back up" %} - {% trans "Remote Backups" %}

    @@ -50,6 +50,18 @@
    +
    + +
    +
    + +
    +
    +
    + +
    diff --git a/IncBackups/views.py b/IncBackups/views.py index 27968b0de..191e65b2d 100644 --- a/IncBackups/views.py +++ b/IncBackups/views.py @@ -524,6 +524,7 @@ def submit_backup_schedule(request): backup_dest = data['backupDestinations'] backup_freq = data['backupFreq'] + backup_retention = data['backupRetention'] backup_sites = data['websitesToBeBacked'] backup_data = 1 if 'websiteData' in data else 0 @@ -531,7 +532,8 @@ def submit_backup_schedule(request): backup_databases = 1 if 'websiteDatabases' in data else 0 backup_job = BackupJob(websiteData=backup_data, websiteDataEmails=backup_emails, - websiteDatabases=backup_databases, destination=backup_dest, frequency=backup_freq) + websiteDatabases=backup_databases, destination=backup_dest, frequency=backup_freq, + retention=backup_retention) backup_job.save() for site in backup_sites: @@ -558,6 +560,7 @@ def get_current_backup_schedules(request): json_data.append({'id': items.id, 'destination': items.destination, 'frequency': items.frequency, + 'retention': items.retention, 'numberOfSites': items.jobsites_set.all().count() }) final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) diff --git a/backup/backupManager.py b/backup/backupManager.py index da92d6198..21314a4b2 100755 --- a/backup/backupManager.py +++ b/backup/backupManager.py @@ -886,6 +886,7 @@ class BackupManager: selectedAccount = data['selectedAccount'] name = data['name'] backupFrequency = data['backupFrequency'] + backupRetention = data['backupRetention'] currentACL = ACLManager.loadedACL(userID) @@ -894,7 +895,8 @@ class BackupManager: nbd = NormalBackupDests.objects.get(name=selectedAccount) - config = {'frequency': backupFrequency} + config = {'frequency': backupFrequency, + 'retention': backupRetention} nbj = NormalBackupJobs(owner=nbd, name=name, config=json.dumps(config)) nbj.save() @@ -1465,6 +1467,11 @@ class BackupManager: except: frequency = 'Never' + try: + retention = config[IncScheduler.retention] + except: + retention = 'Never' + try: currentStatus = config[IncScheduler.currentStatus] except: @@ -1615,6 +1622,7 @@ class BackupManager: selectedJob = data['selectedJob'] backupFrequency = data['backupFrequency'] + backupRetention = data['backupRetention'] nbj = NormalBackupJobs.objects.get(name=selectedJob) @@ -1623,6 +1631,7 @@ class BackupManager: config = json.loads(nbj.config) config[IncScheduler.frequency] = backupFrequency + config[IncScheduler.retention] = backupRetention nbj.config = json.dumps(config) nbj.save() diff --git a/backup/static/backup/backup.js b/backup/static/backup/backup.js index 49980c5f9..92ccab6a5 100755 --- a/backup/static/backup/backup.js +++ b/backup/static/backup/backup.js @@ -1247,7 +1247,8 @@ app.controller('googleDrive', function ($scope, $http) { }; var data = { selectedAccount: $scope.selectedAccount, - backupFrequency: $scope.backupFrequency + backupFrequency: $scope.backupFrequency, + backupRetention: $scope.backupRetention, }; dataurl = "/backup/changeAccountFrequencygDrive"; @@ -1654,7 +1655,8 @@ app.controller('scheduleBackup', function ($scope, $http, $window) { var data = { selectedAccount: $scope.selectedAccountAdd, name: $scope.name, - backupFrequency: $scope.backupFrequency + backupFrequency: $scope.backupFrequency, + backupRetention: $scope.backupRetention, }; dataurl = "/backup/submitBackupSchedule"; @@ -1856,7 +1858,8 @@ app.controller('scheduleBackup', function ($scope, $http, $window) { }; var data = { selectedJob: $scope.selectedJob, - backupFrequency: $scope.backupFrequency + backupFrequency: $scope.backupFrequency, + backupRetention: $scope.backupRetention, }; dataurl = "/backup/changeAccountFrequencyNormal"; diff --git a/backup/templates/backup/backupSchedule.html b/backup/templates/backup/backupSchedule.html index 61e71f478..29dab1bd3 100755 --- a/backup/templates/backup/backupSchedule.html +++ b/backup/templates/backup/backupSchedule.html @@ -12,7 +12,7 @@

    {% trans "Schedule Back up" %} - {% trans "Remote Backups" %} @@ -24,7 +24,7 @@

    {% trans "Create New Backup Schedule" %} + src="{% static 'images/loading.gif' %}" alt="cyberPanelLoading">

    @@ -61,6 +61,16 @@
    +
    + +
    +
    + +
    +
    +
    @@ -81,7 +91,7 @@

    {% trans "Manage Existing Back up Schedules" %} + src="{% static 'images/loading.gif' %}" alt="cyberPanelLoading">

    @@ -133,6 +143,7 @@ Last Run All Sites Frequency ({$ currently $}) + Retention ({$ currently $}) Current Status From fc49994c6a39ebb4da0807dd0637d6fc6c823728 Mon Sep 17 00:00:00 2001 From: WhatTheServer Date: Fri, 16 Apr 2021 08:34:30 -0400 Subject: [PATCH 6/6] Update models.py add missing default of 0 being unlimited retention. --- IncBackups/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IncBackups/models.py b/IncBackups/models.py index 0b806b6d7..9e87e6aec 100644 --- a/IncBackups/models.py +++ b/IncBackups/models.py @@ -21,7 +21,7 @@ class BackupJob(models.Model): websiteData = models.IntegerField() websiteDatabases = models.IntegerField() websiteDataEmails = models.IntegerField() - retention = models.IntegerField() + retention = models.IntegerField(default=0) # 0 being unlimited retention class JobSites(models.Model):