final CloudLinux

This commit is contained in:
Usman Nasir
2020-01-01 11:57:13 +05:00
parent d10450f8be
commit 1a95b0d30d
7 changed files with 136 additions and 52 deletions

View File

@@ -41,24 +41,30 @@ class CLManagerMain(multi.Thread):
else:
return ACLManager.loadError()
ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile)
ipData = f.read()
ipAddress = ipData.split('\n', 1)[0]
data = {}
data['CL'] = 0
data['CAGEFS'] = 0
data['activatedPath'] = 0
data['ipAddress'] = ipAddress
CLPath = '/etc/sysconfig/cloudlinux'
CageFSPath = '/usr/sbin/cagefsctl'
activatedPath = '/home/cyberpanel/cloudlinux'
if os.path.exists(CLPath):
data['CL'] = 1
if os.path.exists(CageFSPath):
data['CAGEFS'] = 1
if os.path.exists(activatedPath):
data['activatedPath'] = 1
if data['CL'] == 0:
return render(self.request, 'CLManager/notAvailable.html', data)
elif data['CAGEFS'] == 0:
elif data['activatedPath'] == 0:
return render(self.request, 'CLManager/notAvailable.html', data)
else:
return render(self.request, self.templateName, self.data)
return render(self.request, 'CLManager/cloudLinux.html', data)
def submitCageFSInstall(self):
try:

View File

@@ -1,9 +1,18 @@
#!/usr/local/CyberCP/bin/python
import sys
import os
import django
sys.path.append('/usr/local/CyberCP')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
django.setup()
import plogical.CyberCPLogFileWriter as logging
import argparse
from plogical.mailUtilities import mailUtilities
from plogical.processUtilities import ProcessUtilities
from plogical.firewallUtilities import FirewallUtilities
from firewall.models import FirewallRules
from serverStatus.serverStatusUtil import ServerStatusUtil
@@ -11,6 +20,37 @@ class CageFS:
packages = ['talksho']
users = ['5001']
@staticmethod
def EnableCloudLinux():
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
confPath = '/usr/local/lsws/conf/httpd_config.conf'
data = open(confPath, 'r').readlines()
writeToFile = open(confPath, 'w')
for items in data:
if items.find('priority') > -1:
writeToFile.writelines(items)
writeToFile.writelines('enableLVE 2\n')
else:
writeToFile.writelines(items)
writeToFile.close()
else:
confPath = '/usr/local/lsws/conf/httpd_config.xml'
data = open(confPath, 'r').readlines()
writeToFile = open(confPath, 'w')
for items in data:
if items.find('<enableChroot>') > -1:
writeToFile.writelines(items)
writeToFile.writelines(' <enableLVE>2</enableLVE>\n')
else:
writeToFile.writelines(items)
writeToFile.close()
@staticmethod
def submitCageFSInstall():
try:
@@ -20,19 +60,52 @@ class CageFS:
statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"Starting Packages Installation..\n", 1)
"Checking if LVE Kernel is loaded ..\n", 1)
command = 'sudo yum install cagefs -y'
if ProcessUtilities.outputExecutioner('uname -a').find('lve') == -1:
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"CloudLinux is installed but kernel is not loaded, please reboot your server to load appropriate kernel. [404]\n", 1)
return 0
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"CloudLinux Kernel detected..\n", 1)
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"Enabling CloudLinux in web server ..\n", 1)
CageFS.EnableCloudLinux()
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"CloudLinux enabled in server ..\n", 1)
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"Adding LVEManager port ..\n", 1)
try:
FirewallUtilities.addRule('tcp', '9000', '0.0.0.0/0')
newFWRule = FirewallRules(name='lvemanager', proto='tcp', port='9000', ipAddress='0.0.0.0/0')
newFWRule.save()
except:
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"LVEManager port added ..\n", 1)
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"Reinstalling important components ..\n", 1)
command = 'yum install -y lvemanager'
ServerStatusUtil.executioner(command, statusFile)
command = 'sudo /usr/sbin/cagefsctl --init'
command = 'yum reinstall -y lvemanager lve-utils cagefs alt-python27-cllib'
ServerStatusUtil.executioner(command, statusFile)
command = 'sudo /usr/sbin/cagefsctl --update-etc'
ServerStatusUtil.executioner(command, statusFile)
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"Important components reinstalled..\n", 1)
command = 'sudo /usr/sbin/cagefsctl --force-update'
ServerStatusUtil.executioner(command, statusFile)
activatedPath = '/home/cyberpanel/cloudlinux'
writeToFile = open(activatedPath, 'a')
writeToFile.write('CLInstalled')
writeToFile.close()
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"Packages successfully installed.[200]\n", 1)

View File

@@ -50,7 +50,7 @@ app.controller('installCageFS', function ($scope, $http, $timeout, $window) {
};
function getRequestStatus() {
$scope.cyberPanelLoading = false;
$scope.installDockerStatus = false;
url = "/serverstatus/switchTOLSWSStatus";
@@ -72,7 +72,7 @@ app.controller('installCageFS', function ($scope, $http, $timeout, $window) {
$timeout(getRequestStatus, 1000);
} else {
// Notifications
$scope.cyberPanelLoading = true;
$scope.installDockerStatus = true;
$timeout.cancel();
$scope.requestData = response.data.requestStatus;
if (response.data.installed === 1) {
@@ -85,7 +85,7 @@ app.controller('installCageFS', function ($scope, $http, $timeout, $window) {
}
function cantLoadInitialDatas(response) {
$scope.cyberPanelLoading = true;
$scope.installDockerStatus = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',

View File

@@ -0,0 +1,37 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "CloudLinux - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container">
<div id="page-title">
<h2>{% trans "CloudLinux" %}</h2>
<p>{% trans "Access LVEManager" %}</p>
</div>
<div class="panel">
<div class="panel-body">
<h3 class="title-hero">
{% trans "CloudLinux" %}
</h3>
<div class="example-box-wrapper">
<p>{% trans "CloudLinux is now integrated via their new API. You can manage CageFS and Package limits directly from LVEManager by clicking below. You can use your server root credentials to access LVEManager." %}</p>
<br>
<a target="_blank" href="http://{{ ipAddress }}:9000">
<button class="btn btn-primary">Access Now
</button>
</a>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -19,7 +19,7 @@
<div class="row">
<div class="col-sm-12">
<div class="alert alert-danger">
<p>{% trans "CageFS is only available with CloudLinux OS. " %} <a target="_blank"
<p>{% trans "CloudLinux is not installed on your server." %} <a target="_blank"
href="https://go.cyberpanel.net/CLConvert">Click
Here</a> {% trans " for conversion details." %}</p>
</div>
@@ -31,12 +31,12 @@
<div ng-controller="installCageFS" class="panel">
<div class="panel-body">
<h3 class="title-hero">
{% trans "Install Packages" %} <img ng-hide="installDockerStatus"
{% trans "Activate Now" %} <img ng-hide="installDockerStatus"
src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
<p>{% trans "CageFS is not installed on this server. Please proceed to installation." %}</p>
<p>{% trans "CloudLinux is installed, but not activated." %}</p>
<!------ LSWS Switch box ----------------->
<div style="margin-top: 2%" ng-hide="installBoxGen" class="col-md-12">
@@ -54,7 +54,7 @@
<!----- LSWS Switch box ----------------->
<br>
<button ng-hide="dockerInstallBTN" class="btn btn-primary" ng-click="submitCageFSInstall()">Install Now</button>
<button ng-hide="dockerInstallBTN" class="btn btn-primary" ng-click="submitCageFSInstall()">Activate Now</button>
</div>
</div>

View File

@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
from django.shortcuts import redirect, HttpResponse
from loginSystem.views import loadLoginPage
from plogical.acl import ACLManager

View File

@@ -50,37 +50,6 @@ class virtualHostUtilities:
ols = 2
lsws = 3
@staticmethod
def EnableCloudLinux():
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
confPath = '/usr/local/lsws/conf/httpd_config.conf'
data = open(confPath, 'r').readlines()
writeToFile = open(confPath, 'w')
for items in data:
if items.find('priority') > -1:
writeToFile.writelines(items)
writeToFile.writelines('enableLVE 2\n')
else:
writeToFile.writelines(items)
writeToFile.close()
else:
confPath = '/usr/local/lsws/conf/httpd_config.xml'
data = open(confPath, 'r').readlines()
writeToFile = open(confPath, 'w')
for items in data:
if items.find('<enableChroot>') > -1:
writeToFile.writelines(items)
writeToFile.writelines(' <enableLVE>2</enableLVE>\n')
else:
writeToFile.writelines(items)
writeToFile.close()
Server_root = "/usr/local/lsws"
cyberPanel = "/usr/local/CyberCP"