2019-12-10 23:04:24 +05:00
|
|
|
#!/usr/local/CyberCP/bin/python
|
2019-07-16 23:23:16 +05:00
|
|
|
import sys
|
2020-01-01 11:57:13 +05:00
|
|
|
import os
|
|
|
|
|
import django
|
2019-07-16 23:23:16 +05:00
|
|
|
sys.path.append('/usr/local/CyberCP')
|
2020-01-01 11:57:13 +05:00
|
|
|
|
|
|
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
|
|
|
|
|
|
|
|
|
django.setup()
|
2019-07-16 23:23:16 +05:00
|
|
|
import plogical.CyberCPLogFileWriter as logging
|
|
|
|
|
import argparse
|
|
|
|
|
from plogical.mailUtilities import mailUtilities
|
2020-01-01 11:57:13 +05:00
|
|
|
from plogical.processUtilities import ProcessUtilities
|
|
|
|
|
from plogical.firewallUtilities import FirewallUtilities
|
|
|
|
|
from firewall.models import FirewallRules
|
2019-07-16 23:23:16 +05:00
|
|
|
from serverStatus.serverStatusUtil import ServerStatusUtil
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CageFS:
|
|
|
|
|
packages = ['talksho']
|
|
|
|
|
users = ['5001']
|
|
|
|
|
|
2020-01-01 11:57:13 +05:00
|
|
|
@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()
|
|
|
|
|
|
2020-01-02 17:09:59 +05:00
|
|
|
ProcessUtilities.restartLitespeed()
|
|
|
|
|
|
2019-07-16 23:23:16 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def submitCageFSInstall():
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
mailUtilities.checkHome()
|
|
|
|
|
|
|
|
|
|
statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
|
|
|
|
|
|
|
|
|
|
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
2020-01-01 11:57:13 +05:00
|
|
|
"Checking if LVE Kernel is loaded ..\n", 1)
|
2019-07-16 23:23:16 +05:00
|
|
|
|
2020-01-01 11:57:13 +05:00
|
|
|
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
|
2019-07-16 23:23:16 +05:00
|
|
|
|
2020-01-01 11:57:13 +05:00
|
|
|
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
|
|
|
|
"CloudLinux Kernel detected..\n", 1)
|
2019-07-16 23:23:16 +05:00
|
|
|
|
2020-01-01 11:57:13 +05:00
|
|
|
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'
|
2019-07-16 23:23:16 +05:00
|
|
|
ServerStatusUtil.executioner(command, statusFile)
|
|
|
|
|
|
2020-01-01 11:57:13 +05:00
|
|
|
command = 'yum reinstall -y lvemanager lve-utils cagefs alt-python27-cllib'
|
2019-07-16 23:23:16 +05:00
|
|
|
ServerStatusUtil.executioner(command, statusFile)
|
|
|
|
|
|
2020-01-01 11:57:13 +05:00
|
|
|
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
|
|
|
|
"Important components reinstalled..\n", 1)
|
|
|
|
|
|
|
|
|
|
activatedPath = '/home/cyberpanel/cloudlinux'
|
|
|
|
|
|
|
|
|
|
writeToFile = open(activatedPath, 'a')
|
|
|
|
|
writeToFile.write('CLInstalled')
|
|
|
|
|
writeToFile.close()
|
|
|
|
|
|
2019-07-16 23:23:16 +05:00
|
|
|
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
|
|
|
|
"Packages successfully installed.[200]\n", 1)
|
|
|
|
|
|
2019-12-10 15:09:10 +05:00
|
|
|
except BaseException as msg:
|
2019-07-16 23:23:16 +05:00
|
|
|
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='CyberPanel CageFS Manager')
|
|
|
|
|
parser.add_argument('--function', help='Function')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
args = vars(parser.parse_args())
|
|
|
|
|
|
|
|
|
|
if args["function"] == "submitCageFSInstall":
|
|
|
|
|
CageFS.submitCageFSInstall()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|
|
|
|
|
|