diff --git a/manageSSL/templates/manageSSL/v2ManageSSL.html b/manageSSL/templates/manageSSL/v2ManageSSL.html index e4f88e182..50ada47d2 100755 --- a/manageSSL/templates/manageSSL/v2ManageSSL.html +++ b/manageSSL/templates/manageSSL/v2ManageSSL.html @@ -10,11 +10,17 @@ {% if PremStat %}
-

{% trans "SSL v2" %} - {% trans "SSL v2" %} - {% trans "DNS Docs" %}

{% trans "On this page, you have the option to configure DNS providers that CyberPanel can utilize for issuing SSL certificates, providing enhanced flexibility and ease of renewal." %}

+

+ +

@@ -166,7 +172,7 @@ protected. Don't wait any longer to upgrade your website's security - get SSL v2 today!

- diff --git a/plogical/Backupsv2.py b/plogical/Backupsv2.py index 23b50491d..c4d1809aa 100644 --- a/plogical/Backupsv2.py +++ b/plogical/Backupsv2.py @@ -420,6 +420,7 @@ token = {token} return 0 self.UpdateStatus('Backup config created,5', CPBackupsV2.RUNNING) + except BaseException as msg: self.UpdateStatus(f'Failed during config generation, Error: {str(msg)}', CPBackupsV2.FAILED) return 0 @@ -453,6 +454,7 @@ token = {token} self.MergeSnapshots() self.UpdateStatus('Completed', CPBackupsV2.COMPLETED) + return 1 break except BaseException as msg: @@ -725,6 +727,19 @@ token = {token} self.website.BackupLock = 0 self.website.save() + ### Delete Snapshots + + def DeleteSnapshots(self, deleteString): + + ### if restore then status file should be restore status file + + from websiteFunctions.models import Websites + self.website = Websites.objects.get(domain=self.data['domain']) + + + command = f'rustic -r {self.repo} forget {deleteString} --prune --password "" 2>/dev/null' + result = ProcessUtilities.outputExecutioner(command, None, True) + # def BackupEmails(self): # # ### This function will backup emails of the website, also need to take care of emails that we need to exclude diff --git a/plogical/IncScheduler.py b/plogical/IncScheduler.py index 89496fc5b..6f7a5053f 100644 --- a/plogical/IncScheduler.py +++ b/plogical/IncScheduler.py @@ -1393,6 +1393,77 @@ Automatic backup failed for %s on %s. for website in Websites.objects.all(): virtualHostUtilities.setupAutoDiscover(1, '/home/cyberpanel/templogs', website.domain, website.admin) + @staticmethod + def v2Backups(function): + try: + # print("....start remote backup...............") + from websiteFunctions.models import Websites + from loginSystem.models import Administrator + import json + import time + if os.path.exists('/home/cyberpanel/v2backups'): + for website in Websites.objects.all(): + finalConfigPath = f'/home/cyberpanel/v2backups/{website.domain}' + if os.path.exists(finalConfigPath): + + command = f'cat {finalConfigPath}' + RetResult = ProcessUtilities.outputExecutioner(command) + print(repr(RetResult)) + BackupConfig = json.loads(ProcessUtilities.outputExecutioner(command).rstrip('\n')) + + for key, value in BackupConfig.items(): + try: + print(key, '->', value) + if key == 'site': + continue + if value['frequency'] == function: + extra_args = {} + extra_args['function'] = 'InitiateBackup' + extra_args['website'] = website.domain + extra_args['domain'] = website.domain + extra_args['BasePath'] = '/home/backup' + extra_args['BackendName'] = key + extra_args['BackupData'] = value['websiteData'] if 'websiteData' in value else False + extra_args['BackupEmails'] = value['websiteEmails'] if 'websiteEmails' in value else False + extra_args['BackupDatabase'] = value['websiteDatabases'] if 'websiteDatabases' in value else False + + from plogical.Backupsv2 import CPBackupsV2 + background = CPBackupsV2(extra_args) + RetStatus = background.InitiateBackup() + + print(RetStatus) + + if RetStatus == 0: + SUBJECT = "Automatic Backupv2 failed for %s on %s." % (website.domain, time.strftime("%m.%d.%Y_%H-%M-%S")) + adminEmailPath = '/home/cyberpanel/adminEmail' + adminEmail = open(adminEmailPath, 'r').read().rstrip('\n') + sender = 'root@%s' % (socket.gethostname()) + error = ProcessUtilities.outputExecutioner(f'cat {background.StatusFile}') + TO = [adminEmail] + message = f"""\ +From: %s +To: %s +Subject: %s +Automatic Backupv2 failed for %s on %s. +{error} +""" % (sender, ", ".join(TO), SUBJECT, website.domain, time.strftime("%m.%d.%Y_%H-%M-%S")) + + logging.SendEmail(sender, TO, message) + else: + BackupConfig[key]['lastRun'] = time.strftime("%m.%d.%Y_%H-%M-%S") + except BaseException as msg: + print("Error: [v2Backups]: %s" % str(msg)) + logging.writeToFile('%s. [v2Backups]' % (str(msg))) + + FinalContent = json.dumps(BackupConfig) + WriteToFile = open(finalConfigPath, 'w') + WriteToFile.write(FinalContent) + WriteToFile.close() + + except BaseException as msg: + print("Error: [v2Backups]: %s" % str(msg)) + logging.writeToFile('%s. [v2Backups]' % (str(msg))) + def main(): parser = argparse.ArgumentParser(description='CyberPanel Installer') @@ -1404,8 +1475,9 @@ def main(): IncScheduler.CalculateAndUpdateDiskUsage() return 0 - if args.function == '30 Minutes' or args.function == '30 Minutes'or args.function == 'Daily' or args.function == '1 Hour' or args.function == '6 Hours' or args.function == '12 Hours' or args.function == '1 Day' or args.function == '3 Days' or args.function == '1 Week': + if args.function == '30 Minutes' or args.function == 'Daily' or args.function == '1 Hour' or args.function == '6 Hours' or args.function == '12 Hours' or args.function == '1 Day' or args.function == '3 Days' or args.function == '1 Week': IncScheduler.RemoteBackup(args.function) + IncScheduler.v2Backups(args.function) return 0 if args.function == 'forceRunAWSBackup': diff --git a/plogical/processUtilities.py b/plogical/processUtilities.py index 5a98aa322..e906d8ce9 100755 --- a/plogical/processUtilities.py +++ b/plogical/processUtilities.py @@ -294,6 +294,10 @@ class ProcessUtilities(multi.Thread): if getpass.getuser() == 'root': if os.path.exists(ProcessUtilities.debugPath): logging.writeToFile(command) + + if user!=None: + if not command.startswith('sudo'): + command = f'sudo -u {user} {command}' if shell == None or shell == True: p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) else: