mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-16 18:26:12 +01:00
package manager support for cent7
This commit is contained in:
@@ -67,16 +67,23 @@ class ApplicationInstaller(multi.Thread):
|
|||||||
|
|
||||||
f = open(ServerStatusUtil.lswsInstallStatusPath, 'a')
|
f = open(ServerStatusUtil.lswsInstallStatusPath, 'a')
|
||||||
|
|
||||||
if package == 'all':
|
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||||
command = 'apt-get update -y'
|
|
||||||
f.write(ProcessUtilities.outputExecutioner(command))
|
|
||||||
|
|
||||||
f.flush()
|
if package == 'all':
|
||||||
|
command = 'apt-get update -y'
|
||||||
|
f.write(ProcessUtilities.outputExecutioner(command))
|
||||||
|
|
||||||
command = 'apt-get upgrade -y'
|
f.flush()
|
||||||
f.write(ProcessUtilities.outputExecutioner(command))
|
|
||||||
else:
|
command = 'apt-get upgrade -y'
|
||||||
command = 'apt-get install --only-upgrade %s -y' % (package)
|
f.write(ProcessUtilities.outputExecutioner(command))
|
||||||
|
else:
|
||||||
|
command = 'apt-get install --only-upgrade %s -y' % (package)
|
||||||
|
f.write(ProcessUtilities.outputExecutioner(command))
|
||||||
|
|
||||||
|
f.close()
|
||||||
|
elif ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||||
|
command = 'yum update %s -y' % (package)
|
||||||
f.write(ProcessUtilities.outputExecutioner(command))
|
f.write(ProcessUtilities.outputExecutioner(command))
|
||||||
|
|
||||||
f.close()
|
f.close()
|
||||||
|
|||||||
@@ -753,6 +753,59 @@ def fetchPackages(request):
|
|||||||
upgradePackages.append(pack)
|
upgradePackages.append(pack)
|
||||||
|
|
||||||
packages = upgradePackages
|
packages = upgradePackages
|
||||||
|
elif ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||||
|
|
||||||
|
if type == 'installed':
|
||||||
|
|
||||||
|
#### Cater for packages that need updates.
|
||||||
|
|
||||||
|
startForUpdate = 1
|
||||||
|
|
||||||
|
command = 'yum check-update'
|
||||||
|
updates = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||||
|
|
||||||
|
for items in updates:
|
||||||
|
if items == '':
|
||||||
|
updates = updates[startForUpdate:]
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
startForUpdate = startForUpdate + 1
|
||||||
|
|
||||||
|
## make list of packages that need update
|
||||||
|
|
||||||
|
updateNeeded = []
|
||||||
|
for items in updates:
|
||||||
|
updateNeeded.append(items.split(' ')[0])
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
command = 'yum list installed'
|
||||||
|
packages = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||||
|
|
||||||
|
startFrom = 1
|
||||||
|
|
||||||
|
for items in packages:
|
||||||
|
if items.find('Installed Packages') > -1:
|
||||||
|
packages = packages[startFrom:]
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
startFrom = startFrom + 1
|
||||||
|
elif type == 'upgrade':
|
||||||
|
#### Cater for packages that need updates.
|
||||||
|
|
||||||
|
startForUpdate = 1
|
||||||
|
|
||||||
|
command = 'yum check-update'
|
||||||
|
packages = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||||
|
|
||||||
|
for items in packages:
|
||||||
|
if items == '':
|
||||||
|
packages = packages[startForUpdate:-1]
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
startForUpdate = startForUpdate + 1
|
||||||
|
|
||||||
|
## make list of packages that need update
|
||||||
|
|
||||||
|
|
||||||
#if os.path.exists(ProcessUtilities.debugPath):
|
#if os.path.exists(ProcessUtilities.debugPath):
|
||||||
@@ -773,51 +826,80 @@ def fetchPackages(request):
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
for items in finalPackages:
|
for items in finalPackages:
|
||||||
try:
|
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||||
if type == 'CyberPanel':
|
try:
|
||||||
|
if type == 'CyberPanel':
|
||||||
|
|
||||||
packageName = items['Package'].split('/')[0]
|
packageName = items['Package'].split('/')[0]
|
||||||
|
|
||||||
|
if packageName in locked:
|
||||||
|
lock = 1
|
||||||
|
else:
|
||||||
|
lock = 0
|
||||||
|
|
||||||
|
dic = {'package': packageName,
|
||||||
|
'version': items['Version'], 'lock': lock}
|
||||||
|
|
||||||
|
counter = counter + 1
|
||||||
|
if checker == 0:
|
||||||
|
json_data = json_data + json.dumps(dic)
|
||||||
|
checker = 1
|
||||||
|
else:
|
||||||
|
json_data = json_data + ',' + json.dumps(dic)
|
||||||
|
|
||||||
if packageName in locked:
|
|
||||||
lock = 1
|
|
||||||
else:
|
else:
|
||||||
lock = 0
|
nowSplitted = items.split('now')
|
||||||
|
|
||||||
dic = {'package': packageName,
|
upgrade = 'Not Needed'
|
||||||
'version': items['Version'], 'lock': lock}
|
|
||||||
|
|
||||||
counter = counter + 1
|
if nowSplitted[1].split(' ')[3].find('upgradable') > -1:
|
||||||
if checker == 0:
|
current = nowSplitted[1].split(' ')
|
||||||
json_data = json_data + json.dumps(dic)
|
upgrade = '%s %s %s' % (current[3], current[4], current[5])
|
||||||
checker = 1
|
|
||||||
else:
|
|
||||||
json_data = json_data + ',' + json.dumps(dic)
|
|
||||||
|
|
||||||
else:
|
if nowSplitted[0].split('/')[0] in locked:
|
||||||
nowSplitted = items.split('now')
|
lock = 1
|
||||||
|
else:
|
||||||
|
lock = 0
|
||||||
|
|
||||||
upgrade = 'Not Needed'
|
dic = {'package': nowSplitted[0].split('/')[0], 'version': '%s %s' % (nowSplitted[1].split(' ')[1], nowSplitted[1].split(' ')[2]), 'upgrade': upgrade, 'lock': lock}
|
||||||
|
|
||||||
if nowSplitted[1].split(' ')[3].find('upgradable') > -1:
|
counter = counter + 1
|
||||||
current = nowSplitted[1].split(' ')
|
if checker == 0:
|
||||||
upgrade = '%s %s %s' % (current[3], current[4], current[5])
|
json_data = json_data + json.dumps(dic)
|
||||||
|
checker = 1
|
||||||
|
else:
|
||||||
|
json_data = json_data + ',' + json.dumps(dic)
|
||||||
|
except BaseException as msg:
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile('[ERROR] %s. [fetchPackages:773]' % (str(msg)))
|
||||||
|
elif ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||||
|
try:
|
||||||
|
if type == 'installed' or type == 'upgrade':
|
||||||
|
|
||||||
if nowSplitted[0].split('/')[0] in locked:
|
details = items.split(' ')
|
||||||
lock = 1
|
details = [a for a in details if a != '']
|
||||||
else:
|
|
||||||
lock = 0
|
|
||||||
|
|
||||||
dic = {'package': nowSplitted[0].split('/')[0], 'version': '%s %s' % (nowSplitted[1].split(' ')[1], nowSplitted[1].split(' ')[2]), 'upgrade': upgrade, 'lock': lock}
|
if type == 'installed':
|
||||||
|
if details[0] in updateNeeded:
|
||||||
|
upgrade = 'Upgrade available'
|
||||||
|
else:
|
||||||
|
upgrade = 'Not needed.'
|
||||||
|
else:
|
||||||
|
upgrade = 'Upgrade available'
|
||||||
|
|
||||||
counter = counter + 1
|
dic = {'package': details[0],
|
||||||
if checker == 0:
|
'version': details[1],
|
||||||
json_data = json_data + json.dumps(dic)
|
'upgrade': upgrade, 'lock': 1}
|
||||||
checker = 1
|
|
||||||
else:
|
|
||||||
json_data = json_data + ',' + json.dumps(dic)
|
|
||||||
|
|
||||||
except BaseException as msg:
|
counter = counter + 1
|
||||||
logging.CyberCPLogFileWriter.writeToFile('[ERROR] %s. [fetchPackages:773]' % (str(msg)))
|
if checker == 0:
|
||||||
|
json_data = json_data + json.dumps(dic)
|
||||||
|
checker = 1
|
||||||
|
else:
|
||||||
|
json_data = json_data + ',' + json.dumps(dic)
|
||||||
|
|
||||||
|
|
||||||
|
except BaseException as msg:
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile('[ERROR] %s. [fetchPackages:839]' % (str(msg)))
|
||||||
|
|
||||||
json_data = json_data + ']'
|
json_data = json_data + ']'
|
||||||
|
|
||||||
@@ -847,6 +929,9 @@ def fetchPackageDetails(request):
|
|||||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||||
command = 'apt-cache show %s' % (package)
|
command = 'apt-cache show %s' % (package)
|
||||||
packageDetails = ProcessUtilities.outputExecutioner(command)
|
packageDetails = ProcessUtilities.outputExecutioner(command)
|
||||||
|
elif ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||||
|
command = 'yum info %s' % (package)
|
||||||
|
packageDetails = ProcessUtilities.outputExecutioner(command)
|
||||||
|
|
||||||
data_ret = {'status': 1, 'packageDetails': packageDetails}
|
data_ret = {'status': 1, 'packageDetails': packageDetails}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
|
|||||||
Reference in New Issue
Block a user