mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
bug fix. cpupgrade
This commit is contained in:
@@ -1659,12 +1659,14 @@ class CloudManager:
|
|||||||
destinationDomain = 'None'
|
destinationDomain = 'None'
|
||||||
|
|
||||||
import time
|
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 = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
|
||||||
execPath = execPath + " CloudBackup --backupDomain %s --data %s --emails %s --databases %s --tempStoragePath %s " \
|
execPath = execPath + " CloudBackup --backupDomain %s --data %s --emails %s --databases %s --tempStoragePath %s " \
|
||||||
"--path %s --port %s --ip %s --destinationDomain %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)
|
ProcessUtilities.popenExecutioner(execPath)
|
||||||
|
|
||||||
final_dic = {'status': 1, 'tempStatusPath': tempStatusPath, 'path': '%s.tar.gz' % (BackupPath)}
|
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 = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
|
||||||
execPath = execPath + " SubmitCloudBackupRestore --backupDomain %s --backupFile %s --sourceDomain %s --tempStoragePath %s" % (
|
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)
|
ProcessUtilities.popenExecutioner(execPath)
|
||||||
|
|
||||||
final_dic = {'status': 1, 'tempStatusPath': tempStatusPath}
|
final_dic = {'status': 1, 'tempStatusPath': tempStatusPath}
|
||||||
@@ -1957,7 +1959,6 @@ class CloudManager:
|
|||||||
finalDic['maintenanceMode'] = 1
|
finalDic['maintenanceMode'] = 1
|
||||||
finalDic['php'] = '7.4'
|
finalDic['php'] = '7.4'
|
||||||
|
|
||||||
|
|
||||||
## Get versopm
|
## Get versopm
|
||||||
|
|
||||||
website = Websites.objects.get(domain=domain)
|
website = Websites.objects.get(domain=domain)
|
||||||
@@ -1997,7 +1998,8 @@ class CloudManager:
|
|||||||
## Search index
|
## Search index
|
||||||
|
|
||||||
command = 'wp option get blog_public --path=%s' % (path)
|
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
|
## Maintenece mode
|
||||||
|
|
||||||
@@ -2043,7 +2045,8 @@ class CloudManager:
|
|||||||
import plogical.randomPassword as randomPassword
|
import plogical.randomPassword as randomPassword
|
||||||
password = randomPassword.generate_pass(32)
|
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)
|
ProcessUtilities.executioner(command, website.externalApp)
|
||||||
|
|
||||||
command = 'wp user update cyberpanel --user_pass="%s" --path=%s' % (password, path)
|
command = 'wp user update cyberpanel --user_pass="%s" --path=%s' % (password, path)
|
||||||
@@ -2072,20 +2075,19 @@ class CloudManager:
|
|||||||
except:
|
except:
|
||||||
path = '/home/%s/public_html' % (self.data['domain'])
|
path = '/home/%s/public_html' % (self.data['domain'])
|
||||||
|
|
||||||
|
|
||||||
if self.data['setting'] == 'lscache':
|
if self.data['setting'] == 'lscache':
|
||||||
if self.data['settingValue']:
|
if self.data['settingValue']:
|
||||||
|
|
||||||
command = "wp plugin install litespeed-cache --path=%s" % (path)
|
command = "wp plugin install litespeed-cache --path=%s" % (path)
|
||||||
ProcessUtilities.executioner(command, website.externalApp)
|
ProcessUtilities.executioner(command, website.externalApp)
|
||||||
|
|
||||||
command = "wp plugin activate litespeed-cache --path=%s" % (path)
|
command = "wp plugin activate litespeed-cache --path=%s" % (path)
|
||||||
ProcessUtilities.executioner(command, website.externalApp)
|
ProcessUtilities.executioner(command, website.externalApp)
|
||||||
|
|
||||||
final_dic = {'status': 1, 'message': 'LSCache successfully installed and activated.'}
|
final_dic = {'status': 1, 'message': 'LSCache successfully installed and activated.'}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
else:
|
else:
|
||||||
command = 'wp plugin deactivate litespeed-cache --path=%s' % (path)
|
command = 'wp plugin deactivate litespeed-cache --path=%s' % (path)
|
||||||
ProcessUtilities.executioner(command, website.externalApp)
|
ProcessUtilities.executioner(command, website.externalApp)
|
||||||
|
|
||||||
@@ -2196,7 +2198,8 @@ class CloudManager:
|
|||||||
if self.data['plugin'] == 'all':
|
if self.data['plugin'] == 'all':
|
||||||
command = 'wp plugin update --all --path=%s' % (path)
|
command = 'wp plugin update --all --path=%s' % (path)
|
||||||
ProcessUtilities.popenExecutioner(command, website.externalApp)
|
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)
|
return HttpResponse(final_json)
|
||||||
elif self.data['plugin'] == 'selected':
|
elif self.data['plugin'] == 'selected':
|
||||||
if self.data['allPluginsChecked']:
|
if self.data['allPluginsChecked']:
|
||||||
@@ -2252,7 +2255,7 @@ class CloudManager:
|
|||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
else:
|
else:
|
||||||
command = 'wp plugin activate %s --path=%s' % (
|
command = 'wp plugin activate %s --path=%s' % (
|
||||||
self.data['plugin'], path)
|
self.data['plugin'], path)
|
||||||
ProcessUtilities.executioner(command, website.externalApp)
|
ProcessUtilities.executioner(command, website.externalApp)
|
||||||
final_json = json.dumps(
|
final_json = json.dumps(
|
||||||
{'status': 1, 'fetchStatus': 1, 'message': "Plugin successfully activated."})
|
{'status': 1, 'fetchStatus': 1, 'message': "Plugin successfully activated."})
|
||||||
@@ -2338,7 +2341,8 @@ class CloudManager:
|
|||||||
if self.data['plugin'] == 'all':
|
if self.data['plugin'] == 'all':
|
||||||
command = 'wp theme update --all --path=%s' % (path)
|
command = 'wp theme update --all --path=%s' % (path)
|
||||||
ProcessUtilities.popenExecutioner(command, website.externalApp)
|
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)
|
return HttpResponse(final_json)
|
||||||
elif self.data['plugin'] == 'selected':
|
elif self.data['plugin'] == 'selected':
|
||||||
if self.data['allPluginsChecked']:
|
if self.data['allPluginsChecked']:
|
||||||
@@ -2395,7 +2399,7 @@ class CloudManager:
|
|||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
else:
|
else:
|
||||||
command = 'wp theme activate %s --path=%s' % (
|
command = 'wp theme activate %s --path=%s' % (
|
||||||
self.data['plugin'], path)
|
self.data['plugin'], path)
|
||||||
ProcessUtilities.executioner(command, website.externalApp)
|
ProcessUtilities.executioner(command, website.externalApp)
|
||||||
final_json = json.dumps(
|
final_json = json.dumps(
|
||||||
{'status': 1, 'fetchStatus': 1, 'message': "Theme successfully activated."})
|
{'status': 1, 'fetchStatus': 1, 'message': "Theme successfully activated."})
|
||||||
@@ -2540,7 +2544,7 @@ class CloudManager:
|
|||||||
ProcessUtilities.executioner(command, website.externalApp)
|
ProcessUtilities.executioner(command, website.externalApp)
|
||||||
|
|
||||||
final_json = json.dumps(
|
final_json = json.dumps(
|
||||||
{'status': 1, 'message': "Autoupdates configured."})
|
{'status': 1, 'message': "Autoupdates configured."})
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
|
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
|
||||||
@@ -2567,12 +2571,11 @@ class CloudManager:
|
|||||||
if cronLine.find('WPAutoUpdates.py') > -1:
|
if cronLine.find('WPAutoUpdates.py') > -1:
|
||||||
finalCron = cronLine
|
finalCron = cronLine
|
||||||
|
|
||||||
|
|
||||||
if finalCron.find('WPAutoUpdates.py') == -1:
|
if finalCron.find('WPAutoUpdates.py') == -1:
|
||||||
finalCron = 'Not Set'
|
finalCron = 'Not Set'
|
||||||
|
|
||||||
final_json = json.dumps(
|
final_json = json.dumps(
|
||||||
{'status': 1, 'cliVersion': cliVersion, 'finalCron': finalCron})
|
{'status': 1, 'cliVersion': cliVersion, 'finalCron': finalCron})
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
|
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
|
||||||
@@ -2614,7 +2617,8 @@ class CloudManager:
|
|||||||
result = ProcessUtilities.outputExecutioner(command)
|
result = ProcessUtilities.outputExecutioner(command)
|
||||||
|
|
||||||
if result.find('Error:') > -1:
|
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)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
else:
|
else:
|
||||||
@@ -2628,8 +2632,24 @@ class CloudManager:
|
|||||||
|
|
||||||
def SubmitCyberPanelUpgrade(self):
|
def SubmitCyberPanelUpgrade(self):
|
||||||
try:
|
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)
|
ProcessUtilities.popenExecutioner(execPath)
|
||||||
final_json = json.dumps({'status': 1})
|
final_json = json.dumps({'status': 1})
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
@@ -2637,4 +2657,4 @@ class CloudManager:
|
|||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
|
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ echo -e "\n${1}=${2}\n" >> /tmp/cyberpanel_debug.log
|
|||||||
Debug_Log2() {
|
Debug_Log2() {
|
||||||
Check_Server_IP "$@"
|
Check_Server_IP "$@"
|
||||||
echo -e "\n${1}" >> /var/log/installLogs.txt
|
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() {
|
Branch_Check() {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import requests
|
|||||||
class InstallLog:
|
class InstallLog:
|
||||||
fileName = "/var/log/installLogs.txt"
|
fileName = "/var/log/installLogs.txt"
|
||||||
currentPercent = '10'
|
currentPercent = '10'
|
||||||
LogURL = 'http://cloud.cyberpanel.net:8000/servers/RecvData'
|
LogURL = 'https://cloud.cyberpanel.net/servers/RecvData'
|
||||||
ServerIP = ''
|
ServerIP = ''
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
@@ -17,17 +16,87 @@ class UpgradeCyberPanel:
|
|||||||
f = open(ipFile)
|
f = open(ipFile)
|
||||||
ipData = f.read()
|
ipData = f.read()
|
||||||
self.ipAddress = ipData.split('\n', 1)[0]
|
self.ipAddress = ipData.split('\n', 1)[0]
|
||||||
|
self.branch = branch
|
||||||
|
self.mail = mail
|
||||||
|
self.ftp = ftp
|
||||||
|
self.dns = dns
|
||||||
|
|
||||||
def PostStatus(self, message):
|
def PostStatus(self, message):
|
||||||
finalData = json.dumps({'ipAddress': self.ipAddress, "UpgradeCyberPanelStatus": message})
|
finalData = json.dumps({'ipAddress': self.ipAddress, "UpgradeCyberPanelStatus": message})
|
||||||
resp = requests.post(UpgradeCyberPanel.LogURL, data=finalData, verify=False)
|
resp = requests.post(UpgradeCyberPanel.LogURL, data=finalData, verify=False)
|
||||||
print (resp.text)
|
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):
|
def UpgardeNow(self):
|
||||||
self.PostStatus('Upgrade in route..,35')
|
|
||||||
import time
|
from plogical.upgrade import Upgrade
|
||||||
time.sleep(10)
|
|
||||||
self.PostStatus('Upgrade completed. [200]')
|
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():
|
def main():
|
||||||
@@ -39,7 +108,7 @@ def main():
|
|||||||
|
|
||||||
args = parser.parse_args()
|
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()
|
uc.UpgardeNow()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1772,8 +1772,10 @@ imap_folder_list_limit = 0
|
|||||||
|
|
||||||
Upgrade.staticContent()
|
Upgrade.staticContent()
|
||||||
|
|
||||||
except:
|
return 1, None
|
||||||
pass
|
|
||||||
|
except BaseException as msg:
|
||||||
|
return 0, str(msg)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def installLSCPD(branch):
|
def installLSCPD(branch):
|
||||||
|
|||||||
Reference in New Issue
Block a user