Skip to content

Commit 2f6a923

Browse files
committed
add redis deamon oneclick install/remove
1 parent ebce934 commit 2f6a923

6 files changed

Lines changed: 66 additions & 7 deletions

File tree

manageServices/serviceManager.py

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,16 +241,61 @@ def RemoveElasticSearch():
241241
ServerStatusUtil.executioner(command, statusFile)
242242

243243

244-
jvmOptions = '/etc/elasticsearch/jvm.options'
245-
246-
247244
command = 'rm -f /home/cyberpanel/elasticsearch'
248245
ServerStatusUtil.executioner(command, statusFile)
249246

250247
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
251248
"ElasticSearch successfully removed.[200]\n", 1)
252249
return 0
253250

251+
@staticmethod
252+
def InstallRedis():
253+
254+
statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
255+
256+
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
257+
command = 'yum install redis -y'
258+
ServerStatusUtil.executioner(command, statusFile)
259+
else:
260+
261+
command = 'apt-get install redis-server -y'
262+
ServerStatusUtil.executioner(command, statusFile)
263+
264+
265+
command = 'systemctl enable redis'
266+
ServerStatusUtil.executioner(command, statusFile)
267+
268+
command = 'systemctl start redis'
269+
ServerStatusUtil.executioner(command, statusFile)
270+
271+
command = 'touch /home/cyberpanel/redis'
272+
ServerStatusUtil.executioner(command, statusFile)
273+
274+
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
275+
"Redis successfully installed.[200]\n", 1)
276+
return 0
277+
278+
@staticmethod
279+
def RemoveRedis():
280+
281+
statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
282+
283+
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
284+
command = 'yum erase redis -y'
285+
ServerStatusUtil.executioner(command, statusFile)
286+
else:
287+
288+
command = 'apt-get remove redis-server -y'
289+
ServerStatusUtil.executioner(command, statusFile)
290+
291+
292+
command = 'rm -f /home/cyberpanel/redis'
293+
ServerStatusUtil.executioner(command, statusFile)
294+
295+
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
296+
"Redis successfully removed.[200]\n", 1)
297+
return 0
298+
254299
def main():
255300

256301
parser = argparse.ArgumentParser(description='CyberPanel Application Manager')
@@ -263,6 +308,10 @@ def main():
263308
ServiceManager.InstallElasticSearch()
264309
elif args["function"] == "RemoveElasticSearch":
265310
ServiceManager.RemoveElasticSearch()
311+
elif args["function"] == "InstallRedis":
312+
ServiceManager.InstallRedis()
313+
elif args["function"] == "RemoveRedis":
314+
ServiceManager.RemoveRedis()
266315

267316

268317

2.99 KB
Loading

manageServices/static/manageServices/manageServices.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,7 @@ app.controller('manageApplications', function ($scope, $http, $timeout, $window)
497497

498498

499499
function ListInitialDatas(response) {
500-
501500
if (response.data.abort === 0) {
502-
$scope.cyberpanelLoading = true;
503501
$scope.requestData = response.data.requestStatus;
504502
$timeout(getRequestStatus, 1000);
505503
} else {

manageServices/views.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,14 +315,23 @@ def manageApplications(request):
315315
## ElasticSearch
316316

317317
esPath = '/home/cyberpanel/elasticsearch'
318+
rPath = '/home/cyberpanel/redis'
318319

319320
if os.path.exists(esPath):
320321
installed = 'Installed'
321322
else:
322323
installed = 'Not-Installed'
323324

325+
if os.path.exists(rPath):
326+
rInstalled = 'Installed'
327+
else:
328+
rInstalled = 'Not-Installed'
329+
324330
elasticSearch = {'image': '/static/manageServices/images/elastic-search.png', 'name': 'Elastic Search', 'installed': installed}
331+
redis = {'image': '/static/manageServices/images/redis.png', 'name': 'Redis',
332+
'installed': rInstalled}
325333
services.append(elasticSearch)
334+
services.append(redis)
326335

327336
try:
328337
return render(request, 'manageServices/applications.html', {'services': services})
@@ -353,6 +362,11 @@ def removeInstall(request):
353362
command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/manageServices/serviceManager.py --function InstallElasticSearch'
354363
else:
355364
command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/manageServices/serviceManager.py --function RemoveElasticSearch'
365+
elif appName == 'Redis':
366+
if status == 'Installing':
367+
command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/manageServices/serviceManager.py --function InstallRedis'
368+
else:
369+
command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/manageServices/serviceManager.py --function RemoveRedis'
356370

357371
ProcessUtilities.popenExecutioner(command)
358372
data_ret = {'status': 1}
2.99 KB
Loading

static/manageServices/manageServices.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,7 @@ app.controller('manageApplications', function ($scope, $http, $timeout, $window)
497497

498498

499499
function ListInitialDatas(response) {
500-
501500
if (response.data.abort === 0) {
502-
$scope.cyberpanelLoading = true;
503501
$scope.requestData = response.data.requestStatus;
504502
$timeout(getRequestStatus, 1000);
505503
} else {

0 commit comments

Comments
 (0)