Skip to content

Commit

Permalink
add redis deamon oneclick install/remove
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Aug 22, 2020
1 parent ebce934 commit 2f6a923
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 7 deletions.
55 changes: 52 additions & 3 deletions manageServices/serviceManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,61 @@ def RemoveElasticSearch():
ServerStatusUtil.executioner(command, statusFile)


jvmOptions = '/etc/elasticsearch/jvm.options'


command = 'rm -f /home/cyberpanel/elasticsearch'
ServerStatusUtil.executioner(command, statusFile)

logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"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')
Expand All @@ -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()



Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions manageServices/static/manageServices/manageServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions manageServices/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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}
Expand Down
Binary file added static/manageServices/images/redis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions static/manageServices/manageServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2f6a923

Please sign in to comment.