mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-14 01:06:09 +01:00
add package upgrade for ubuntu
This commit is contained in:
@@ -2171,8 +2171,6 @@ app.controller('installImunify', function ($scope, $http, $timeout, $window) {
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
|
||||
if self.installApp == 'wordpress':
|
||||
self.installWordPress()
|
||||
elif self.installApp == 'joomla':
|
||||
@@ -51,10 +52,44 @@ class ApplicationInstaller(multi.Thread):
|
||||
self.installMagento()
|
||||
elif self.installApp == 'convertDomainToSite':
|
||||
self.convertDomainToSite()
|
||||
elif self.installApp == 'updatePackage':
|
||||
self.updatePackage()
|
||||
|
||||
except BaseException as msg:
|
||||
logging.writeToFile(str(msg) + ' [ApplicationInstaller.run]')
|
||||
|
||||
def updatePackage(self):
|
||||
try:
|
||||
|
||||
package = self.extraArgs['package']
|
||||
|
||||
from serverStatus.serverStatusUtil import ServerStatusUtil
|
||||
|
||||
f = open(ServerStatusUtil.lswsInstallStatusPath, 'a')
|
||||
|
||||
if package == 'all':
|
||||
command = 'apt-get update -y'
|
||||
f.write(ProcessUtilities.outputExecutioner(command))
|
||||
|
||||
f.flush()
|
||||
|
||||
command = 'apt-get upgrade -y'
|
||||
f.write(ProcessUtilities.outputExecutioner(command))
|
||||
else:
|
||||
command = 'apt-get install --only-upgrade %s -y' % (package)
|
||||
f.write(ProcessUtilities.outputExecutioner(command))
|
||||
|
||||
f.close()
|
||||
|
||||
logging.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
'Package(s) upgraded successfully. [200]',
|
||||
1)
|
||||
|
||||
except BaseException as msg:
|
||||
from serverStatus.serverStatusUtil import ServerStatusUtil
|
||||
logging.statusWriter(ServerStatusUtil.lswsInstallStatusPath, 'Failed. Error: %s. [404]' % (str(msg)), 1)
|
||||
return 0
|
||||
|
||||
def convertDomainToSite(self):
|
||||
try:
|
||||
|
||||
|
||||
@@ -836,9 +836,9 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
|
||||
};
|
||||
$scope.fetchPackages('upgrade');
|
||||
|
||||
$scope.fetchPackageDetails = function (package) {
|
||||
$scope.fetchPackageDetails = function (packageFetch) {
|
||||
$scope.cyberpanelLoading = false;
|
||||
$scope.package = package;
|
||||
$scope.package = packageFetch;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
@@ -847,7 +847,7 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
|
||||
};
|
||||
|
||||
var data = {
|
||||
package: package
|
||||
package: packageFetch
|
||||
};
|
||||
|
||||
dataurl = "/serverstatus/fetchPackageDetails";
|
||||
@@ -878,4 +878,87 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
|
||||
|
||||
};
|
||||
|
||||
$scope.updatePackage = function (packageToUpgrade = 'all') {
|
||||
$scope.cyberpanelLoading = false;
|
||||
$scope.package = packageToUpgrade;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
var data = {
|
||||
package: packageToUpgrade
|
||||
};
|
||||
|
||||
dataurl = "/serverstatus/updatePackage";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
getRequestStatus();
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
function getRequestStatus() {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
url = "/serverstatus/switchTOLSWSStatus";
|
||||
|
||||
var data = {};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
if (response.data.abort === 0) {
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
$timeout(getRequestStatus, 1000);
|
||||
} else {
|
||||
// Notifications
|
||||
$timeout.cancel();
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
@@ -37,6 +37,57 @@
|
||||
<a style="float: left; margin-bottom: 2%; margin-left: 2%"
|
||||
class="btn btn-border btn-alt border-blue-alt btn-link font-blue-alt" href="#"
|
||||
title=""><span>Fetched Packages: {$ fetchedPackages $}</span></a>
|
||||
|
||||
<a ng-click="updatePackage('all')" data-toggle="modal"
|
||||
data-target="#updatePackage" style="margin-left: 1%"
|
||||
class="btn btn-border btn-alt border-azure btn-link font-azure"
|
||||
href="#"
|
||||
title=""><span>Update All</span></a>
|
||||
|
||||
<div id="updatePackage" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog modal-lg">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal">
|
||||
×
|
||||
</button>
|
||||
<h4 class="modal-title">Upgrading {$ package $}
|
||||
package(s).
|
||||
<img ng-hide="cyberpanelLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<div class="col-sm-12">
|
||||
<textarea ng-model="requestData"
|
||||
class="form-control"
|
||||
rows="12"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button"
|
||||
ng-disabled="savingSettings"
|
||||
class="btn btn-default"
|
||||
data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-10"
|
||||
style="padding: 0px; box-shadow: 0px 0px 1px 0px #888888; margin-bottom: 2%">
|
||||
<input placeholder="Search..."
|
||||
@@ -120,10 +171,56 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a style="margin-left: 1%"
|
||||
<a ng-click="updatePackage(record.package)" data-toggle="modal"
|
||||
data-target="#updatePackage" style="margin-left: 1%"
|
||||
class="btn btn-border btn-alt border-azure btn-link font-azure"
|
||||
href="#"
|
||||
title=""><span>Upgrade</span></a></td>
|
||||
title=""><span>Update</span></a>
|
||||
|
||||
<div id="updatePackage" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog modal-lg">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal">
|
||||
×
|
||||
</button>
|
||||
<h4 class="modal-title">Upgrading {$ package $}
|
||||
package(s).
|
||||
<img ng-hide="cyberpanelLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<div class="col-sm-12">
|
||||
<textarea ng-model="requestData"
|
||||
class="form-control"
|
||||
rows="12"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button"
|
||||
ng-disabled="savingSettings"
|
||||
class="btn btn-default"
|
||||
data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -21,5 +21,6 @@ urlpatterns = [
|
||||
url(r'^packageManager$', views.packageManager, name='packageManager'),
|
||||
url(r'^fetchPackages$', views.fetchPackages, name='fetchPackages'),
|
||||
url(r'^fetchPackageDetails$', views.fetchPackageDetails, name='fetchPackageDetails'),
|
||||
url(r'^updatePackage$', views.updatePackage, name='updatePackage'),
|
||||
|
||||
]
|
||||
@@ -821,3 +821,42 @@ def fetchPackageDetails(request):
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def updatePackage(request):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
data = json.loads(request.body)
|
||||
package = data['package']
|
||||
|
||||
from serverStatus.serverStatusUtil import ServerStatusUtil
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
'Starting package(s) upgrade..',
|
||||
1)
|
||||
|
||||
extraArgs = {}
|
||||
extraArgs['package'] = package
|
||||
|
||||
from plogical.applicationInstaller import ApplicationInstaller
|
||||
|
||||
background = ApplicationInstaller('updatePackage', extraArgs)
|
||||
background.start()
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
data_ret = {'status': 1}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
Reference in New Issue
Block a user