diff --git a/manageServices/serviceManager.py b/manageServices/serviceManager.py index 333d47021..56dd56157 100755 --- a/manageServices/serviceManager.py +++ b/manageServices/serviceManager.py @@ -241,9 +241,6 @@ type=rpm-md ServerStatusUtil.executioner(command, statusFile) - jvmOptions = '/etc/elasticsearch/jvm.options' - - command = 'rm -f /home/cyberpanel/elasticsearch' ServerStatusUtil.executioner(command, statusFile) @@ -251,6 +248,54 @@ type=rpm-md "ElasticSearch successfully removed.[200]\n", 1) return 0 + @staticmethod + def InstallRedis(): + + statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w') + + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + command = 'yum install redis -y' + ServerStatusUtil.executioner(command, statusFile) + else: + + command = 'apt-get install redis-server -y' + ServerStatusUtil.executioner(command, statusFile) + + + command = 'systemctl enable redis' + ServerStatusUtil.executioner(command, statusFile) + + command = 'systemctl start redis' + ServerStatusUtil.executioner(command, statusFile) + + command = 'touch /home/cyberpanel/redis' + ServerStatusUtil.executioner(command, statusFile) + + logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, + "Redis successfully installed.[200]\n", 1) + return 0 + + @staticmethod + def RemoveRedis(): + + statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w') + + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + command = 'yum erase redis -y' + ServerStatusUtil.executioner(command, statusFile) + else: + + command = 'apt-get remove redis-server -y' + ServerStatusUtil.executioner(command, statusFile) + + + command = 'rm -f /home/cyberpanel/redis' + ServerStatusUtil.executioner(command, statusFile) + + logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, + "Redis successfully removed.[200]\n", 1) + return 0 + def main(): parser = argparse.ArgumentParser(description='CyberPanel Application Manager') @@ -263,6 +308,10 @@ def main(): ServiceManager.InstallElasticSearch() elif args["function"] == "RemoveElasticSearch": ServiceManager.RemoveElasticSearch() + elif args["function"] == "InstallRedis": + ServiceManager.InstallRedis() + elif args["function"] == "RemoveRedis": + ServiceManager.RemoveRedis() diff --git a/manageServices/static/manageServices/images/redis.png b/manageServices/static/manageServices/images/redis.png new file mode 100644 index 000000000..a6fa300bf Binary files /dev/null and b/manageServices/static/manageServices/images/redis.png differ diff --git a/manageServices/static/manageServices/manageServices.js b/manageServices/static/manageServices/manageServices.js index 27a4100e3..949fab41c 100755 --- a/manageServices/static/manageServices/manageServices.js +++ b/manageServices/static/manageServices/manageServices.js @@ -497,9 +497,7 @@ app.controller('manageApplications', function ($scope, $http, $timeout, $window) function ListInitialDatas(response) { - if (response.data.abort === 0) { - $scope.cyberpanelLoading = true; $scope.requestData = response.data.requestStatus; $timeout(getRequestStatus, 1000); } else { diff --git a/manageServices/views.py b/manageServices/views.py index 577899fe8..c4bc2f697 100755 --- a/manageServices/views.py +++ b/manageServices/views.py @@ -315,14 +315,23 @@ def manageApplications(request): ## ElasticSearch esPath = '/home/cyberpanel/elasticsearch' + rPath = '/home/cyberpanel/redis' if os.path.exists(esPath): installed = 'Installed' else: installed = 'Not-Installed' + if os.path.exists(rPath): + rInstalled = 'Installed' + else: + rInstalled = 'Not-Installed' + elasticSearch = {'image': '/static/manageServices/images/elastic-search.png', 'name': 'Elastic Search', 'installed': installed} + redis = {'image': '/static/manageServices/images/redis.png', 'name': 'Redis', + 'installed': rInstalled} services.append(elasticSearch) + services.append(redis) try: return render(request, 'manageServices/applications.html', {'services': services}) @@ -353,6 +362,11 @@ def removeInstall(request): command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/manageServices/serviceManager.py --function InstallElasticSearch' else: command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/manageServices/serviceManager.py --function RemoveElasticSearch' + elif appName == 'Redis': + if status == 'Installing': + command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/manageServices/serviceManager.py --function InstallRedis' + else: + command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/manageServices/serviceManager.py --function RemoveRedis' ProcessUtilities.popenExecutioner(command) data_ret = {'status': 1} diff --git a/static/manageServices/images/redis.png b/static/manageServices/images/redis.png new file mode 100644 index 000000000..a6fa300bf Binary files /dev/null and b/static/manageServices/images/redis.png differ diff --git a/static/manageServices/manageServices.js b/static/manageServices/manageServices.js index 27a4100e3..949fab41c 100644 --- a/static/manageServices/manageServices.js +++ b/static/manageServices/manageServices.js @@ -497,9 +497,7 @@ app.controller('manageApplications', function ($scope, $http, $timeout, $window) function ListInitialDatas(response) { - if (response.data.abort === 0) { - $scope.cyberpanelLoading = true; $scope.requestData = response.data.requestStatus; $timeout(getRequestStatus, 1000); } else {