diff --git a/firewall/static/firewall/firewall.js b/firewall/static/firewall/firewall.js index a0acd1f53..eaa372adb 100755 --- a/firewall/static/firewall/firewall.js +++ b/firewall/static/firewall/firewall.js @@ -2171,8 +2171,6 @@ app.controller('installImunify', function ($scope, $http, $timeout, $window) { text: 'Could not connect to server, please refresh this page', type: 'error' }); - - } } diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index 57b3909ed..5063926d3 100755 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -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: diff --git a/serverStatus/static/serverStatus/serverStatus.js b/serverStatus/static/serverStatus/serverStatus.js index 7ab77b3d1..40689c2f7 100755 --- a/serverStatus/static/serverStatus/serverStatus.js +++ b/serverStatus/static/serverStatus/serverStatus.js @@ -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' + }); + } + + } + }); \ No newline at end of file diff --git a/serverStatus/templates/serverStatus/packageManager.html b/serverStatus/templates/serverStatus/packageManager.html index c94bd995b..7cea53791 100755 --- a/serverStatus/templates/serverStatus/packageManager.html +++ b/serverStatus/templates/serverStatus/packageManager.html @@ -37,6 +37,57 @@ Fetched Packages: {$ fetchedPackages $} + + Update All + +