mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-15 17:56:12 +01:00
enale elastic search and start
This commit is contained in:
@@ -1,9 +1,17 @@
|
|||||||
|
import os
|
||||||
|
import os.path
|
||||||
|
import sys
|
||||||
|
import django
|
||||||
|
sys.path.append('/usr/local/CyberCP')
|
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||||
|
django.setup()
|
||||||
from random import randint
|
from random import randint
|
||||||
from plogical.processUtilities import ProcessUtilities
|
from plogical.processUtilities import ProcessUtilities
|
||||||
from dns.models import Supermasters
|
from dns.models import Supermasters
|
||||||
from manageServices.models import SlaveServers
|
from manageServices.models import SlaveServers
|
||||||
import argparse
|
import argparse
|
||||||
from serverStatus.serverStatusUtil import ServerStatusUtil
|
from serverStatus.serverStatusUtil import ServerStatusUtil
|
||||||
|
from plogical import CyberCPLogFileWriter as logging
|
||||||
|
|
||||||
class ServiceManager:
|
class ServiceManager:
|
||||||
|
|
||||||
@@ -127,9 +135,58 @@ superslave=yes
|
|||||||
Supermasters(ip=self.extraArgs['masterServerIP'], nameserver=self.extraArgs['slaveServerNS'], account='').save()
|
Supermasters(ip=self.extraArgs['masterServerIP'], nameserver=self.extraArgs['slaveServerNS'], account='').save()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def installElasticSearch():
|
def InstallElasticSearch():
|
||||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
|
||||||
"Packages successfully installed.[200]\n", 1)
|
statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
|
||||||
|
|
||||||
|
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||||
|
command = 'rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch'
|
||||||
|
ServerStatusUtil.executioner(command, statusFile)
|
||||||
|
|
||||||
|
repoPath = '/etc/yum.repos.d/elasticsearch.repo'
|
||||||
|
|
||||||
|
content = '''[elasticsearch]
|
||||||
|
name=Elasticsearch repository for 7.x packages
|
||||||
|
baseurl=https://artifacts.elastic.co/packages/7.x/yum
|
||||||
|
gpgcheck=1
|
||||||
|
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
|
||||||
|
enabled=0
|
||||||
|
autorefresh=1
|
||||||
|
type=rpm-md
|
||||||
|
'''
|
||||||
|
|
||||||
|
writeToFile = open(repoPath, 'w')
|
||||||
|
writeToFile.write(content)
|
||||||
|
writeToFile.close()
|
||||||
|
|
||||||
|
command = 'yum install --enablerepo=elasticsearch elasticsearch -y'
|
||||||
|
ServerStatusUtil.executioner(command, statusFile)
|
||||||
|
|
||||||
|
command = 'mkdir -p /home/elasticsearch/tmp'
|
||||||
|
ServerStatusUtil.executioner(command, statusFile)
|
||||||
|
|
||||||
|
command = 'chown elasticsearch:elasticsearch /home/elasticsearch/tmp'
|
||||||
|
ServerStatusUtil.executioner(command, statusFile)
|
||||||
|
|
||||||
|
|
||||||
|
jvmOptions = '/etc/elasticsearch/jvm.options'
|
||||||
|
|
||||||
|
writeToFile = open(jvmOptions, 'a')
|
||||||
|
writeToFile.write('-Djava.io.tmpdir=/home/elasticsearch/tmp\n')
|
||||||
|
writeToFile.close()
|
||||||
|
|
||||||
|
command = 'systemctl enable elasticsearch'
|
||||||
|
ServerStatusUtil.executioner(command, statusFile)
|
||||||
|
|
||||||
|
command = 'systemctl start elasticsearch'
|
||||||
|
ServerStatusUtil.executioner(command, statusFile)
|
||||||
|
|
||||||
|
command = 'touch /home/cyberpanel/elasticsearch'
|
||||||
|
ServerStatusUtil.executioner(command, statusFile)
|
||||||
|
|
||||||
|
|
||||||
|
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||||
|
"Packages successfully installed.[200]\n", 1)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -145,8 +202,6 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|||||||
@@ -63,8 +63,6 @@
|
|||||||
×
|
×
|
||||||
</button>
|
</button>
|
||||||
<h4 class="modal-title">{$ status $} {$ appName $} ... <img ng-hide="cyberpanelLoading" src="{% static 'images/loading.gif' %}">
|
<h4 class="modal-title">{$ status $} {$ appName $} ... <img ng-hide="cyberpanelLoading" src="{% static 'images/loading.gif' %}">
|
||||||
<img ng-hide="cyberpanelLoading"
|
|
||||||
src="{% static 'images/loading.gif' %}">
|
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
|||||||
@@ -346,9 +346,16 @@ def removeInstall(request):
|
|||||||
data = json.loads(request.body)
|
data = json.loads(request.body)
|
||||||
|
|
||||||
status = data['status']
|
status = data['status']
|
||||||
service = data['service']
|
appName = data['appName']
|
||||||
|
|
||||||
command = '/usr/local/CyberCP/manageServices/serviceManager.py --function InstallElasticSearch'
|
if appName == 'Elastic Search':
|
||||||
|
if status == 'Installing':
|
||||||
|
command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/manageServices/serviceManager.py --function InstallElasticSearch'
|
||||||
|
|
||||||
|
ProcessUtilities.popenExecutioner(command)
|
||||||
|
data_ret = {'status': 1}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
|
|||||||
Reference in New Issue
Block a user