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/CLManager/CageFS.py b/CLManager/CageFS.py index 17713a6b8..ee4991d6b 100644 --- a/CLManager/CageFS.py +++ b/CLManager/CageFS.py @@ -243,10 +243,6 @@ def main(): elif args["function"] == "submitinstallImunifyAV": CageFS.submitinstallImunifyAV() - - - - if __name__ == "__main__": main() diff --git a/CLManager/urls.py b/CLManager/urls.py index 957d19638..0f2aff59c 100644 --- a/CLManager/urls.py +++ b/CLManager/urls.py @@ -6,8 +6,8 @@ urlpatterns = [ url(r'^listPackages$', views.listPackages, name='listPackagesCL'), url(r'^monitorUsage$', views.monitorUsage, name='monitorUsage'), url(r'^CageFS$', views.CageFS, name='CageFS'), + url(r'^submitCageFSInstall$', views.submitCageFSInstall, name='submitCageFSInstall'), - # url(r'^submitCageFSInstall$', views.submitCageFSInstall, name='submitCageFSInstall'), # url(r'^submitWebsiteListing$', views.getFurtherAccounts, name='submitWebsiteListing'), # url(r'^enableOrDisable$', views.enableOrDisable, name='enableOrDisable'), # url(r'^submitCreatePackage$', views.submitCreatePackage, name='submitCreatePackageCL'), diff --git a/IncBackups/IncBackups.py b/IncBackups/IncBackups.py index fbb5807e4..cbabdd047 100644 --- a/IncBackups/IncBackups.py +++ b/IncBackups/IncBackups.py @@ -219,9 +219,16 @@ class IncJobs(multi.Thread): try: logging.statusWriter(self.statusPath, 'Backing up data..', 1) + backupPath = '/home/%s' % (self.website.domain) + # Define our excludes file for use with restic + backupExcludesFile = '/home/%s/backup-exclude.conf' % (self.website.domain) + resticBackupExcludeCMD = ' --exclude-file=%s' % (backupExcludesFile) + if self.backupDestinations == 'local': - backupPath = '/home/%s' % (self.website.domain) command = 'restic -r %s backup %s --password-file %s --exclude %s' % (self.repoPath, backupPath, self.passwordFile, self.repoPath) + # If /home/%s/backup-exclude.conf file exists lets pass this to restic by appending the command to end. + if os.path.isfile(backupExcludesFile): + command = command + resticBackupExcludeCMD snapShotid = ProcessUtilities.outputExecutioner(command).split(' ')[-2] newSnapshot = JobSnapshots(job=self.jobid, type='data:%s' % (backupPath), snapshotid=snapShotid, destination=self.backupDestinations) @@ -230,8 +237,10 @@ class IncJobs(multi.Thread): elif self.backupDestinations[:4] == 'sftp': remotePath = '/home/backup/%s' % (self.website.domain) - backupPath = '/home/%s' % (self.website.domain) command = 'export PATH=${PATH}:/usr/bin && restic -r %s:%s backup %s --password-file %s --exclude %s' % (self.backupDestinations, remotePath, backupPath, self.passwordFile, self.repoPath) + # If /home/%s/backup-exclude.conf file exists lets pass this to restic by appending the command to end. + if os.path.isfile(backupExcludesFile): + command = command + resticBackupExcludeCMD snapShotid = ProcessUtilities.outputExecutioner(command).split(' ')[-2] newSnapshot = JobSnapshots(job=self.jobid, type='data:%s' % (remotePath), snapshotid=snapShotid, destination=self.backupDestinations) @@ -312,13 +321,23 @@ class IncJobs(multi.Thread): try: logging.statusWriter(self.statusPath, 'Will first initiate backup repo..', 1) + # Define our excludes file for use with restic + backupExcludesFile = '/home/%s/backup-exclude.conf' % (self.website.domain) + resticBackupExcludeCMD = ' --exclude-file=%s' % (backupExcludesFile) + if self.backupDestinations == 'local': command = 'restic init --repo %s --password-file %s' % (self.repoPath, self.passwordFile) + # If /home/%s/backup-exclude.conf file exists lets pass this to restic by appending the command to end. + if os.path.isfile(backupExcludesFile): + command = command + resticBackupExcludeCMD ProcessUtilities.executioner(command, self.website.externalApp) elif self.backupDestinations[:4] == 'sftp': remotePath = '/home/backup/%s' % (self.website.domain) command = 'export PATH=${PATH}:/usr/bin && restic init --repo %s:%s --password-file %s' % (self.backupDestinations, remotePath, self.passwordFile) + # If /home/%s/backup-exclude.conf file exists lets pass this to restic by appending the command to end. + if os.path.isfile(backupExcludesFile): + command = command + resticBackupExcludeCMD ProcessUtilities.executioner(command) logging.statusWriter(self.statusPath, 'Repo %s initiated for %s.' % (self.backupDestinations, self.website.domain), 1) diff --git a/IncBackups/IncBackupsControl.py b/IncBackups/IncBackupsControl.py index c62152edc..1aebbb7b9 100644 --- a/IncBackups/IncBackupsControl.py +++ b/IncBackups/IncBackupsControl.py @@ -1,8 +1,10 @@ #!/usr/local/CyberCP/bin/python import os import os.path +import shlex +import subprocess import sys - +import requests sys.path.append('/usr/local/CyberCP') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") @@ -138,9 +140,16 @@ class IncJobs(multi.Thread): if fType == 'backup': key, secret = self.getAWSData() + # Define our excludes file for use with restic + backupExcludesFile = '/home/%s/backup-exclude.conf' % (self.website.domain) + resticBackupExcludeCMD = ' --exclude-file=%s' % (backupExcludesFile) + command = 'export AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s && restic -r s3:s3.amazonaws.com/%s backup %s --password-file %s' % ( key, secret, self.website.domain, backupPath, self.passwordFile) + # If /home/%s/backup-exclude.conf file exists lets pass this to restic by appending the command to end. + if os.path.isfile(backupExcludesFile): + command = command + resticBackupExcludeCMD result = ProcessUtilities.outputExecutioner(command) if result.find('saved') == -1: @@ -198,8 +207,15 @@ class IncJobs(multi.Thread): def localFunction(self, backupPath, type, restore=None): if restore == None: + # Define our excludes file for use with restic + backupExcludesFile = '/home/%s/backup-exclude.conf' % (self.website.domain) + resticBackupExcludeCMD = ' --exclude-file=%s' % (backupExcludesFile) + command = 'restic -r %s backup %s --password-file %s --exclude %s' % ( self.repoPath, backupPath, self.passwordFile, self.repoPath) + # If /home/%s/backup-exclude.conf file exists lets pass this to restic by appending the command to end. + if os.path.isfile(backupExcludesFile): + command = command + resticBackupExcludeCMD result = ProcessUtilities.outputExecutioner(command) if result.find('saved') == -1: @@ -233,9 +249,15 @@ class IncJobs(multi.Thread): def sftpFunction(self, backupPath, type, restore=None): if restore == None: + # Define our excludes file for use with restic + backupExcludesFile = '/home/%s/backup-exclude.conf' % (self.website.domain) + resticBackupExcludeCMD = ' --exclude-file=%s' % (backupExcludesFile) remotePath = '/home/backup/%s' % (self.website.domain) command = 'export PATH=${PATH}:/usr/bin && restic -r %s:%s backup %s --password-file %s --exclude %s' % ( self.backupDestinations, remotePath, backupPath, self.passwordFile, self.repoPath) + # If /home/%s/backup-exclude.conf file exists lets pass this to restic by appending the command to end. + if os.path.isfile(backupExcludesFile): + command = command + resticBackupExcludeCMD result = ProcessUtilities.outputExecutioner(command) if result.find('saved') == -1: @@ -840,9 +862,32 @@ Subject: %s command = 'restic' if ProcessUtilities.outputExecutioner(command).find('restic is a backup program which') == -1: - logging.statusWriter(self.statusPath, 'It seems restic is not installed, for incremental backups to work ' - 'restic must be installed. You can manually install restic using this ' - 'guide -> http://go.cyberpanel.net/restic. [5009]', 1) + try: + + CentOSPath = '/etc/redhat-release' + + if os.path.exists(CentOSPath): + command = 'yum install -y yum-plugin-copr' + ProcessUtilities.executioner(command) + command = 'yum copr enable -y copart/restic' + ProcessUtilities.executioner(command) + command = 'yum install -y restic' + ProcessUtilities.executioner(command) + + else: + command = 'apt-get update -y' + ProcessUtilities.executioner(command) + + command = 'apt-get install restic -y' + ProcessUtilities.executioner(command) + + except: + logging.statusWriter(self.statusPath, + 'It seems restic is not installed, for incremental backups to work ' + 'restic must be installed. You can manually install restic using this ' + 'guide -> https://go.cyberpanel.net/restic. [5009]', 1) + pass + return 0 ## Restic check completed. diff --git a/IncBackups/models.py b/IncBackups/models.py index f75aafaaf..9e87e6aec 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(default=0) # 0 being unlimited retention 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 399cd0bfd..191e65b2d 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,13 +517,14 @@ 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) 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: @@ -548,7 +550,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() @@ -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}) @@ -571,7 +574,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 +599,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 +636,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 +664,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 +685,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..21314a4b2 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() @@ -886,15 +886,17 @@ class BackupManager: selectedAccount = data['selectedAccount'] name = data['name'] backupFrequency = data['backupFrequency'] + backupRetention = data['backupRetention'] 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) - config = {'frequency': backupFrequency} + config = {'frequency': backupFrequency, + 'retention': backupRetention} nbj = NormalBackupJobs(owner=nbd, name=name, config=json.dumps(config)) nbj.save() @@ -910,7 +912,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 +1415,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) @@ -1465,6 +1467,11 @@ class BackupManager: except: frequency = 'Never' + try: + retention = config[IncScheduler.retention] + except: + retention = 'Never' + try: currentStatus = config[IncScheduler.currentStatus] except: @@ -1499,7 +1506,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 +1533,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 +1594,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: @@ -1615,14 +1622,16 @@ class BackupManager: selectedJob = data['selectedJob'] backupFrequency = data['backupFrequency'] + backupRetention = data['backupRetention'] 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) config[IncScheduler.frequency] = backupFrequency + config[IncScheduler.retention] = backupRetention nbj.config = json.dumps(config) nbj.save() @@ -1649,7 +1658,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 +1685,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/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 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..12bdef14e 100755 --- a/baseTemplate/templates/baseTemplate/index.html +++ b/baseTemplate/templates/baseTemplate/index.html @@ -506,7 +506,7 @@ {% endif %} {% if admin or createDatabase %} -
  • {% trans "PHPMYAdmin" %}
  • {% endif %} @@ -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/cli/cyberPanel.py b/cli/cyberPanel.py index 939f0b7e5..f17755e51 100755 --- a/cli/cyberPanel.py +++ b/cli/cyberPanel.py @@ -1,7 +1,9 @@ #!/usr/local/CyberCP/bin/python -import os,sys +import os, sys + sys.path.append('/usr/local/CyberCP') import django + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") django.setup() from inspect import stack @@ -27,12 +29,19 @@ from plogical.backupSchedule import backupSchedule # All that we see or seem is but a dream within a dream. +def get_cyberpanel_version(): + with open('/usr/local/CyberCP/version.txt') as version: + version_file = version.read() + version = json.loads(str(version_file)) + return f"{version['version']}.{version['build']}" + + class cyberPanel: def printStatus(self, operationStatus, errorMessage): data = json.dumps({'success': operationStatus, 'errorMessage': errorMessage - }) + }) print(data) ## Website Functions @@ -42,10 +51,10 @@ class cyberPanel: from random import randint externalApp = "".join(re.findall("[a-zA-Z]+", domainName))[:5] + str(randint(1000, 9999)) phpSelection = 'PHP ' + php - + try: counter = 0 - _externalApp=externalApp + _externalApp = externalApp while True: tWeb = Websites.objects.get(externalApp=externalApp) externalApp = '%s%s' % (_externalApp, str(counter)) @@ -55,10 +64,10 @@ class cyberPanel: time.sleep(2) result = virtualHostUtilities.createVirtualHost(domainName, email, phpSelection, externalApp, ssl, dkim, - openBasedir, owner, package, 0) + openBasedir, owner, package, 0) if result[0] == 1: - self.printStatus(1,'None') + self.printStatus(1, 'None') else: self.printStatus(0, result[1]) @@ -72,10 +81,11 @@ class cyberPanel: path = '/home/' + masterDomain + '/public_html/' + domainName phpSelection = 'PHP ' + php - result = virtualHostUtilities.createDomain(masterDomain, domainName, phpSelection, path, ssl, dkim, openBasedir, owner, 0) + result = virtualHostUtilities.createDomain(masterDomain, domainName, phpSelection, path, ssl, dkim, + openBasedir, owner, 0) if result[0] == 1: - self.printStatus(1,'None') + self.printStatus(1, 'None') else: self.printStatus(0, result[1]) @@ -98,7 +108,7 @@ class cyberPanel: result = virtualHostUtilities.deleteDomain(childDomain) if result[0] == 1: - self.printStatus(1,'None') + self.printStatus(1, 'None') else: self.printStatus(0, result[1]) @@ -123,13 +133,14 @@ class cyberPanel: state = "Suspended" else: state = "Active" - dic = {'domain': items.domain, 'adminEmail': items.adminEmail,'ipAddress':ipAddress,'admin': items.admin.userName,'package': items.package.packageName,'state':state} + dic = {'domain': items.domain, 'adminEmail': items.adminEmail, 'ipAddress': ipAddress, + 'admin': items.admin.userName, 'package': items.package.packageName, 'state': state} if checker == 0: json_data = json_data + json.dumps(dic) checker = 1 else: - json_data = json_data +',' + json.dumps(dic) + json_data = json_data + ',' + json.dumps(dic) json_data = json_data + ']' final_json = json.dumps(json_data) @@ -149,14 +160,16 @@ class cyberPanel: ipData = f.read() ipAddress = ipData.split('\n', 1)[0] - table = PrettyTable(['ID','Domain', 'IP Address', 'Package', 'Owner', 'State', 'Email']) + table = PrettyTable(['ID', 'Domain', 'IP Address', 'Package', 'Owner', 'State', 'Email']) for items in websites: if items.state == 0: state = "Suspended" else: state = "Active" - table.add_row([items.id, items.domain, ipAddress, items.package.packageName, items.admin.userName, state, items.adminEmail]) + table.add_row( + [items.id, items.domain, ipAddress, items.package.packageName, items.admin.userName, state, + items.adminEmail]) print(table) except BaseException as msg: @@ -174,7 +187,7 @@ class cyberPanel: result = vhost.changePHP(completePathToConfigFile, phpVersion) if result[0] == 1: - self.printStatus(1,'None') + self.printStatus(1, 'None') else: self.printStatus(0, result[1]) @@ -338,7 +351,7 @@ class cyberPanel: # Setup default backup path to /home//backup if not passed in if backupPath is None: backupPath = '/home/' + virtualHostName + '/backup' - + # remove trailing slash in path backupPath = backupPath.rstrip("/") backuptime = time.strftime("%m.%d.%Y_%H-%M-%S") @@ -387,7 +400,8 @@ class cyberPanel: ## Packages - def createPackage(self, owner, packageName, diskSpace, bandwidth, emailAccounts, dataBases, ftpAccounts, allowedDomains): + def createPackage(self, owner, packageName, diskSpace, bandwidth, emailAccounts, dataBases, ftpAccounts, + allowedDomains): try: admin = Administrator.objects.get(userName=owner) @@ -431,7 +445,7 @@ class cyberPanel: 'bandwidth': items.bandwidth, 'ftpAccounts ': items.ftpAccounts, 'dataBases': items.dataBases, - 'emailAccounts':items.emailAccounts + 'emailAccounts': items.emailAccounts } if checker == 0: @@ -454,10 +468,13 @@ class cyberPanel: records = Package.objects.all() - table = PrettyTable(['Name', 'Domains', 'Disk Space', 'Bandwidth', 'FTP Accounts', 'Databases', 'Email Accounts']) + table = PrettyTable( + ['Name', 'Domains', 'Disk Space', 'Bandwidth', 'FTP Accounts', 'Databases', 'Email Accounts']) for items in records: - table.add_row([items.packageName, items.allowedDomains, items.diskSpace, items.bandwidth, items.ftpAccounts, items.dataBases, items.emailAccounts]) + table.add_row( + [items.packageName, items.allowedDomains, items.diskSpace, items.bandwidth, items.ftpAccounts, + items.dataBases, items.emailAccounts]) print(table) except BaseException as msg: @@ -584,8 +601,8 @@ class cyberPanel: for items in records: dic = { - 'email': items.email, - } + 'email': items.email, + } if checker == 0: json_data = json_data + json.dumps(dic) @@ -857,7 +874,8 @@ def main(): else: openBasedir = 0 - cyberpanel.createWebsite(args.package, args.owner, args.domainName, args.email, args.php, ssl, dkim, openBasedir) + cyberpanel.createWebsite(args.package, args.owner, args.domainName, args.email, args.php, ssl, dkim, + openBasedir) elif args.function == "deleteWebsite": completeCommandExample = 'cyberpanel deleteWebsite --domainName cyberpanel.net' @@ -1086,8 +1104,6 @@ def main(): print("\n\nPlease enter value for Allowed Child Domains. For example:\n\n" + completeCommandExample + "\n\n") return - - cyberpanel.createPackage(args.owner, args.packageName, args.diskSpace, args.bandwidth, args.emailAccounts, args.dataBases, args.ftpAccounts, args.allowedDomains) elif args.function == "deletePackage": @@ -1334,14 +1350,7 @@ def main(): ProcessUtilities.executioner(command) elif args.function == 'version' or args.function == 'v' or args.function == 'V': ## Get CurrentVersion - with open('/usr/local/CyberCP/version.txt') as file: - file_contents = file.read() - version = re.search('\d.\d', file_contents) - version = version.group() - build = file_contents[-2:] - build = build[0:1] - currentversion = version + '.' + build - print (currentversion) + print(get_cyberpanel_version()) ### User Functions @@ -1574,6 +1583,5 @@ def main(): wm.installJoomla(1, data) - if __name__ == "__main__": main() diff --git a/cloudAPI/cloudManager.py b/cloudAPI/cloudManager.py index 0d98b6e7a..3f51e466d 100755 --- a/cloudAPI/cloudManager.py +++ b/cloudAPI/cloudManager.py @@ -2970,3 +2970,35 @@ class CloudManager: final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) + + def CheckMasterNode(self): + try: + + command = 'systemctl status mysql' + result = ProcessUtilities.outputExecutioner(command) + + if result.find('active (running)') > -1: + final_json = json.dumps({'status': 1}) + else: + final_json = json.dumps({'status': 0, 'error_message': 'MySQL on Main node is not running.'}) + + return HttpResponse(final_json) + + except BaseException as msg: + final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + + def SyncToMaster(self): + try: + + command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/ClusterManager.py --function SyncToMaster --type Failover' + ProcessUtilities.executioner(command) + + final_json = json.dumps({'status': 1}) + return HttpResponse(final_json) + + except BaseException as msg: + final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) diff --git a/cloudAPI/views.py b/cloudAPI/views.py index 758977737..fbfb9e185 100755 --- a/cloudAPI/views.py +++ b/cloudAPI/views.py @@ -50,8 +50,12 @@ def router(request): return cm.DetachCluster() elif controller == 'DebugCluster': return cm.DebugCluster() + elif controller == 'CheckMasterNode': + return cm.CheckMasterNode() elif controller == 'UptimeMonitor': return cm.UptimeMonitor() + elif controller == 'SyncToMaster': + return cm.SyncToMaster() elif controller == 'FetchMasterBootStrapStatus': return cm.FetchMasterBootStrapStatus() elif controller == 'FetchChildBootStrapStatus': diff --git a/cyberpanel.sh b/cyberpanel.sh index 53c348e2f..bee93ea7a 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -19,7 +19,7 @@ #Check_OS() ---> check system , support on centos7/8 ubutnu18/20 and cloudlinux 7 , 8 is untested. #Check_Virualization() ---> check for virtualizaon , LXC not suppoed , some edit needed on OVZ #Check_Panel() ---> check to make sure no other panel is installed -#Check_Porcess() ---> check no other process like apache is running +#Check_Process() ---> check no other process like apache is running #Check_Provider() ---> check the provider, certain provider like Alibaba or tencent yun may need some special change #Check_Argument() ---> parse argument and go to Argument_Mode() or Interactive_Mode() respectively #Pre_Install_Setup_Repository() ---> setup/install repositories for centos system. @@ -236,27 +236,29 @@ fi if grep -q -E "CentOS Linux 7|CentOS Linux 8" /etc/os-release ; then Server_OS="CentOS" +elif grep -q "AlmaLinux-8" /etc/os-release ; then + Server_OS="AlmaLinux" elif grep -q -E "CloudLinux 7|CloudLinux 8" /etc/os-release ; then Server_OS="CloudLinux" -elif grep -q -E "Ubuntu 18.04|Ubuntu 20.04" /etc/os-release ; then +elif grep -q -E "Ubuntu 18.04|Ubuntu 20.04|Ubuntu 20.10" /etc/os-release ; then Server_OS="Ubuntu" else echo -e "Unable to detect your system..." - echo -e "\nCyberPanel is supported on Ubuntu 18.04 x86_64, Ubuntu 20.04 x86_64, CentOS 7.x, CentOS 8.x and CloudLinux 7.x...\n" - Debug_Log2 "CyberPanel is supported on Ubuntu 18.04 x86_64, Ubuntu 20.04 x86_64, CentOS 7.x, CentOS 8.x and CloudLinux 7.x... [404]" + echo -e "\nCyberPanel is supported on Ubuntu 18.04 x86_64, Ubuntu 20.04 x86_64, Ubuntu 20.10 x86_64, CentOS 7.x, CentOS 8.x, AlmaLinux 8.x and CloudLinux 7.x...\n" + Debug_Log2 "CyberPanel is supported on Ubuntu 18.04 x86_64, Ubuntu 20.04 x86_64, Ubuntu 20.10 x86_64, CentOS 7.x, CentOS 8.x, AlmaLinux 8.x and CloudLinux 7.x... [404]" exit fi -Server_OS_Version=$(grep VERSION_ID /etc/os-release | awk -F[=,] '{print $2}' | tr -d \" | head -c2) +Server_OS_Version=$(grep VERSION_ID /etc/os-release | awk -F[=,] '{print $2}' | tr -d \" | head -c2 | tr -d . ) #to make 20.04 display as 20 echo -e "System: $Server_OS $Server_OS_Version detected...\n" -if [[ $Server_OS = "CloudLinux" ]] ; then +if [[ $Server_OS = "CloudLinux" ]] || [[ "$Server_OS" = "AlmaLinux" ]] ; then Server_OS_Version=$(grep VERSION_ID /etc/os-release | awk -F[=,] '{print $2}' | tr -d \" | cut -c1-1) Server_OS="CentOS" #CloudLinux gives version id like 7.8 , 7.9 , so cut it to show first number only - #then treat it as CentOS system. + #treat CL and Alma as CentOS fi if [[ "$Debug" = "On" ]] ; then @@ -321,7 +323,7 @@ elif [[ -d /etc/httpd/conf/plesk.conf.d/ ]] || [[ -d /etc/apache2/plesk.conf.d/ fi } -Check_Porcess() { +Check_Process() { if systemctl is-active --quiet httpd; then systemctl disable httpd systemctl stop httpd @@ -806,6 +808,11 @@ if [[ $Server_OS = "CentOS" ]] ; then yum autoremove -y epel-release rm -f /etc/yum.repos.d/epel.repo rm -f /etc/yum.repos.d/epel.repo.rpmsave + + yum install -y yum-plugin-copr + Check_Return "yum repo" "no_exit" + yum copr enable -y copart/restic + Check_Return "yum repo" "no_exit" if [[ "$Server_OS_Version" = "8" ]]; then @@ -847,11 +854,6 @@ EOF yum install --nogpg -y https://cyberpanel.sh/mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm Check_Return "yum repo" "no_exit" - yum install -y yum-plugin-copr - Check_Return "yum repo" "no_exit" - yum copr enable -y copart/restic - Check_Return "yum repo" "no_exit" - rpm -ivh https://cyberpanel.sh/repo.iotti.biz/CentOS/7/noarch/lux-release-7-1.noarch.rpm Check_Return "yum repo" "no_exit" @@ -1545,6 +1547,7 @@ fi } Post_Install_Display_Final_Info() { +RainloopAdminPass=$(grep SetPassword /usr/local/CyberCP/public/rainloop.php| sed -e 's|$oConfig->SetPassword(||g' -e "s|');||g" -e "s|'||g") Elapsed_Time="$((Time_Count / 3600)) hrs $(((SECONDS / 60) % 60)) min $((Time_Count % 60)) sec" echo "###################################################################" echo " CyberPanel Successfully Installed " @@ -1553,7 +1556,7 @@ echo " Current Disk usage : $(df -h | awk '$NF=="/"{printf "%d/%d echo " " echo " Current RAM usage : $(free -m | awk 'NR==2{printf "%s/%sMB (%.2f%%)\n", $3,$2,$3*100/$2 }') " echo " " -echo " Installation time : $Elapsed_Time " +echo " Installation time : $Elapsed_Time " echo " " echo " Visit: https://$Server_IP:8090 " echo " Panel username: admin " @@ -1562,8 +1565,13 @@ echo " Panel password: ***** " else echo " Panel password: $Admin_Pass " fi -echo " WebAdmin console username: admin " -echo " WebAdmin console password: $Webadmin_Pass " +echo " Visit: https://$Server_IP:7080 " +echo " WebAdmin console username: admin " +echo " WebAdmin console password: $Webadmin_Pass " +echo " " +echo " Visit: https://$Server_IP:8090/rainloop/?admin " +echo " Rainloop Admin username: admin " +echo " Rainloop Admin password: $RainloopAdminPass " echo " " echo -e " Run \e[31mcyberpanel help\e[39m to get FAQ info" echo -e " Run \e[31mcyberpanel upgrade\e[39m to upgrade it to latest version." @@ -1572,6 +1580,7 @@ echo " " echo " Website : https://www.cyberpanel.net " echo " Forums : https://forums.cyberpanel.net " echo " Wikipage: https://docs.cyberpanel.net " +echo " Docs : https://cyberpanel.net/docs/ " echo " " echo -e " Enjoy your accelerated Internet by " echo -e " CyberPanel & $Word " @@ -1774,6 +1783,10 @@ if [[ "$Server_Country" = "CN" ]] ; then Post_Install_CN_Replacement fi +# If valid hostname that resolves where we can issue an ssl we will create the hostname as a website so we can issue the SSL and do our first login without SSL warnings or exceptions needed. +HostName=$(hostname --fqdn); [ -z "$(dig +short "$HostName")" ] && echo "$HostName resolves to valid IP. Setting up hostname SSL" && cyberpanel createWebsite --package Default --owner admin --domainName $(hostname --fqdn) --email root@localhost --php 7.4 && cyberpanel hostNameSSL --domainName $(hostname --fqdn) + + } Post_Install_CN_Replacement() { @@ -1805,7 +1818,7 @@ Check_Virualization Check_Panel -Check_Porcess +Check_Process Check_Provider diff --git a/databases/templates/databases/phpMyAdmin.html b/databases/templates/databases/phpMyAdmin.html index 00a192ae6..709a0ba8b 100755 --- a/databases/templates/databases/phpMyAdmin.html +++ b/databases/templates/databases/phpMyAdmin.html @@ -24,12 +24,15 @@

    {% trans "Auto-login for PHPMYAdmin is now supported. Click the button below to generate auto-access for PHPMYAdmin" %}


    - +
    - + +
    -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/dns/dnsManager.py b/dns/dnsManager.py index cba1aa73c..92dac0f9e 100755 --- a/dns/dnsManager.py +++ b/dns/dnsManager.py @@ -269,7 +269,7 @@ class DNSManager: if recordType == "A": - recordContentA = data['recordContentA'] ## IP or ponting value + recordContentA = data['recordContentA'] ## IP or pointing value if recordName == "@": value = zoneDomain @@ -309,7 +309,7 @@ class DNSManager: else: value = recordName + "." + zoneDomain - recordContentAAAA = data['recordContentAAAA'] ## IP or ponting value + recordContentAAAA = data['recordContentAAAA'] ## IP or pointing value DNS.createDNSRecord(zone, value, recordType, recordContentAAAA, 0, ttl) @@ -324,7 +324,7 @@ class DNSManager: else: value = recordName + "." + zoneDomain - recordContentCNAME = data['recordContentCNAME'] ## IP or ponting value + recordContentCNAME = data['recordContentCNAME'] ## IP or pointing value DNS.createDNSRecord(zone, value, recordType, recordContentCNAME, 0, ttl) @@ -339,7 +339,7 @@ class DNSManager: else: value = recordName + "." + zoneDomain - recordContentSPF = data['recordContentSPF'] ## IP or ponting value + recordContentSPF = data['recordContentSPF'] ## IP or pointing value DNS.createDNSRecord(zone, value, recordType, recordContentSPF, 0, ttl) @@ -354,7 +354,7 @@ class DNSManager: else: value = recordName + "." + zoneDomain - recordContentTXT = data['recordContentTXT'] ## IP or ponting value + recordContentTXT = data['recordContentTXT'] ## IP or pointing value DNS.createDNSRecord(zone, value, recordType, recordContentTXT, 0, ttl) @@ -404,7 +404,7 @@ class DNSManager: value = recordName else: value = recordName + "." + zoneDomain - recordContentCAA = data['recordContentCAA'] ## IP or ponting value + recordContentCAA = data['recordContentCAA'] ## IP or pointing value DNS.createDNSRecord(zone, value, recordType, recordContentCAA, 0, ttl) final_dic = {'status': 1, 'add_status': 1, 'error_message': "None"} @@ -849,7 +849,7 @@ class DNSManager: if recordType == "A": - recordContentA = data['recordContentA'] ## IP or ponting value + recordContentA = data['recordContentA'] ## IP or pointing value if recordName == "@": value = zoneDomain @@ -889,7 +889,7 @@ class DNSManager: else: value = recordName + "." + zoneDomain - recordContentAAAA = data['recordContentAAAA'] ## IP or ponting value + recordContentAAAA = data['recordContentAAAA'] ## IP or pointing value DNS.createDNSRecordCloudFlare(cf, zone, value, recordType, recordContentAAAA, 0, ttl) @@ -904,7 +904,7 @@ class DNSManager: else: value = recordName + "." + zoneDomain - recordContentCNAME = data['recordContentCNAME'] ## IP or ponting value + recordContentCNAME = data['recordContentCNAME'] ## IP or pointing value DNS.createDNSRecordCloudFlare(cf, zone, value, recordType, recordContentCNAME, 0, ttl) @@ -919,7 +919,7 @@ class DNSManager: else: value = recordName + "." + zoneDomain - recordContentSPF = data['recordContentSPF'] ## IP or ponting value + recordContentSPF = data['recordContentSPF'] ## IP or pointing value DNS.createDNSRecordCloudFlare(cf, zone, value, recordType, recordContentSPF, 0, ttl) @@ -934,7 +934,7 @@ class DNSManager: else: value = recordName + "." + zoneDomain - recordContentTXT = data['recordContentTXT'] ## IP or ponting value + recordContentTXT = data['recordContentTXT'] ## IP or pointing value DNS.createDNSRecordCloudFlare(cf, zone, value, recordType, recordContentTXT, 0, ttl) @@ -984,7 +984,7 @@ class DNSManager: value = recordName else: value = recordName + "." + zoneDomain - recordContentCAA = data['recordContentCAA'] ## IP or ponting value + recordContentCAA = data['recordContentCAA'] ## IP or pointing value DNS.createDNSRecordCloudFlare(cf, zone, value, recordType, recordContentCAA, 0, ttl) final_dic = {'status': 1, 'add_status': 1, 'error_message': "None"} diff --git a/install/install.py b/install/install.py index d457fb59b..46e596624 100755 --- a/install/install.py +++ b/install/install.py @@ -24,9 +24,9 @@ char_set = {'small': 'abcdefghijklmnopqrstuvwxyz', def generate_pass(length=14): - chars = string.ascii_uppercase + string.ascii_lowercase + string.digits - size = length - return ''.join(random.choice(chars) for x in range(size)) + chars = string.ascii_uppercase + string.ascii_lowercase + string.digits + size = length + return ''.join(random.choice(chars) for x in range(size)) # There can not be peace without first a great suffering. @@ -56,6 +56,8 @@ def get_distro(): if data.find('CentOS Linux release 8') > -1: return cent8 + if data.find('AlmaLinux release 8') > -1: + return cent8 else: logging.InstallLog.writeToFile("Can't find linux release file - fatal error") @@ -96,7 +98,8 @@ class preFlightsChecks: cyberPanelMirror = "mirror.cyberpanel.net/pip" cdn = 'cyberpanel.sh' - def __init__(self, rootPath, ip, path, cwd, cyberPanelPath, distro, remotemysql = None , mysqlhost = None, mysqldb = None, mysqluser = None, mysqlpassword = None, mysqlport = None): + def __init__(self, rootPath, ip, path, cwd, cyberPanelPath, distro, remotemysql=None, mysqlhost=None, mysqldb=None, + mysqluser=None, mysqlpassword=None, mysqlport=None): self.ipAddr = ip self.path = path self.cwd = cwd @@ -276,12 +279,11 @@ class preFlightsChecks: if self.distro == ubuntu: self.stdOut("Add Cyberpanel user") command = 'adduser --disabled-login --gecos "" cyberpanel' - preFlightsChecks.call(command, self.distro, command,command,1, 1, os.EX_OSERR) + preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) else: command = "useradd -s /bin/false cyberpanel" - preFlightsChecks.call(command, self.distro, command,command,1, 1, os.EX_OSERR) - + preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) ############################### @@ -292,21 +294,21 @@ class preFlightsChecks: else: command = "adduser docker" - preFlightsChecks.call(command, self.distro, command,command,1, 0, os.EX_OSERR) + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) command = 'groupadd docker' - preFlightsChecks.call(command, self.distro, command,command,1, 0, os.EX_OSERR) + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) command = 'usermod -aG docker docker' - preFlightsChecks.call(command, self.distro, command,command,1, 0, os.EX_OSERR) + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) command = 'usermod -aG docker cyberpanel' - preFlightsChecks.call(command, self.distro, command,command,1, 0, os.EX_OSERR) + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) ### command = "mkdir -p /etc/letsencrypt/live/" - preFlightsChecks.call(command, self.distro, command,command,1, 0, os.EX_OSERR) + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) except BaseException as msg: logging.InstallLog.writeToFile("[ERROR] setup_account_cyberpanel. " + str(msg)) @@ -391,6 +393,24 @@ class preFlightsChecks: ### Put correct mysql passwords in settings file! + # This allows root/sudo users to be able to work with MySQL/MariaDB without hunting down the password like + # all the other control panels allow + # reference: https://oracle-base.com/articles/mysql/mysql-password-less-logins-using-option-files + mysql_my_root_cnf = '/root/.my.cnf' + mysql_root_cnf_content = """ + [client] + user=root + password="%s" + """ % password + + with open(mysql_my_root_cnf, 'w') as f: + f.write(mysql_root_cnf_content) + os.chmod(mysql_my_root_cnf, 0o600) + command = 'chown root:root %s' % mysql_my_root_cnf + subprocess.call(shlex.split(command)) + + logging.InstallLog.writeToFile("Updating /root/.my.cnf!") + logging.InstallLog.writeToFile("Updating settings.py!") path = self.cyberPanelPath + "/CyberCP/settings.py" @@ -451,7 +471,7 @@ class preFlightsChecks: logging.InstallLog.writeToFile("settings.py updated!") - #self.setupVirtualEnv(self.distro) + # self.setupVirtualEnv(self.distro) ### Applying migrations @@ -645,7 +665,7 @@ class preFlightsChecks: preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) except BaseException as msg: - logging.InstallLog.writeToFile('[ERROR] '+ str(msg) + " [install_unzip]") + logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_unzip]") def install_zip(self): self.stdOut("Install zip") @@ -665,7 +685,8 @@ class preFlightsChecks: if not os.path.exists("/usr/local/CyberCP/public"): os.mkdir("/usr/local/CyberCP/public") - command = 'wget -O /usr/local/CyberCP/public/phpmyadmin.zip https://%s/misc/phpmyadmin.zip' % (preFlightsChecks.cdn) + command = 'wget -O /usr/local/CyberCP/public/phpmyadmin.zip https://%s/misc/phpmyadmin.zip' % ( + preFlightsChecks.cdn) preFlightsChecks.call(command, self.distro, '[download_install_phpmyadmin]', command, 1, 0, os.EX_OSERR) @@ -681,7 +702,6 @@ class preFlightsChecks: preFlightsChecks.call(command, self.distro, '[download_install_phpmyadmin]', command, 1, 0, os.EX_OSERR) - ## Write secret phrase rString = ''.join([random.choice(string.ascii_letters + string.digits) for n in range(32)]) @@ -725,15 +745,16 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; 'chown -R lscpd:lscpd /usr/local/CyberCP/public/phpmyadmin', 1, 0, os.EX_OSERR) if self.remotemysql == 'ON': - command = "sed -i 's|'localhost'|'%s'|g' %s" % (self.mysqlhost, '/usr/local/CyberCP/public/phpmyadmin/config.inc.php') + command = "sed -i 's|'localhost'|'%s'|g' %s" % ( + self.mysqlhost, '/usr/local/CyberCP/public/phpmyadmin/config.inc.php') preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - command = 'cp /usr/local/CyberCP/plogical/phpmyadminsignin.php /usr/local/CyberCP/public/phpmyadmin/phpmyadminsignin.php' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) if self.remotemysql == 'ON': - command = "sed -i 's|localhost|%s|g' /usr/local/CyberCP/public/phpmyadmin/phpmyadminsignin.php" % (self.mysqlhost) + command = "sed -i 's|localhost|%s|g' /usr/local/CyberCP/public/phpmyadmin/phpmyadminsignin.php" % ( + self.mysqlhost) preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) @@ -743,7 +764,7 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; ###################################################### Email setup - def install_postfix_davecot(self): + def install_postfix_dovecot(self): self.stdOut("Install dovecot - first remove postfix") try: @@ -754,7 +775,6 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; command = 'apt-get -y remove postfix' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - self.stdOut("Install dovecot - do the install") if self.distro == centos: @@ -829,7 +849,7 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; # pass except BaseException as msg: - logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_postfix_davecot]") + logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_postfix_dovecot]") return 0 return 1 @@ -845,14 +865,13 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; mysql_virtual_forwardings = "email-configs-one/mysql-virtual_forwardings.cf" mysql_virtual_mailboxes = "email-configs-one/mysql-virtual_mailboxes.cf" mysql_virtual_email2email = "email-configs-one/mysql-virtual_email2email.cf" - davecotmysql = "email-configs-one/dovecot-sql.conf.ext" - + dovecotmysql = "email-configs-one/dovecot-sql.conf.ext" ### update password: - data = open(davecotmysql, "r").readlines() + data = open(dovecotmysql, "r").readlines() - writeDataToFile = open(davecotmysql, "w") + writeDataToFile = open(dovecotmysql, "w") if mysql == 'Two': dataWritten = "connect = host=127.0.0.1 dbname=cyberpanel user=cyberpanel password=" + mysqlPassword + " port=3307\n" @@ -865,7 +884,6 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; else: writeDataToFile.writelines(items) - writeDataToFile.close() ### update password: @@ -932,13 +950,11 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; writeDataToFile.close() - - if self.remotemysql == 'ON': - command = "sed -i 's|host=localhost|host=%s|g' %s" % (self.mysqlhost, davecotmysql) + command = "sed -i 's|host=localhost|host=%s|g' %s" % (self.mysqlhost, dovecotmysql) preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) - command = "sed -i 's|port=3306|port=%s|g' %s" % (self.mysqlport, davecotmysql) + command = "sed -i 's|port=3306|port=%s|g' %s" % (self.mysqlport, dovecotmysql) preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) ## @@ -947,7 +963,7 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) command = "sed -i 's|localhost|%s:%s|g' %s" % ( - self.mysqlhost, self.mysqlport, mysql_virtual_forwardings) + self.mysqlhost, self.mysqlport, mysql_virtual_forwardings) preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) command = "sed -i 's|localhost|%s:%s|g' %s" % ( @@ -981,10 +997,11 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; fd.write(line) fd.close() except IOError as err: - self.stdOut("[ERROR] Error converting: " + filename + " from centos defaults to ubuntu defaults: " + str(err), 1, - 1, os.EX_OSERR) + self.stdOut( + "[ERROR] Error converting: " + filename + " from centos defaults to ubuntu defaults: " + str(err), 1, + 1, os.EX_OSERR) - def setup_postfix_davecot_config(self, mysql): + def setup_postfix_dovecot_config(self, mysql): try: logging.InstallLog.writeToFile("Configuring postfix and dovecot...") @@ -996,8 +1013,8 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; mysql_virtual_email2email = "/etc/postfix/mysql-virtual_email2email.cf" main = "/etc/postfix/main.cf" master = "/etc/postfix/master.cf" - davecot = "/etc/dovecot/dovecot.conf" - davecotmysql = "/etc/dovecot/dovecot-sql.conf.ext" + dovecot = "/etc/dovecot/dovecot.conf" + dovecotmysql = "/etc/dovecot/dovecot-sql.conf.ext" if os.path.exists(mysql_virtual_domains): os.remove(mysql_virtual_domains) @@ -1017,11 +1034,11 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; if os.path.exists(master): os.remove(master) - if os.path.exists(davecot): - os.remove(davecot) + if os.path.exists(dovecot): + os.remove(dovecot) - if os.path.exists(davecotmysql): - os.remove(davecotmysql) + if os.path.exists(dovecotmysql): + os.remove(dovecotmysql) ###############Getting SSL @@ -1051,9 +1068,19 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; "/etc/postfix/mysql-virtual_email2email.cf") shutil.copy("email-configs-one/main.cf", main) shutil.copy("email-configs-one/master.cf", master) - shutil.copy("email-configs-one/dovecot.conf", davecot) - shutil.copy("email-configs-one/dovecot-sql.conf.ext", davecotmysql) + shutil.copy("email-configs-one/dovecot.conf", dovecot) + shutil.copy("email-configs-one/dovecot-sql.conf.ext", dovecotmysql) + + ########### Set custom settings + # We are going to leverage postconfig -e to edit the settings for hostname + command = "postconf -e 'myhostname = %s'" % (str(socket.getfqdn())) + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + + # We are explicitly going to use sed to set the hostname default from "myhostname = server.example.com" + # to the fqdn from socket if the default is still found + command = "sed -i 's|server.example.com|%s|g' %s" % (str(socket.getfqdn()), main) + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) ######################################## Permissions @@ -1149,7 +1176,7 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; command = 'chmod o= /etc/dovecot/dovecot-sql.conf.ext' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - ################################### Restart davecot + ################################### Restart dovecot command = 'systemctl enable dovecot.service' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) @@ -1202,7 +1229,7 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; logging.InstallLog.writeToFile("Postfix and Dovecot configured") except BaseException as msg: - logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [setup_postfix_davecot_config]") + logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [setup_postfix_dovecot_config]") return 0 return 1 @@ -1630,7 +1657,7 @@ imap_folder_list_limit = 0 ## command = 'systemctl start lscpd' - #preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + # preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) preFlightsChecks.stdOut("LSCPD Daemon Set!") @@ -1680,7 +1707,6 @@ imap_folder_list_limit = 0 cronFile = open(cronPath, "w") - content = """ 0 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/findBWUsage.py >/dev/null 2>&1 0 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/postfixSenderPolicy/client.py hourlyCleanup >/dev/null 2>&1 @@ -1699,7 +1725,6 @@ imap_folder_list_limit = 0 command = 'chmod 600 %s' % (cronPath) preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - if self.distro == centos or self.distro == cent8: command = 'systemctl restart crond.service' else: @@ -2007,25 +2032,11 @@ milter_default_action = accept CentOSPath = '/etc/redhat-release' if os.path.exists(CentOSPath): - - if self.distro == centos: - command = 'yum install restic -y' + command = 'yum install -y yum-plugin-copr' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - elif self.distro == cent8: - - command = 'cat /proc/cpuinfo' - - result = subprocess.check_output(shlex.split(command)).decode("utf-8") - - if result.find('ARM') > -1 or result.find('arm') > -1: - command = 'wget -O /usr/bin/restic https://rep.cyberpanel.net/restic_0.9.6_linux_arm64' - preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - - else: - command = 'wget -O /usr/bin/restic https://rep.cyberpanel.net/restic_0.9.6_linux_amd64' - preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - - command = 'chmod +x /usr/bin/restic' + command = 'yum copr enable -y copart/restic' + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + command = 'yum install -y restic' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) else: @@ -2132,7 +2143,6 @@ vmail def disablePackegeUpdates(self): if self.distro == centos: - mainConfFile = '/etc/yum.conf' content = 'exclude=MariaDB-client MariaDB-common MariaDB-devel MariaDB-server MariaDB-shared ' \ 'pdns pdns-backend-mysql dovecot dovecot-mysql postfix3 postfix3-ldap postfix3-mysql ' \ @@ -2142,6 +2152,7 @@ vmail writeToFile.write(content) writeToFile.close() + def main(): parser = argparse.ArgumentParser(description='CyberPanel Installer') parser.add_argument('publicip', help='Please enter public IP for your VPS or dedicated server.') @@ -2205,7 +2216,8 @@ def main(): mysqldb = args.mysqldb if preFlightsChecks.debug: - print('mysqlhost: %s, mysqldb: %s, mysqluser: %s, mysqlpassword: %s, mysqlport: %s' % (mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport)) + print('mysqlhost: %s, mysqldb: %s, mysqluser: %s, mysqlpassword: %s, mysqlport: %s' % ( + mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport)) time.sleep(10) else: @@ -2217,7 +2229,8 @@ def main(): mysqldb = '' distro = get_distro() - checks = preFlightsChecks("/usr/local/lsws/", args.publicip, "/usr/local", cwd, "/usr/local/CyberCP", distro, remotemysql, mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport) + checks = preFlightsChecks("/usr/local/lsws/", args.publicip, "/usr/local", cwd, "/usr/local/CyberCP", distro, + remotemysql, mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport) checks.mountTemp() if args.port == None: @@ -2238,25 +2251,26 @@ def main(): import installCyberPanel - if ent == 0: - installCyberPanel.Main(cwd, mysql, distro, ent, None, port, args.ftp, args.powerdns, args.publicip, remotemysql, mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport) + installCyberPanel.Main(cwd, mysql, distro, ent, None, port, args.ftp, args.powerdns, args.publicip, remotemysql, + mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport) else: - installCyberPanel.Main(cwd, mysql, distro, ent, serial, port, args.ftp, args.powerdns, args.publicip, remotemysql, mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport) + installCyberPanel.Main(cwd, mysql, distro, ent, serial, port, args.ftp, args.powerdns, args.publicip, + remotemysql, mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport) checks.setupPHPAndComposer() checks.fix_selinux_issue() checks.install_psmisc() if args.postfix == None: - checks.install_postfix_davecot() + checks.install_postfix_dovecot() checks.setup_email_Passwords(installCyberPanel.InstallCyberPanel.mysqlPassword, mysql) - checks.setup_postfix_davecot_config(mysql) + checks.setup_postfix_dovecot_config(mysql) else: if args.postfix == 'ON': - checks.install_postfix_davecot() + checks.install_postfix_dovecot() checks.setup_email_Passwords(installCyberPanel.InstallCyberPanel.mysqlPassword, mysql) - checks.setup_postfix_davecot_config(mysql) + checks.setup_postfix_dovecot_config(mysql) checks.install_unzip() checks.install_zip() @@ -2313,7 +2327,7 @@ def main(): checks.enableDisableFTP('on', distro) checks.installCLScripts() - #checks.disablePackegeUpdates() + # checks.disablePackegeUpdates() try: # command = 'mkdir -p /usr/local/lscp/cyberpanel/rainloop/data/data/default/configs/' @@ -2345,10 +2359,9 @@ echo $oConfig->Save() ? 'Done' : 'Error'; writeToFile.write(content) writeToFile.close() - command = '/usr/local/lsws/lsphp72/bin/php /usr/local/CyberCP/public/rainloop.php' subprocess.call(shlex.split(command)) - + command = "chown -R lscpd:lscpd /usr/local/lscp/cyberpanel/rainloop/data" subprocess.call(shlex.split(command)) except: diff --git a/install/litespeed/httpd_config.xml b/install/litespeed/httpd_config.xml index 026bf6572..391c8fa1d 100755 --- a/install/litespeed/httpd_config.xml +++ b/install/litespeed/httpd_config.xml @@ -147,7 +147,7 @@ SecFilterSelective ARGS "into[[:space:]]+outfile|load[[:space:]]+data|/\*.+ $SERVER_ROOT/admin/conf/* - ALL, 127.0.0.1T, 103.21.244.0/22T, 103.22.200.0/22T, 103.31.4.0/22T, 104.16.0.0/12T, 108.162.192.0/18T, 131.0.72.0/22T, 141.101.64.0/18T, 162.158.0.0/15T, 172.64.0.0/13T, 173.245.48.0/20T, 188.114.96.0/20T, 190.93.240.0/20T, 197.234.240.0/22T, 198.41.128.0/17T, 2400:cb00::/32T, 2405:8100::/32T, 2405:b500::/32T, 2606:4700::/32T, 2803:f800::/32T, 2a06:98c0::/29T, 2c0f:f248::/32T, 192.88.134.0/23T, 185.93.228.0/22, 66.248.200.0/22T, 208.109.0.0/22T, 2a02:fe80::/29T + ALL, 127.0.0.1T, 103.21.244.0/22T, 103.22.200.0/22T, 103.31.4.0/22T, 104.16.0.0/13T, 104.24.0.0/14T, 108.162.192.0/18T, 131.0.72.0/22T, 141.101.64.0/18T, 162.158.0.0/15T, 172.64.0.0/13T, 173.245.48.0/20T, 188.114.96.0/20T, 190.93.240.0/20T, 197.234.240.0/22T, 198.41.128.0/17T, 2400:cb00::/32T, 2405:8100::/32T, 2405:b500::/32T, 2606:4700::/32T, 2803:f800::/32T, 2a06:98c0::/29T, 2c0f:f248::/32T, 192.88.134.0/23T, 185.93.228.0/22, 66.248.200.0/22T, 208.109.0.0/22T, 2a02:fe80::/29T @@ -351,6 +351,26 @@ SecFilterSelective ARGS "into[[:space:]]+outfile|load[[:space:]]+data|/\*.+ 400 500 + + lsapi + lsphp80 +
    uds://tmp/lshttpd/lsphp80.sock
    + 35 + PHP_LSAPI_CHILDREN=35 + 60 + 0 + 1 + 0 + 3 + $SERVER_ROOT/lsphp80/bin/lsphp + 100 + 1 + 0 + 2047M + 2047M + 400 + 500 +
    @@ -408,6 +428,11 @@ SecFilterSelective ARGS "into[[:space:]]+outfile|load[[:space:]]+data|/\*.+ lsapi lsphp74 + + php80 + lsapi + lsphp80 + @@ -427,4 +452,4 @@ SecFilterSelective ARGS "into[[:space:]]+outfile|load[[:space:]]+data|/\*.+ 400 500 - \ No newline at end of file + diff --git a/install/php-configs/php.ini b/install/php-configs/php.ini index 99712a192..984c0cbfb 100755 --- a/install/php-configs/php.ini +++ b/install/php-configs/php.ini @@ -393,7 +393,7 @@ max_input_time = 60 ; Maximum amount of memory a script may consume (128MB) ; http://php.net/memory-limit -memory_limit = 128M +memory_limit = 256M ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Error handling and logging ; @@ -660,7 +660,7 @@ auto_globals_jit = On ; Its value may be 0 to disable the limit. It is ignored if POST data reading ; is disabled through enable_post_data_reading. ; http://php.net/post-max-size -post_max_size = 8M +post_max_size = 20M ; Automatically add files before PHP document. ; http://php.net/auto-prepend-file @@ -808,7 +808,7 @@ file_uploads = On ; Maximum allowed size for uploaded files. ; http://php.net/upload-max-filesize -upload_max_filesize = 2M +upload_max_filesize = 20M ; Maximum number of files that can be uploaded via a single request max_file_uploads = 20 diff --git a/install/phpconfigs/php71.conf b/install/phpconfigs/php71.conf index 446d3b4b9..618143265 100755 --- a/install/phpconfigs/php71.conf +++ b/install/phpconfigs/php71.conf @@ -1,4 +1,4 @@ -extprocessor php71 { +php71.confextprocessor php71 { type lsapi address uds://tmp/lshttpd/lsphp71.sock maxConns 50 diff --git a/install/phpconfigs/php72.conf b/install/phpconfigs/php72.conf new file mode 100755 index 000000000..9a4a8c586 --- /dev/null +++ b/install/phpconfigs/php72.conf @@ -0,0 +1,16 @@ +php72.confextprocessor php72 { + type lsapi + address uds://tmp/lshttpd/lsphp72.sock + maxConns 50 + initTimeout 60 + retryTimeout 0 + persistConn 1 + respBuffer 0 + autoStart 1 + path /usr/local/lsws/lsphp72/bin/lsphp + memSoftLimit 2047M + memHardLimit 2047M + procSoftLimit 400 + procHardLimit 500 +} + diff --git a/install/phpconfigs/php73.conf b/install/phpconfigs/php73.conf new file mode 100755 index 000000000..2017f879f --- /dev/null +++ b/install/phpconfigs/php73.conf @@ -0,0 +1,16 @@ +php73.confextprocessor php73 { + type lsapi + address uds://tmp/lshttpd/lsphp73.sock + maxConns 50 + initTimeout 60 + retryTimeout 0 + persistConn 1 + respBuffer 0 + autoStart 1 + path /usr/local/lsws/lsphp73/bin/lsphp + memSoftLimit 2047M + memHardLimit 2047M + procSoftLimit 400 + procHardLimit 500 +} + diff --git a/install/phpconfigs/php74.conf b/install/phpconfigs/php74.conf new file mode 100755 index 000000000..407e1c4b5 --- /dev/null +++ b/install/phpconfigs/php74.conf @@ -0,0 +1,16 @@ +php80.confextprocessor php80 { + type lsapi + address uds://tmp/lshttpd/lsphp80.sock + maxConns 50 + initTimeout 60 + retryTimeout 0 + persistConn 1 + respBuffer 0 + autoStart 1 + path /usr/local/lsws/lsphp80/bin/lsphp + memSoftLimit 2047M + memHardLimit 2047M + procSoftLimit 400 + procHardLimit 500 +} + diff --git a/install/phpconfigs/php80.conf b/install/phpconfigs/php80.conf new file mode 100755 index 000000000..d60ccd0d7 --- /dev/null +++ b/install/phpconfigs/php80.conf @@ -0,0 +1,16 @@ +php74.confextprocessor php74 { + type lsapi + address uds://tmp/lshttpd/lsphp74.sock + maxConns 50 + initTimeout 60 + retryTimeout 0 + persistConn 1 + respBuffer 0 + autoStart 1 + path /usr/local/lsws/lsphp74/bin/lsphp + memSoftLimit 2047M + memHardLimit 2047M + procSoftLimit 400 + procHardLimit 500 +} + 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/mailServer/mailserverManager.py b/mailServer/mailserverManager.py index f473e0146..927a8f43d 100755 --- a/mailServer/mailserverManager.py +++ b/mailServer/mailserverManager.py @@ -882,7 +882,7 @@ class MailServerManager(multi.Thread): final_json = json.dumps(final_dic) return HttpResponse(final_json) - def install_postfix_davecot(self): + def install_postfix_dovecot(self): try: if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: command = 'yum remove postfix -y' @@ -901,9 +901,9 @@ class MailServerManager(multi.Thread): ProcessUtilities.executioner(command) command = 'dnf install --enablerepo=gf-plus postfix3 postfix3-mysql -y' + ProcessUtilities.executioner(command) else: - import socket - command = 'apt-get -y debconf-utils' + command = 'apt-get install -y debconf-utils' ProcessUtilities.executioner(command) file_name = 'pf.unattend.text' pf = open(file_name, 'w') @@ -917,7 +917,20 @@ class MailServerManager(multi.Thread): # os.remove(file_name) ProcessUtilities.executioner(command) + + import socket + # We are going to leverage postconfig -e to edit the settings for hostname + command = '"postconf -e "myhostname = %s"' % (str(socket.getfqdn())) + ProcessUtilities.executioner(command) + command = '"postconf -e "myhostname = %s"' % (str(socket.getfqdn())) + ProcessUtilities.executioner(command) + # We are explicitly going to use sed to set the hostname default from "myhostname = server.example.com" + # to the fqdn from socket if the default is still found + postfix_main = '/etc/postfix/main.cf' + command = "sed -i 's|server.example.com|%s|g' %s" % (str(socket.getfqdn()), postfix_main) + ProcessUtilities.executioner(command) + logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Re-installing Dovecot..,15') if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: @@ -975,7 +988,7 @@ class MailServerManager(multi.Thread): logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Postfix/dovecot reinstalled.,40') except BaseException as msg: - logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], '%s [install_postfix_davecot][404]' % (str(msg)), 10) + logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], '%s [install_postfix_dovecot][404]' % (str(msg)), 10) return 0 return 1 @@ -988,13 +1001,13 @@ class MailServerManager(multi.Thread): mysql_virtual_forwardings = "/usr/local/CyberCP/install/email-configs-one/mysql-virtual_forwardings.cf" mysql_virtual_mailboxes = "/usr/local/CyberCP/install/email-configs-one/mysql-virtual_mailboxes.cf" mysql_virtual_email2email = "/usr/local/CyberCP/install/email-configs-one/mysql-virtual_email2email.cf" - davecotmysql = "/usr/local/CyberCP/install/email-configs-one/dovecot-sql.conf.ext" + dovecotmysql = "/usr/local/CyberCP/install/email-configs-one/dovecot-sql.conf.ext" ### update password: - data = open(davecotmysql, "r").readlines() + data = open(dovecotmysql, "r").readlines() - writeDataToFile = open(davecotmysql, "w") + writeDataToFile = open(dovecotmysql, "w") dataWritten = "connect = host=localhost dbname=cyberpanel user=cyberpanel password=" + mysqlPassword + " port=3306\n" @@ -1086,10 +1099,10 @@ class MailServerManager(multi.Thread): writeDataToFile.close() if self.remotemysql == 'ON': - command = "sed -i 's|host=localhost|host=%s|g' %s" % (self.mysqlhost, davecotmysql) + command = "sed -i 's|host=localhost|host=%s|g' %s" % (self.mysqlhost, dovecotmysql) ProcessUtilities.executioner(command) - command = "sed -i 's|port=3306|port=%s|g' %s" % (self.mysqlport, davecotmysql) + command = "sed -i 's|port=3306|port=%s|g' %s" % (self.mysqlport, dovecotmysql) ProcessUtilities.executioner(command) ## @@ -1133,7 +1146,7 @@ class MailServerManager(multi.Thread): logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], '%s [centos_lib_dir_to_ubuntu][404]' % (str(msg)), 10) - def setup_postfix_davecot_config(self): + def setup_postfix_dovecot_config(self): try: mysql_virtual_domains = "/etc/postfix/mysql-virtual_domains.cf" @@ -1142,8 +1155,8 @@ class MailServerManager(multi.Thread): mysql_virtual_email2email = "/etc/postfix/mysql-virtual_email2email.cf" main = "/etc/postfix/main.cf" master = "/etc/postfix/master.cf" - davecot = "/etc/dovecot/dovecot.conf" - davecotmysql = "/etc/dovecot/dovecot-sql.conf.ext" + dovecot = "/etc/dovecot/dovecot.conf" + dovecotmysql = "/etc/dovecot/dovecot-sql.conf.ext" if os.path.exists(mysql_virtual_domains): os.remove(mysql_virtual_domains) @@ -1163,11 +1176,11 @@ class MailServerManager(multi.Thread): if os.path.exists(master): os.remove(master) - if os.path.exists(davecot): - os.remove(davecot) + if os.path.exists(dovecot): + os.remove(dovecot) - if os.path.exists(davecotmysql): - os.remove(davecotmysql) + if os.path.exists(dovecotmysql): + os.remove(dovecotmysql) ###############Getting SSL @@ -1197,8 +1210,8 @@ class MailServerManager(multi.Thread): "/etc/postfix/mysql-virtual_email2email.cf") shutil.copy("/usr/local/CyberCP/install/email-configs-one/main.cf", main) shutil.copy("/usr/local/CyberCP/install/email-configs-one/master.cf", master) - shutil.copy("/usr/local/CyberCP/install/email-configs-one/dovecot.conf", davecot) - shutil.copy("/usr/local/CyberCP/install/email-configs-one/dovecot-sql.conf.ext", davecotmysql) + shutil.copy("/usr/local/CyberCP/install/email-configs-one/dovecot.conf", dovecot) + shutil.copy("/usr/local/CyberCP/install/email-configs-one/dovecot-sql.conf.ext", dovecotmysql) ######################################## Permissions @@ -1294,7 +1307,7 @@ class MailServerManager(multi.Thread): command = 'chmod o= /etc/dovecot/dovecot-sql.conf.ext' ProcessUtilities.executioner(command) - ################################### Restart davecot + ################################### Restart dovecot command = 'systemctl enable dovecot.service' ProcessUtilities.executioner(command) @@ -1309,7 +1322,7 @@ class MailServerManager(multi.Thread): command = 'systemctl restart postfix.service' ProcessUtilities.executioner(command) - ## chaging permissions for main.cf + ## changing permissions for main.cf command = "chmod 755 " + main ProcessUtilities.executioner(command) @@ -1346,7 +1359,7 @@ class MailServerManager(multi.Thread): ProcessUtilities.executioner(command) except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], - '%s [setup_postfix_davecot_config][404]' % ( + '%s [setup_postfix_dovecot_config][404]' % ( str(msg)), 10) return 0 @@ -1597,7 +1610,7 @@ milter_default_action = accept logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Removing and re-installing postfix/dovecot..,5') - if self.install_postfix_davecot() == 0: + if self.install_postfix_dovecot() == 0: return 0 logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Resetting configurations..,40') @@ -1612,8 +1625,8 @@ milter_default_action = accept logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Configurations reset..,70') - if self.setup_postfix_davecot_config() == 0: - logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'setup_postfix_davecot_config failed. [404].') + if self.setup_postfix_dovecot_config() == 0: + logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'setup_postfix_dovecot_config failed. [404].') return 0 logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Restoreing OpenDKIM configurations..,70') @@ -1688,4 +1701,4 @@ def main(): background.ResetEmailConfigurations() if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/manageServices/views.py b/manageServices/views.py index d01a8f14c..e82afe5d1 100755 --- a/manageServices/views.py +++ b/manageServices/views.py @@ -301,7 +301,7 @@ def removeInstall(request): status = data['status'] appName = data['appName'] - if appName == 'Elastic Search': + if appName == 'Elasticsearch': if status == 'Installing': command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/manageServices/serviceManager.py --function InstallElasticSearch' else: diff --git a/plogical/ClusterManager.py b/plogical/ClusterManager.py index e3c83ad66..0f43ee9da 100644 --- a/plogical/ClusterManager.py +++ b/plogical/ClusterManager.py @@ -83,18 +83,34 @@ class ClusterManager: ClusterConfigPath = '/home/cyberpanel/cluster' config = json.loads(open(ClusterConfigPath, 'r').read()) + if self.type == 'Child': + ### If Centos then update library path for galera + + ClusterConfigFailover = config['ClusterConfigFailover'] + + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + ClusterConfigFailover = ClusterConfigFailover.replace('/usr/lib/galera/libgalera_smm.so', '/usr/lib64/galera-4/libgalera_smm.so') + writeToFile = open(ClusterPath, 'w') - writeToFile.write(config['ClusterConfigFailover']) + writeToFile.write(ClusterConfigFailover) writeToFile.close() writeToFile = open(cronPath, 'a') writeToFile.write('*/5 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/ClusterManager.py --function CreatePendingVirtualHosts --type Child\n') writeToFile.close() else: + + ### If Centos then update library path for galera + + ClusterConfigMaster = config['ClusterConfigMaster'] + + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + ClusterConfigMaster = ClusterConfigMaster.replace('/usr/lib/galera/libgalera_smm.so', '/usr/lib64/galera-4/libgalera_smm.so') + writeToFile = open(ClusterPath, 'w') - writeToFile.write(config['ClusterConfigMaster']) + writeToFile.write(ClusterConfigMaster) writeToFile.close() writeToFile = open(cronPath, 'a') @@ -341,7 +357,7 @@ password=%s""" % (rootdbpassword, rootdbpassword) self.PostStatus('Data and SSL certificates currently synced.') except BaseException as msg: - self.PostStatus('Failed to create pending vhosts, error %s [404].' % (str(msg))) + self.PostStatus('Failed to sync data, error %s [404].' % (str(msg))) def PingNow(self): try: @@ -407,6 +423,25 @@ password=%s""" % (rootdbpassword, rootdbpassword) except BaseException as msg: logging.writeToFile('%s. [31:404]' % (str(msg))) + def SyncToMaster(self): + try: + + self.PostStatus('Syncing data from home directory to Main server..') + + command = "rsync -avzp -e 'ssh -o StrictHostKeyChecking=no -p %s -i /root/.ssh/cyberpanel' /home root@%s:/" % (self.config['masterServerSSHPort'], self.config['masterServerIP']) + ProcessUtilities.normalExecutioner(command) + + self.PostStatus('Syncing SSL certificates to Main server..') + + command = "rsync -avzp -e 'ssh -o StrictHostKeyChecking=no -p %s -i /root/.ssh/cyberpanel' /etc/letsencrypt root@%s:/etc" % ( + self.config['masterServerSSHPort'], self.config['masterServerIP']) + ProcessUtilities.normalExecutioner(command) + + self.PostStatus('Data back to main.') + + except BaseException as msg: + self.PostStatus('Failed to sync data, error %s [404].' % (str(msg))) + def main(): parser = argparse.ArgumentParser(description='CyberPanel Installer') @@ -437,6 +472,8 @@ def main(): uc.UptimeMonitor() elif args.function == 'Uptime': uc.Uptime() + elif args.function == 'SyncToMaster': + uc.SyncToMaster() if __name__ == "__main__": 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/cPanelImporter.py b/plogical/cPanelImporter.py index c1c56d882..97f6bda5a 100644 --- a/plogical/cPanelImporter.py +++ b/plogical/cPanelImporter.py @@ -104,7 +104,10 @@ class cPanelImporter: self.PHPVersion = 'PHP 8.0' if self.PHPVersion == '': - self.PHPVersion = self.InheritPHP + if self.InheritPHP != '': + self.PHPVersion = self.InheritPHP + else: + self.PHPVersion = 'PHP 7.4' return self.PHPVersion diff --git a/plogical/upgrade.py b/plogical/upgrade.py index ff831b221..2ace0c409 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: @@ -1512,6 +1512,15 @@ imap_folder_list_limit = 0 `websiteDataEmails` int(11) NOT NULL, PRIMARY KEY (`id`) )""" + try: + cursor.execute(query) + except: + pass + + + query = 'ALTER TABLE IncBackups_backupjob ADD retention integer DEFAULT 0' + + try: cursor.execute(query) except: @@ -2412,7 +2421,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 +2430,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/IncBackups/IncBackups.js b/static/IncBackups/IncBackups.js index 9031c393d..79b13571e 100644 --- a/static/IncBackups/IncBackups.js +++ b/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/static/backup/backup.js b/static/backup/backup.js index 49980c5f9..92ccab6a5 100644 --- a/static/backup/backup.js +++ b/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/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, diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index a0b13fd84..56950db0d 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -166,7 +166,6 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - try: HA = data['HA'] externalApp = 'nobody'