diff --git a/cloudAPI/cloudManager.py b/cloudAPI/cloudManager.py index 740008d8d..e9d0bf60d 100755 --- a/cloudAPI/cloudManager.py +++ b/cloudAPI/cloudManager.py @@ -1659,12 +1659,14 @@ class CloudManager: destinationDomain = 'None' import time - BackupPath = '/home/cyberpanel/backups/%s/backup-' % (self.data['domain']) + self.data['domain'] + "-" + time.strftime("%m.%d.%Y_%H-%M-%S") + BackupPath = '/home/cyberpanel/backups/%s/backup-' % (self.data['domain']) + self.data[ + 'domain'] + "-" + time.strftime("%m.%d.%Y_%H-%M-%S") execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" execPath = execPath + " CloudBackup --backupDomain %s --data %s --emails %s --databases %s --tempStoragePath %s " \ "--path %s --port %s --ip %s --destinationDomain %s" % ( - self.data['domain'], data, emails, databases, tempStatusPath, BackupPath, port, ip, destinationDomain) + self.data['domain'], data, emails, databases, tempStatusPath, BackupPath, port, ip, + destinationDomain) ProcessUtilities.popenExecutioner(execPath) final_dic = {'status': 1, 'tempStatusPath': tempStatusPath, 'path': '%s.tar.gz' % (BackupPath)} @@ -1784,7 +1786,7 @@ class CloudManager: execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" execPath = execPath + " SubmitCloudBackupRestore --backupDomain %s --backupFile %s --sourceDomain %s --tempStoragePath %s" % ( - self.data['domain'], self.data['backupFile'],sourceDomain, tempStatusPath) + self.data['domain'], self.data['backupFile'], sourceDomain, tempStatusPath) ProcessUtilities.popenExecutioner(execPath) final_dic = {'status': 1, 'tempStatusPath': tempStatusPath} @@ -1957,7 +1959,6 @@ class CloudManager: finalDic['maintenanceMode'] = 1 finalDic['php'] = '7.4' - ## Get versopm website = Websites.objects.get(domain=domain) @@ -1997,7 +1998,8 @@ class CloudManager: ## Search index command = 'wp option get blog_public --path=%s' % (path) - finalDic['searchIndex'] = int(ProcessUtilities.outputExecutioner(command, website.externalApp).splitlines()[-1]) + finalDic['searchIndex'] = int( + ProcessUtilities.outputExecutioner(command, website.externalApp).splitlines()[-1]) ## Maintenece mode @@ -2043,7 +2045,8 @@ class CloudManager: import plogical.randomPassword as randomPassword password = randomPassword.generate_pass(32) - command = 'wp user create cyberpanel support@cyberpanel.cloud --role=administrator --user_pass="%s" --path=%s' % (password, path) + command = 'wp user create cyberpanel support@cyberpanel.cloud --role=administrator --user_pass="%s" --path=%s' % ( + password, path) ProcessUtilities.executioner(command, website.externalApp) command = 'wp user update cyberpanel --user_pass="%s" --path=%s' % (password, path) @@ -2072,20 +2075,19 @@ class CloudManager: except: path = '/home/%s/public_html' % (self.data['domain']) - if self.data['setting'] == 'lscache': - if self.data['settingValue']: + if self.data['settingValue']: - command = "wp plugin install litespeed-cache --path=%s" % (path) - ProcessUtilities.executioner(command, website.externalApp) + command = "wp plugin install litespeed-cache --path=%s" % (path) + ProcessUtilities.executioner(command, website.externalApp) - command = "wp plugin activate litespeed-cache --path=%s" % (path) - ProcessUtilities.executioner(command, website.externalApp) + command = "wp plugin activate litespeed-cache --path=%s" % (path) + ProcessUtilities.executioner(command, website.externalApp) - final_dic = {'status': 1, 'message': 'LSCache successfully installed and activated.'} - final_json = json.dumps(final_dic) - return HttpResponse(final_json) - else: + final_dic = {'status': 1, 'message': 'LSCache successfully installed and activated.'} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + else: command = 'wp plugin deactivate litespeed-cache --path=%s' % (path) ProcessUtilities.executioner(command, website.externalApp) @@ -2196,7 +2198,8 @@ class CloudManager: if self.data['plugin'] == 'all': command = 'wp plugin update --all --path=%s' % (path) ProcessUtilities.popenExecutioner(command, website.externalApp) - final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'message': "Plugin updates started in the background."}) + final_json = json.dumps( + {'status': 1, 'fetchStatus': 1, 'message': "Plugin updates started in the background."}) return HttpResponse(final_json) elif self.data['plugin'] == 'selected': if self.data['allPluginsChecked']: @@ -2252,7 +2255,7 @@ class CloudManager: return HttpResponse(final_json) else: command = 'wp plugin activate %s --path=%s' % ( - self.data['plugin'], path) + self.data['plugin'], path) ProcessUtilities.executioner(command, website.externalApp) final_json = json.dumps( {'status': 1, 'fetchStatus': 1, 'message': "Plugin successfully activated."}) @@ -2338,7 +2341,8 @@ class CloudManager: if self.data['plugin'] == 'all': command = 'wp theme update --all --path=%s' % (path) ProcessUtilities.popenExecutioner(command, website.externalApp) - final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'message': "Theme updates started in the background."}) + final_json = json.dumps( + {'status': 1, 'fetchStatus': 1, 'message': "Theme updates started in the background."}) return HttpResponse(final_json) elif self.data['plugin'] == 'selected': if self.data['allPluginsChecked']: @@ -2395,7 +2399,7 @@ class CloudManager: return HttpResponse(final_json) else: command = 'wp theme activate %s --path=%s' % ( - self.data['plugin'], path) + self.data['plugin'], path) ProcessUtilities.executioner(command, website.externalApp) final_json = json.dumps( {'status': 1, 'fetchStatus': 1, 'message': "Theme successfully activated."}) @@ -2540,7 +2544,7 @@ class CloudManager: ProcessUtilities.executioner(command, website.externalApp) final_json = json.dumps( - {'status': 1, 'message': "Autoupdates configured."}) + {'status': 1, 'message': "Autoupdates configured."}) return HttpResponse(final_json) except BaseException as msg: final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} @@ -2567,12 +2571,11 @@ class CloudManager: if cronLine.find('WPAutoUpdates.py') > -1: finalCron = cronLine - if finalCron.find('WPAutoUpdates.py') == -1: finalCron = 'Not Set' final_json = json.dumps( - {'status': 1, 'cliVersion': cliVersion, 'finalCron': finalCron}) + {'status': 1, 'cliVersion': cliVersion, 'finalCron': finalCron}) return HttpResponse(final_json) except BaseException as msg: final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} @@ -2614,7 +2617,8 @@ class CloudManager: result = ProcessUtilities.outputExecutioner(command) if result.find('Error:') > -1: - final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': 'This does not seem to be a WordPress installation'} + final_dic = {'status': 0, 'fetchStatus': 0, + 'error_message': 'This does not seem to be a WordPress installation'} final_json = json.dumps(final_dic) return HttpResponse(final_json) else: @@ -2628,8 +2632,24 @@ class CloudManager: def SubmitCyberPanelUpgrade(self): try: + try: + mail = str(int(self.data['mail'])) + except: + mail = '0' + + try: + dns = str(int(self.data['dns'])) + except: + dns = '0' + + try: + ftp = str(int(self.data['ftp'])) + except: + ftp = '0' + + execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/CyberPanelUpgrade.py --branch %s --mail %s --dns %s --ftp %s" % ( + self.data['CyberPanelBranch'], mail, dns, ftp) - execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/CyberPanelUpgrade.py" ProcessUtilities.popenExecutioner(execPath) final_json = json.dumps({'status': 1}) return HttpResponse(final_json) @@ -2637,4 +2657,4 @@ class CloudManager: except BaseException as msg: final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) - return HttpResponse(final_json) \ No newline at end of file + return HttpResponse(final_json) diff --git a/cyberpanel.sh b/cyberpanel.sh index 4d1cb42e6..942148526 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -104,7 +104,7 @@ echo -e "\n${1}=${2}\n" >> /tmp/cyberpanel_debug.log Debug_Log2() { Check_Server_IP "$@" echo -e "\n${1}" >> /var/log/installLogs.txt -curl -d '{"ipAddress": "'"$Server_IP"'", "InstallCyberPanelStatus": "'"$1"'"}' -H "Content-Type: application/json" -X POST http://cloud.cyberpanel.net:8000/servers/RecvData > /dev/null +curl -d '{"ipAddress": "'"$Server_IP"'", "InstallCyberPanelStatus": "'"$1"'"}' -H "Content-Type: application/json" -X POST https://cloud.cyberpanel.net/servers/RecvData > /dev/null } Branch_Check() { diff --git a/install/installLog.py b/install/installLog.py index 3699a6834..cf16daf8f 100755 --- a/install/installLog.py +++ b/install/installLog.py @@ -7,7 +7,7 @@ import requests class InstallLog: fileName = "/var/log/installLogs.txt" currentPercent = '10' - LogURL = 'http://cloud.cyberpanel.net:8000/servers/RecvData' + LogURL = 'https://cloud.cyberpanel.net/servers/RecvData' ServerIP = '' @staticmethod diff --git a/plogical/CyberPanelUpgrade.py b/plogical/CyberPanelUpgrade.py index 61bf1e42f..9f364e889 100644 --- a/plogical/CyberPanelUpgrade.py +++ b/plogical/CyberPanelUpgrade.py @@ -1,5 +1,4 @@ import json -import os import os.path import sys import argparse @@ -17,17 +16,87 @@ class UpgradeCyberPanel: f = open(ipFile) ipData = f.read() self.ipAddress = ipData.split('\n', 1)[0] + self.branch = branch + self.mail = mail + self.ftp = ftp + self.dns = dns def PostStatus(self, message): finalData = json.dumps({'ipAddress': self.ipAddress, "UpgradeCyberPanelStatus": message}) resp = requests.post(UpgradeCyberPanel.LogURL, data=finalData, verify=False) print (resp.text) + def RestoreOldCP(self): + + from plogical.upgrade import Upgrade + + command = 'rm -rf /usr/local/CyberCP' + Upgrade.executioner(command, command) + + command = 'mv /usr/local/CyberCPBak /usr/local/CyberCP' + Upgrade.executioner(command, command) + Upgrade.fixPermissions() + + def UpgardeNow(self): - self.PostStatus('Upgrade in route..,35') - import time - time.sleep(10) - self.PostStatus('Upgrade completed. [200]') + + from plogical.upgrade import Upgrade + + self.PostStatus('Backing up current installation..,5' % (self.branch)) + + command = 'cp -R /usr/local/CyberCP /usr/local/CyberCPBak' + Upgrade.executioner(command, command) + + self.PostStatus('Upgrading/Downgrading to branch %s..,10' % (self.branch)) + + status, message = Upgrade.downloadAndUpgrade(None, self.branch) + + if status == 0: + self.RestoreOldCP() + self.PostStatus('Failed to upgrade, error %s.[404]' % (message)) + return 0 + + self.PostStatus('CyberPanel is now on %s..,40' % (self.branch)) + + ## + + self.PostStatus('Updating database..,45') + + Upgrade.mailServerMigrations() + Upgrade.emailMarketingMigrationsa() + Upgrade.dockerMigrations() + Upgrade.CLMigrations() + Upgrade.IncBackupMigrations() + Upgrade.applyLoginSystemMigrations() + Upgrade.s3BackupMigrations() + Upgrade.containerMigrations() + Upgrade.manageServiceMigrations() + + self.PostStatus('Database updated.,55') + + + ## Put function here to update custom ACLs + + Upgrade.UpdateConfigOfCustomACL() + Upgrade.enableServices() + Upgrade.someDirectories() + Upgrade.GeneralMigrations() + + ## Upgrade version + + self.PostStatus('Fixing permissions,70') + + Upgrade.fixPermissions() + + ## + + Upgrade.upgradeVersion() + Upgrade.UpdateMaxSSLCons() + + self.PostStatus('CyberPanel Upgraded/Downgraded to %s. [200]' % (self.branch)) + + + def main(): @@ -39,7 +108,7 @@ def main(): args = parser.parse_args() - uc = UpgradeCyberPanel(1,1,1,1) + uc = UpgradeCyberPanel(args.branch,int(args.mail),int(args.dns),int(args.ftp)) uc.UpgardeNow() diff --git a/plogical/upgrade.py b/plogical/upgrade.py index 5fa6c24d9..f40c809be 100755 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -1772,8 +1772,10 @@ imap_folder_list_limit = 0 Upgrade.staticContent() - except: - pass + return 1, None + + except BaseException as msg: + return 0, str(msg) @staticmethod def installLSCPD(branch):