certral execution: final phase

This commit is contained in:
usmannasir
2019-04-15 15:54:23 +05:00
parent 04e07905f2
commit 8245398006
25 changed files with 728 additions and 175 deletions

View File

@@ -227,8 +227,11 @@ def deleteWebsite(request):
website = Websites.objects.get(domain=data['websiteName']) website = Websites.objects.get(domain=data['websiteName'])
websiteOwner = website.admin websiteOwner = website.admin
try:
if admin.websites_set.all().count() == 0: if admin.websites_set.all().count() == 0:
websiteOwner.delete() websiteOwner.delete()
except:
pass
## Deleting master domain ## Deleting master domain

View File

@@ -25,7 +25,6 @@ import requests
from plogical.processUtilities import ProcessUtilities from plogical.processUtilities import ProcessUtilities
from serverStatus.serverStatusUtil import ServerStatusUtil from serverStatus.serverStatusUtil import ServerStatusUtil
import threading as multi import threading as multi
from plogical.mailUtilities import mailUtilities
# Use default socket to connect # Use default socket to connect

View File

@@ -18,18 +18,6 @@ class DockerInstall:
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"Starting Docker Installation..\n", 1) "Starting Docker Installation..\n", 1)
command = "sudo adduser docker"
ServerStatusUtil.executioner(command, statusFile)
command = 'sudo groupadd docker'
ServerStatusUtil.executioner(command, statusFile)
command = 'sudo usermod -aG docker docker'
ServerStatusUtil.executioner(command, statusFile)
command = 'sudo usermod -aG docker cyberpanel'
ServerStatusUtil.executioner(command, statusFile)
if ProcessUtilities.decideDistro() == ProcessUtilities.centos: if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
command = 'sudo yum install -y docker' command = 'sudo yum install -y docker'
else: else:
@@ -51,9 +39,6 @@ class DockerInstall:
time.sleep(2) time.sleep(2)
command = 'sudo systemctl restart gunicorn.socket'
ProcessUtilities.executioner(command)
except BaseException, msg: except BaseException, msg:
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1) logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)

View File

@@ -15,8 +15,6 @@ from math import ceil
from postfixSenderPolicy.client import cacheClient from postfixSenderPolicy.client import cacheClient
import thread import thread
from plogical.mailUtilities import mailUtilities from plogical.mailUtilities import mailUtilities
import subprocess
import shlex
from plogical.virtualHostUtilities import virtualHostUtilities from plogical.virtualHostUtilities import virtualHostUtilities
from random import randint from random import randint
from plogical.acl import ACLManager from plogical.acl import ACLManager
@@ -785,7 +783,11 @@ def installSpamAssassin(request):
else: else:
return ACLManager.loadErrorJson() return ACLManager.loadErrorJson()
try: try:
thread.start_new_thread(mailUtilities.installSpamAssassin, ('Install','SpamAssassin'))
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
execPath = execPath + " installSpamAssassin"
ProcessUtilities.popenExecutioner(execPath)
final_json = json.dumps({'status': 1, 'error_message': "None"}) final_json = json.dumps({'status': 1, 'error_message': "None"})
return HttpResponse(final_json) return HttpResponse(final_json)
except BaseException,msg: except BaseException,msg:

View File

@@ -39,7 +39,8 @@ class FileManager:
if not self.data['completeStartingPath'].find(self.data['home']) > -1: if not self.data['completeStartingPath'].find(self.data['home']) > -1:
return self.ajaxPre(0, 'Not allowed to browse this path, going back home!') return self.ajaxPre(0, 'Not allowed to browse this path, going back home!')
command = "sudo ls -la --group-directories-first " + self.returnPathEnclosed(self.data['completeStartingPath']) command = "sudo ls -la --group-directories-first " + self.returnPathEnclosed(
self.data['completeStartingPath'])
output = ProcessUtilities.outputExecutioner(command).splitlines() output = ProcessUtilities.outputExecutioner(command).splitlines()
counter = 0 counter = 0
@@ -49,16 +50,22 @@ class FileManager:
currentFile = filter(lambda a: a != '', currentFile) currentFile = filter(lambda a: a != '', currentFile)
if currentFile[-1] == '.' or currentFile[-1] == '..' or currentFile[0] == 'total': if currentFile[-1] == '.' or currentFile[-1] == '..' or currentFile[0] == 'total':
continue continue
if len(currentFile) > 9:
fileName = currentFile[8:]
currentFile[-1] = " ".join(fileName)
dirCheck = 0 dirCheck = 0
if currentFile[0][0] == 'd': if currentFile[0][0] == 'd':
dirCheck = 1 dirCheck = 1
size = str(int(int(currentFile[4]) / float(1024))) size = str(int(int(currentFile[4]) / float(1024)))
lastModified = currentFile[5] + ' ' + currentFile[6] + ' ' + currentFile[7] lastModified = currentFile[5] + ' ' + currentFile[6] + ' ' + currentFile[7]
finalData[str(counter)] = [currentFile[-1], currentFile[-1], lastModified, size, currentFile[0], dirCheck] finalData[str(counter)] = [currentFile[-1], currentFile[-1], lastModified, size, currentFile[0],
dirCheck]
counter = counter + 1 counter = counter + 1
except: except BaseException, msg:
continue logging.writeToFile(str(msg))
json_data = json.dumps(finalData) json_data = json.dumps(finalData)
return HttpResponse(json_data) return HttpResponse(json_data)
@@ -71,7 +78,8 @@ class FileManager:
finalData = {} finalData = {}
finalData['status'] = 1 finalData['status'] = 1
command = "sudo ls -la --group-directories-first " + self.returnPathEnclosed(self.data['completeStartingPath']) command = "sudo ls -la --group-directories-first " + self.returnPathEnclosed(
self.data['completeStartingPath'])
output = ProcessUtilities.outputExecutioner(command).splitlines() output = ProcessUtilities.outputExecutioner(command).splitlines()
counter = 0 counter = 0
@@ -83,11 +91,16 @@ class FileManager:
if currentFile[-1] == '.' or currentFile[-1] == '..' or currentFile[0] == 'total': if currentFile[-1] == '.' or currentFile[-1] == '..' or currentFile[0] == 'total':
continue continue
if len(currentFile) > 9:
fileName = currentFile[8:]
currentFile[-1] = " ".join(fileName)
dirCheck = False dirCheck = False
if currentFile[0][0] == 'd': if currentFile[0][0] == 'd':
dirCheck = True dirCheck = True
finalData[str(counter)] = [currentFile[-1], self.data['completeStartingPath'] + '/' + currentFile[-1], dirCheck] finalData[str(counter)] = [currentFile[-1],
self.data['completeStartingPath'] + '/' + currentFile[-1], dirCheck]
counter = counter + 1 counter = counter + 1
except: except:
continue continue
@@ -106,10 +119,11 @@ class FileManager:
if self.data['fileName'].find('..') > -1: if self.data['fileName'].find('..') > -1:
return self.ajaxPre(0, 'Not allowed to move in this path, please choose location inside home!') return self.ajaxPre(0, 'Not allowed to move in this path, please choose location inside home!')
command = "sudo touch " + self.returnPathEnclosed(self.data['fileName']) command = "sudo touch " + self.returnPathEnclosed(self.data['fileName'])
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
self.changeOwner(self.data['fileName']) self.changeOwner(self.returnPathEnclosed(self.data['fileName']))
json_data = json.dumps(finalData) json_data = json.dumps(finalData)
return HttpResponse(json_data) return HttpResponse(json_data)
@@ -125,7 +139,7 @@ class FileManager:
command = "sudo mkdir " + self.returnPathEnclosed(self.data['folderName']) command = "sudo mkdir " + self.returnPathEnclosed(self.data['folderName'])
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
self.changeOwner(self.data['folderName']) self.changeOwner(self.returnPathEnclosed(self.data['folderName']))
json_data = json.dumps(finalData) json_data = json.dumps(finalData)
return HttpResponse(json_data) return HttpResponse(json_data)

View File

@@ -246,7 +246,7 @@ class preFlightsChecks:
# self.stdOut("Error in fixing sudoers file: " + str(err), 1, 1, os.EX_OSERR) # self.stdOut("Error in fixing sudoers file: " + str(err), 1, 1, os.EX_OSERR)
self.stdOut("Add Cyberpanel user") self.stdOut("Add Cyberpanel user")
command = "adduser --disabled-login cyberpanel" command = 'adduser --disabled-login --gecos "" cyberpanel'
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd) res = subprocess.call(cmd)
if res != 0 and res != 9: if res != 0 and res != 9:
@@ -288,6 +288,36 @@ class preFlightsChecks:
############################### ###############################
### Docker User/group
if self.distro == ubuntu:
command = 'adduser --disabled-login --gecos "" docker'
else:
command = "adduser docker"
preFlightsChecks.call(command, self.distro, '[setup_account_cyberpanel]',
'add user cyberpanel',
1, 0, os.EX_OSERR)
command = 'groupadd docker'
preFlightsChecks.call(command, self.distro, '[setup_account_cyberpanel]',
'add user cyberpanel',
1, 0, os.EX_OSERR)
command = 'usermod -aG docker docker'
preFlightsChecks.call(command, self.distro, '[setup_account_cyberpanel]',
'add user cyberpanel',
1, 0, os.EX_OSERR)
command = 'usermod -aG docker cyberpanel'
preFlightsChecks.call(command, self.distro, '[setup_account_cyberpanel]',
'add user cyberpanel',
1, 0, os.EX_OSERR)
###
command = "mkdir -p /etc/letsencrypt/live/" command = "mkdir -p /etc/letsencrypt/live/"
preFlightsChecks.call(command, self.distro, '[setup_account_cyberpanel]', preFlightsChecks.call(command, self.distro, '[setup_account_cyberpanel]',
'add user cyberpanel', 'add user cyberpanel',
@@ -884,8 +914,8 @@ class preFlightsChecks:
os.chdir(self.path) os.chdir(self.path)
#command = "wget http://cyberpanel.sh/CyberPanel.1.8.1.tar.gz" command = "wget http://cyberpanel.sh/CyberPanel.1.8.2.tar.gz"
command = "wget http://cyberpanel.sh/CyberPanelTemp.tar.gz" #command = "wget http://cyberpanel.sh/CyberPanelTemp.tar.gz"
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]', preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'CyberPanel Download', 'CyberPanel Download',
1, 1, os.EX_OSERR) 1, 1, os.EX_OSERR)
@@ -893,8 +923,8 @@ class preFlightsChecks:
## ##
count = 0 count = 0
#command = "tar zxf CyberPanel.1.8.1.tar.gz" command = "tar zxf CyberPanel.1.8.2.tar.gz"
command = "tar zxf CyberPanelTemp.tar.gz" #command = "tar zxf CyberPanelTemp.tar.gz"
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]', preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'Extract CyberPanel',1, 1, os.EX_OSERR) 'Extract CyberPanel',1, 1, os.EX_OSERR)
@@ -976,9 +1006,27 @@ class preFlightsChecks:
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]', preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'Move static content', 1, 1, os.EX_OSERR) 'Move static content', 1, 1, os.EX_OSERR)
try:
path = "/usr/local/CyberCP/version.txt"
writeToFile = open(path, 'w')
writeToFile.writelines('1.8\n')
writeToFile.writelines('2')
writeToFile.close()
except:
pass
def fixCyberPanelPermissions(self): def fixCyberPanelPermissions(self):
###### fix Core CyberPanel permissions ###### fix Core CyberPanel permissions
command = "usermod -G lscpd,lsadm,nobody lscpd"
preFlightsChecks.call(command, self.distro, '[fixCyberPanelPermissions]',
'add lscpd to important groups', 0, 0, os.EX_OSERR)
command = "usermod -G lscpd,lsadm,nogroup lscpd"
preFlightsChecks.call(command, self.distro, '[fixCyberPanelPermissions]',
'add lscpd to important groups', 0, 0, os.EX_OSERR)
command = "find /usr/local/CyberCP -type d -exec chmod 0755 {} \;" command = "find /usr/local/CyberCP -type d -exec chmod 0755 {} \;"
preFlightsChecks.call(command, self.distro, '[fixCyberPanelPermissions]', preFlightsChecks.call(command, self.distro, '[fixCyberPanelPermissions]',
'fix permissions /usr/local/CyberCP', 1, 0, os.EX_OSERR) 'fix permissions /usr/local/CyberCP', 1, 0, os.EX_OSERR)
@@ -1015,9 +1063,9 @@ class preFlightsChecks:
preFlightsChecks.call(command, self.distro, '[fixCyberPanelPermissions]', preFlightsChecks.call(command, self.distro, '[fixCyberPanelPermissions]',
'fix permissions /usr/local/CyberCP', 1, 0, os.EX_OSERR) 'fix permissions /usr/local/CyberCP', 1, 0, os.EX_OSERR)
command = "chown -R lscpd:lscpd /usr/local/CyberCP/public/rainloop/data" command = "chown -R lscpd:lscpd /usr/local/CyberCP/public/phpmyadmin/tmp"
preFlightsChecks.call(command, self.distro, '[fixCyberPanelPermissions]', preFlightsChecks.call(command, self.distro, '[fixCyberPanelPermissions]',
'fix permissions /usr/local/CyberCP', 1, 0, os.EX_OSERR) 'fix permissions /usr/local/CyberCP/public/phpmyadmin/tmp', 1, 0, os.EX_OSERR)
## change owner ## change owner
@@ -1025,6 +1073,25 @@ class preFlightsChecks:
preFlightsChecks.call(command, self.distro, '[fixCyberPanelPermissions]', preFlightsChecks.call(command, self.distro, '[fixCyberPanelPermissions]',
'change owner /usr/local/CyberCP', 1, 0, os.EX_OSERR) 'change owner /usr/local/CyberCP', 1, 0, os.EX_OSERR)
command = "chown -R lscpd:lscpd /usr/local/lscp/cyberpanel/rainloop/data"
preFlightsChecks.call(command, self.distro, '[fixCyberPanelPermissions]',
'change owner /usr/local/CyberCP', 1, 0, os.EX_OSERR)
command = "chmod 700 /usr/local/CyberCP/cli/cyberPanel.py"
preFlightsChecks.call(command, self.distro, '[fixCyberPanelPermissions]',
'Change permissions for CLI.', 1, 0, os.EX_OSERR)
command = "chmod 700 /usr/local/CyberCP/plogical/upgradeCritical.py"
preFlightsChecks.call(command, self.distro, '[fixCyberPanelPermissions]',
'Change permissions for upgrade.', 1, 0, os.EX_OSERR)
command = "chmod 700 /usr/local/CyberCP/postfixSenderPolicy/client.py"
preFlightsChecks.call(command, self.distro, '[fixCyberPanelPermissions]',
'Change permissions for client.', 1, 0, os.EX_OSERR)
command = "chmod 600 /usr/local/CyberCP/CyberCP/settings.py"
preFlightsChecks.call(command, self.distro, '[fixCyberPanelPermissions]',
'Change permissions for client.', 1, 0, os.EX_OSERR)
def install_unzip(self): def install_unzip(self):
self.stdOut("Install unzip") self.stdOut("Install unzip")
@@ -2055,10 +2122,12 @@ class preFlightsChecks:
try: try:
####### #######
if not os.path.exists("/usr/local/CyberCP/public"): if not os.path.exists("/usr/local/CyberCP/public"):
os.mkdir("/usr/local/CyberCP/public") os.mkdir("/usr/local/CyberCP/public")
if os.path.exists("/usr/local/CyberCP/public/rainloop"):
return 0
os.chdir("/usr/local/CyberCP/public") os.chdir("/usr/local/CyberCP/public")
count = 1 count = 1
@@ -2156,6 +2225,27 @@ class preFlightsChecks:
break break
###### ######
command = "mkdir -p /usr/local/lscp/cyberpanel/rainloop/data"
preFlightsChecks.call(command, self.distro, '[downoad_and_install_rainloop]',
'rainlooop data folder',
1, 0, os.EX_OSERR)
path = "/usr/local/CyberCP/public/rainloop/rainloop/v/1.12.1/include.php"
data = open(path, 'r').readlines()
writeToFile = open(path, 'w')
for items in data:
if items.find("$sCustomDataPath = '';") > -1:
writeToFile.writelines(
" $sCustomDataPath = '/usr/local/lscp/cyberpanel/rainloop/data';\n")
else:
writeToFile.writelines(items)
writeToFile.close()
except OSError, msg: except OSError, msg:
logging.InstallLog.writeToFile(str(msg) + " [downoad_and_install_rainloop]") logging.InstallLog.writeToFile(str(msg) + " [downoad_and_install_rainloop]")
@@ -2323,7 +2413,7 @@ class preFlightsChecks:
1, 1, os.EX_OSERR) 1, 1, os.EX_OSERR)
command = 'openssl req -newkey rsa:1024 -new -nodes -x509 -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout /usr/local/lscp/key.pem -out /usr/local/lscp/cert.pem' command = 'openssl req -newkey rsa:1024 -new -nodes -x509 -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout /usr/local/lscp/conf/key.pem -out /usr/local/lscp/conf/cert.pem'
preFlightsChecks.call(command, self.distro, '[installLSCPD]', preFlightsChecks.call(command, self.distro, '[installLSCPD]',
'Install LSCPD', 'Install LSCPD',
1, 1, os.EX_OSERR) 1, 1, os.EX_OSERR)
@@ -2359,11 +2449,16 @@ class preFlightsChecks:
preFlightsChecks.call(command, self.distro, '[installLSCPD]', preFlightsChecks.call(command, self.distro, '[installLSCPD]',
'Install LSCPD', 'Install LSCPD',
1, 0, os.EX_OSERR) 1, 0, os.EX_OSERR)
try:
os.mkdir('/usr/local/lscp/cyberpanel') os.mkdir('/usr/local/lscp/cyberpanel')
except:
pass
try:
os.mkdir('/usr/local/lscp/cyberpanel/logs') os.mkdir('/usr/local/lscp/cyberpanel/logs')
except:
pass
self.setupComodoRules() #self.setupComodoRules()
self.setupPort() self.setupPort()
self.setupPythonWSGI() self.setupPythonWSGI()
@@ -2405,6 +2500,7 @@ class preFlightsChecks:
modsecConfig = """ modsecConfig = """
module mod_security { module mod_security {
ls_enabled 0
modsecurity on modsecurity on
modsecurity_rules ` modsecurity_rules `
SecDebugLogLevel 0 SecDebugLogLevel 0
@@ -3509,8 +3605,9 @@ def main():
checks.setup_gunicorn() checks.setup_gunicorn()
import installCyberPanel import installCyberPanel
if ent == 0: if ent == 0:
installCyberPanel.Main(cwd, mysql, distro, ent, port) installCyberPanel.Main(cwd, mysql, distro, ent, None, port)
else: else:
installCyberPanel.Main(cwd, mysql, distro, ent, serial, port) installCyberPanel.Main(cwd, mysql, distro, ent, serial, port)

View File

@@ -686,7 +686,7 @@ class InstallCyberPanel:
logging.InstallLog.writeToFile(str(msg) + " [startPowerDNS]") logging.InstallLog.writeToFile(str(msg) + " [startPowerDNS]")
def Main(cwd, mysql, distro, ent, serial = None): def Main(cwd, mysql, distro, ent, serial = None, port = "8090"):
InstallCyberPanel.mysqlPassword = randomPassword.generate_pass() InstallCyberPanel.mysqlPassword = randomPassword.generate_pass()
InstallCyberPanel.mysql_Root_password = randomPassword.generate_pass() InstallCyberPanel.mysql_Root_password = randomPassword.generate_pass()
@@ -706,7 +706,7 @@ def Main(cwd, mysql, distro, ent, serial = None):
else: else:
InstallCyberPanel.mysqlPassword = InstallCyberPanel.mysql_Root_password InstallCyberPanel.mysqlPassword = InstallCyberPanel.mysql_Root_password
installer = InstallCyberPanel("/usr/local/lsws/",cwd, distro, ent, serial) installer = InstallCyberPanel("/usr/local/lsws/",cwd, distro, ent, serial, port)
installer.installLiteSpeed() installer.installLiteSpeed()
if ent == 0: if ent == 0:

Binary file not shown.

View File

@@ -202,7 +202,7 @@ def loadLoginPage(request):
firstName="Cyber",lastName="Panel", acl=acl, token=token) firstName="Cyber",lastName="Panel", acl=acl, token=token)
admin.save() admin.save()
vers = version(currentVersion="1.8", build=1) vers = version(currentVersion="1.8", build=2)
vers.save() vers.save()
package = Package(admin=admin, packageName="Default", diskSpace=1000, package = Package(admin=admin, packageName="Default", diskSpace=1000,

View File

@@ -1319,10 +1319,19 @@ def getRequestStatus(request):
checkCommand = 'dpkg --list' checkCommand = 'dpkg --list'
checkCommand = shlex.split(checkCommand) checkCommand = shlex.split(checkCommand)
requestStatus = unicode(open(phpUtilities.installLogPath, "r").read()) command = "sudo cat " + phpUtilities.installLogPath
requestStatus = ProcessUtilities.outputExecutioner(command)
if requestStatus.find('No such') > -1:
requestStatus = ""
requestStatusSize = len(requestStatus) requestStatusSize = len(requestStatus)
if requestStatus.find("PHP Extension Installed") > -1: if requestStatus.find("PHP Extension Installed") > -1:
command = "sudo rm -f " + phpUtilities.installLogPath
ProcessUtilities.executioner(command)
if ProcessUtilities.outputExecutioner(checkCommand).find(extensionName) > -1: if ProcessUtilities.outputExecutioner(checkCommand).find(extensionName) > -1:
ext = installedPackages.objects.get(extensionName=extensionName) ext = installedPackages.objects.get(extensionName=extensionName)
ext.status = 1 ext.status = 1
@@ -1339,10 +1348,14 @@ def getRequestStatus(request):
return HttpResponse(final_json) return HttpResponse(final_json)
elif requestStatus.find("Can not be installed") > -1: elif requestStatus.find("Can not be installed") > -1:
command = "sudo rm -f " + phpUtilities.installLogPath
ProcessUtilities.executioner(command)
if ProcessUtilities.outputExecutioner(checkCommand).find(extensionName) > -1: if ProcessUtilities.outputExecutioner(checkCommand).find(extensionName) > -1:
ext = installedPackages.objects.get(extensionName=extensionName) ext = installedPackages.objects.get(extensionName=extensionName)
ext.status = 1 ext.status = 1
ext.save() ext.save()
else: else:
ext = installedPackages.objects.get(extensionName=extensionName) ext = installedPackages.objects.get(extensionName=extensionName)
ext.status = 0 ext.status = 0
@@ -1355,10 +1368,14 @@ def getRequestStatus(request):
return HttpResponse(final_json) return HttpResponse(final_json)
elif requestStatus.find("Can not un-install Extension") > -1: elif requestStatus.find("Can not un-install Extension") > -1:
command = "sudo rm -f " + phpUtilities.installLogPath
ProcessUtilities.executioner(command)
if ProcessUtilities.outputExecutioner(checkCommand).find(extensionName) > -1: if ProcessUtilities.outputExecutioner(checkCommand).find(extensionName) > -1:
ext = installedPackages.objects.get(extensionName=extensionName) ext = installedPackages.objects.get(extensionName=extensionName)
ext.status = 1 ext.status = 1
ext.save() ext.save()
else: else:
ext = installedPackages.objects.get(extensionName=extensionName) ext = installedPackages.objects.get(extensionName=extensionName)
ext.status = 0 ext.status = 0
@@ -1371,6 +1388,9 @@ def getRequestStatus(request):
return HttpResponse(final_json) return HttpResponse(final_json)
elif requestStatus.find("PHP Extension Removed") > -1: elif requestStatus.find("PHP Extension Removed") > -1:
command = "sudo rm -f " + phpUtilities.installLogPath
ProcessUtilities.executioner(command)
ext = installedPackages.objects.get(extensionName=extensionName) ext = installedPackages.objects.get(extensionName=extensionName)
ext.status = 0 ext.status = 0
ext.save() ext.save()

View File

@@ -8,7 +8,6 @@ from loginSystem.views import loadLoginPage
import os import os
import json import json
from plogical.mailUtilities import mailUtilities from plogical.mailUtilities import mailUtilities
import subprocess, shlex
from plogical.acl import ACLManager from plogical.acl import ACLManager
from models import PDNSStatus from models import PDNSStatus
from .serviceManager import ServiceManager from .serviceManager import ServiceManager

View File

@@ -31,7 +31,7 @@ def main():
firstName="Cyber", lastName="Panel", acl=acl, token=token) firstName="Cyber", lastName="Panel", acl=acl, token=token)
admin.save() admin.save()
vers = version(currentVersion="1.8", build=1) vers = version(currentVersion="1.8", build=2)
vers.save() vers.save()
package = Package(admin=admin, packageName="Default", diskSpace=1000, package = Package(admin=admin, packageName="Default", diskSpace=1000,

View File

@@ -507,9 +507,9 @@ class ApplicationInstaller(multi.Thread):
try: try:
command = 'sudo git --help' command = 'sudo git --help'
res = ProcessUtilities.executioner(command) output = ProcessUtilities.outputExecutioner(command)
if res == 0: if output.find('command not found') > -1:
statusFile = open(tempStatusPath, 'w') statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Installing GIT..,0') statusFile.writelines('Installing GIT..,0')
statusFile.close() statusFile.close()
@@ -721,7 +721,7 @@ class ApplicationInstaller(multi.Thread):
if not os.path.exists("staging.zip"): if not os.path.exists("staging.zip"):
command = 'wget --no-check-certificate https://github.com/joomla/joomla-cms/archive/staging.zip -P ' + finalPath command = 'wget --no-check-certificate https://github.com/joomla/joomla-cms/archive/staging.zip -P ' + finalPath
ProcessUtilities.executioner(command) ProcessUtilities.normalExecutioner(command)
else: else:
statusFile = open(tempStatusPath, 'w') statusFile = open(tempStatusPath, 'w')
statusFile.writelines("File already exists." + " [404]") statusFile.writelines("File already exists." + " [404]")
@@ -729,12 +729,12 @@ class ApplicationInstaller(multi.Thread):
return 0 return 0
command = 'unzip ' + finalPath + 'staging.zip -d ' + finalPath command = 'unzip ' + finalPath + 'staging.zip -d ' + finalPath
ProcessUtilities.executioner(command) ProcessUtilities.normalExecutioner(command)
os.remove(finalPath + 'staging.zip') os.remove(finalPath + 'staging.zip')
command = 'cp -r ' + finalPath + 'joomla-cms-staging/. ' + finalPath command = 'cp -r ' + finalPath + 'joomla-cms-staging/. ' + finalPath
ProcessUtilities.executioner(command) ProcessUtilities.normalExecutioner(command)
shutil.rmtree(finalPath + "joomla-cms-staging") shutil.rmtree(finalPath + "joomla-cms-staging")
os.rename(finalPath + "installation/configuration.php-dist", finalPath + "configuration.php") os.rename(finalPath + "installation/configuration.php-dist", finalPath + "configuration.php")
@@ -820,7 +820,7 @@ class ApplicationInstaller(multi.Thread):
shutil.rmtree(finalPath + "installation") shutil.rmtree(finalPath + "installation")
command = "sudo chown -R " + virtualHostUser + ":" + virtualHostUser + " " + finalPath command = "sudo chown -R " + virtualHostUser + ":" + virtualHostUser + " " + finalPath
ProcessUtilities.executioner(command) ProcessUtilities.normalExecutioner(command)
vhost.addRewriteRules(domainName) vhost.addRewriteRules(domainName)

View File

@@ -161,7 +161,25 @@ class installUtilities:
else: else:
command = "sudo /usr/local/lsws/bin/lswsctrl restart" command = "sudo /usr/local/lsws/bin/lswsctrl restart"
ProcessUtilities.executioner(command) return ProcessUtilities.executioner(command)
except OSError, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]")
return 0
except ValueError, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]")
return 0
@staticmethod
def stopLiteSpeedSocket():
try:
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
command = "sudo systemctl stop lsws"
else:
command = "sudo /usr/local/lsws/bin/lswsctrl stop"
return ProcessUtilities.executioner(command)
except OSError, msg: except OSError, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]")
@@ -169,7 +187,6 @@ class installUtilities:
except ValueError, msg: except ValueError, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]")
return 0 return 0
return 1
@staticmethod @staticmethod

View File

@@ -68,15 +68,15 @@ class mailUtilities:
path = "/usr/local/CyberCP/install/rainloop/cyberpanel.net.ini" path = "/usr/local/CyberCP/install/rainloop/cyberpanel.net.ini"
if not os.path.exists("/usr/local/CyberCP/public/rainloop/data/_data_/_default_/domains/"): if not os.path.exists("/usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/domains/"):
os.makedirs("/usr/local/CyberCP/public/rainloop/data/_data_/_default_/domains/") os.makedirs("/usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/domains/")
finalPath = "/usr/local/CyberCP/public/rainloop/data/_data_/_default_/domains/" + domain + ".ini" finalPath = "/usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/domains/" + domain + ".ini"
if not os.path.exists(finalPath): if not os.path.exists(finalPath):
shutil.copy(path, finalPath) shutil.copy(path, finalPath)
command = 'chown -R lscpd:lscpd /usr/local/CyberCP/public/rainloop/data/' command = 'chown -R lscpd:lscpd /usr/local/lscp/cyberpanel/rainloop/data/'
ProcessUtilities.normalExecutioner(command) ProcessUtilities.normalExecutioner(command)
## After effects ends ## After effects ends
@@ -360,8 +360,6 @@ milter_default_action = accept
def installSpamAssassin(install, SpamAssassin): def installSpamAssassin(install, SpamAssassin):
try: try:
mailUtilities.checkHome()
if ProcessUtilities.decideDistro() == ProcessUtilities.centos: if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
command = 'sudo yum install spamassassin -y' command = 'sudo yum install spamassassin -y'
else: else:
@@ -397,9 +395,9 @@ milter_default_action = accept
path = "/etc/mail/spamassassin/local.cf" path = "/etc/mail/spamassassin/local.cf"
command = "sudo cat " + path command = "sudo cat " + path
res = subprocess.call(shlex.split(command)) output = ProcessUtilities.outputExecutioner(command)
if res == 1: if output.find('No such') > -1:
return 0 return 0
else: else:
return 1 return 1
@@ -606,6 +604,8 @@ def main():
mailUtilities.saveSpamAssassinConfigs(args.tempConfigPath) mailUtilities.saveSpamAssassinConfigs(args.tempConfigPath)
elif args.function == 'savePolicyServerStatus': elif args.function == 'savePolicyServerStatus':
mailUtilities.savePolicyServerStatus(args.install) mailUtilities.savePolicyServerStatus(args.install)
elif args.function == 'installSpamAssassin':
mailUtilities.installSpamAssassin("install", "SpamAssassin")
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@@ -87,7 +87,6 @@ class phpUtilities:
except BaseException, msg: except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [initiateInstall]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [initiateInstall]")
@staticmethod @staticmethod
def initiateRemoval(extension): def initiateRemoval(extension):
try: try:

View File

@@ -4,6 +4,7 @@ import shlex
import os import os
import socket import socket
import threading as multi import threading as multi
import time
class ProcessUtilities(multi.Thread): class ProcessUtilities(multi.Thread):
litespeedProcess = "litespeed" litespeedProcess = "litespeed"
@@ -144,18 +145,25 @@ class ProcessUtilities(multi.Thread):
@staticmethod @staticmethod
def setupUDSConnection(): def setupUDSConnection():
count = 0
while 1:
try: try:
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(ProcessUtilities.server_address) sock.connect(ProcessUtilities.server_address)
return [sock, "None"] return [sock, "None"]
except BaseException, msg: except BaseException, msg:
logging.writeToFile(str(msg) + ". [setupUDSConnection:138]") if count == 3:
logging.writeToFile("Failed to connect to LSCPD socket, run 'systemctl restart lscpd' on command line to fix this issue.")
return [-1, str(msg)] return [-1, str(msg)]
else:
count = count + 1
logging.writeToFile("Failed to connect to LSCPD UDS, error message:" + str(msg) + ". Attempt " + str(count) + ", we will attempt again in 2 seconds. [setupUDSConnection:138]")
time.sleep(2)
@staticmethod @staticmethod
def sendCommand(command): def sendCommand(command):
try: try:
logging.writeToFile(command)
ret = ProcessUtilities.setupUDSConnection() ret = ProcessUtilities.setupUDSConnection()

View File

@@ -14,6 +14,8 @@ import time
from baseTemplate.models import version from baseTemplate.models import version
import MySQLdb as mysql import MySQLdb as mysql
from CyberCP import settings from CyberCP import settings
import random
import string
class Upgrade: class Upgrade:
logPath = "/usr/local/lscp/logs/upgradeLog" logPath = "/usr/local/lscp/logs/upgradeLog"
@@ -49,6 +51,316 @@ class Upgrade:
except: except:
return 0 return 0
@staticmethod
def mountTemp():
try:
if os.path.exists("/usr/.tempdisk"):
return 0
command = "dd if=/dev/zero of=/usr/.tempdisk bs=100M count=15"
Upgrade.executioner(command, 'mountTemp', 0)
command = "mkfs.ext4 -F /usr/.tempdisk"
Upgrade.executioner(command, 'mountTemp', 0)
command = "mkdir -p /usr/.tmpbak/"
Upgrade.executioner(command, 'mountTemp', 0)
command = "cp -pr /tmp/* /usr/.tmpbak/"
subprocess.call(command, shell=True)
command = "mount -o loop,rw,nodev,nosuid,noexec,nofail /usr/.tempdisk /tmp"
Upgrade.executioner(command, 'mountTemp', 0)
command = "chmod 1777 /tmp"
Upgrade.executioner(command, 'mountTemp', 0)
command = "cp -pr /usr/.tmpbak/* /tmp/"
subprocess.call(command, shell=True)
command = "rm -rf /usr/.tmpbak"
Upgrade.executioner(command, 'mountTemp', 0)
command = "mount --bind /tmp /var/tmp"
Upgrade.executioner(command, 'mountTemp', 0)
tmp = "/usr/.tempdisk /tmp ext4 loop,rw,noexec,nosuid,nodev,nofail 0 0\n"
varTmp = "/tmp /var/tmp none bind 0 0\n"
fstab = "/etc/fstab"
writeToFile = open(fstab, "a")
writeToFile.writelines(tmp)
writeToFile.writelines(varTmp)
writeToFile.close()
except BaseException, msg:
Upgrade.stdOut(str(msg) + " [mountTemp]", 0)
@staticmethod
def setupPythonWSGI():
try:
cwd = os.getcwd()
command = "wget http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.4.tgz"
Upgrade.executioner(command, 0)
command = "tar xf wsgi-lsapi-1.4.tgz"
Upgrade.executioner(command, 0)
os.chdir("wsgi-lsapi-1.4")
command = "python ./configure.py"
Upgrade.executioner(command, 0)
command = "make"
Upgrade.executioner(command, 0)
command = "cp lswsgi /usr/local/CyberCP/bin/"
Upgrade.executioner(command, 0)
os.chdir(cwd)
except:
return 0
@staticmethod
def dockerUsers():
### Docker User/group
command = "adduser docker"
Upgrade.executioner(command, 'adduser docker', 0)
command = 'groupadd docker'
Upgrade.executioner(command, 'adduser docker', 0)
command = 'usermod -aG docker docker'
Upgrade.executioner(command, 'adduser docker', 0)
command = 'usermod -aG docker cyberpanel'
Upgrade.executioner(command, 'adduser docker', 0)
###
@staticmethod
def fixSudoers():
try:
distroPath = '/etc/lsb-release'
if os.path.exists(distroPath):
fileName = '/etc/sudoers'
data = open(fileName, 'r').readlines()
writeDataToFile = open(fileName, 'w')
for line in data:
if line.find("%sudo ALL=(ALL:ALL)") > -1:
continue
else:
writeDataToFile.write(line)
writeDataToFile.close()
else:
try:
path = "/etc/sudoers"
data = open(path, 'r').readlines()
writeToFile = open(path, 'w')
for items in data:
if items.find("wheel") > -1 and items.find("ALL=(ALL)"):
continue
else:
writeToFile.writelines(items)
writeToFile.close()
except:
pass
command = "chsh -s /bin/false cyberpanel"
Upgrade.executioner(command, 0)
except IOError as err:
pass
@staticmethod
def download_install_phpmyadmin():
try:
cwd = os.getcwd()
if not os.path.exists("/usr/local/CyberCP/public"):
os.mkdir("/usr/local/CyberCP/public")
try:
shutil.rmtree("/usr/local/CyberCP/public/phpmyadmin")
except:
pass
os.chdir("/usr/local/CyberCP/public")
command = '/usr/local/lsws/lsphp70/bin/php /usr/bin/composer create-project phpmyadmin/phpmyadmin'
Upgrade.executioner(command, 0)
## Write secret phrase
rString = ''.join([random.choice(string.ascii_letters + string.digits) for n in xrange(32)])
data = open('phpmyadmin/config.sample.inc.php', 'r').readlines()
writeToFile = open('phpmyadmin/config.inc.php', 'w')
for items in data:
if items.find('blowfish_secret') > -1:
writeToFile.writelines(
"$cfg['blowfish_secret'] = '" + rString + "'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */\n")
else:
writeToFile.writelines(items)
writeToFile.writelines("$cfg['TempDir'] = '/usr/local/CyberCP/public/phpmyadmin/tmp';\n")
writeToFile.close()
os.mkdir('/usr/local/CyberCP/public/phpmyadmin/tmp')
os.chdir(cwd)
except BaseException, msg:
Upgrade.stdOut(str(msg) + " [download_install_phpmyadmin]", 0)
@staticmethod
def setupComposer():
command = "wget https://cyberpanel.sh/composer.sh"
Upgrade.executioner(command, 0)
command = "chmod +x composer.sh"
Upgrade.executioner(command, 0)
command = "./composer.sh"
Upgrade.executioner(command, 0)
@staticmethod
def downoad_and_install_raindloop():
try:
#######
if os.path.exists("/usr/local/CyberCP/public/rainloop"):
if os.path.exists("/usr/local/lscp/cyberpanel/rainloop/data"):
pass
else:
command = "mv /usr/local/CyberCP/public/rainloop/data /usr/local/lscp/cyberpanel/rainloop/data"
Upgrade.executioner(command, 0)
command = "chown -R lscpd:lscpd /usr/local/lscp/cyberpanel/rainloop/data"
Upgrade.executioner(command, 0)
path = "/usr/local/CyberCP/public/rainloop/rainloop/v/1.12.1/include.php"
data = open(path, 'r').readlines()
writeToFile = open(path, 'w')
for items in data:
if items.find("$sCustomDataPath = '';") > -1:
writeToFile.writelines(
" $sCustomDataPath = '/usr/local/lscp/cyberpanel/rainloop/data';\n")
else:
writeToFile.writelines(items)
writeToFile.close()
return 0
cwd = os.getcwd()
if not os.path.exists("/usr/local/CyberCP/public"):
os.mkdir("/usr/local/CyberCP/public")
os.chdir("/usr/local/CyberCP/public")
count = 1
while (1):
command = 'wget https://www.rainloop.net/repository/webmail/rainloop-community-latest.zip'
cmd = shlex.split(command)
res = subprocess.call(cmd)
if res != 0:
count = count + 1
if count == 3:
break
else:
break
#############
count = 0
while (1):
command = 'unzip rainloop-community-latest.zip -d /usr/local/CyberCP/public/rainloop'
cmd = shlex.split(command)
res = subprocess.call(cmd)
if res != 0:
count = count + 1
if count == 3:
break
else:
break
os.remove("rainloop-community-latest.zip")
#######
os.chdir("/usr/local/CyberCP/public/rainloop")
count = 0
while (1):
command = 'find . -type d -exec chmod 755 {} \;'
cmd = shlex.split(command)
res = subprocess.call(cmd)
if res != 0:
count = count + 1
if count == 3:
break
else:
break
#############
count = 0
while (1):
command = 'find . -type f -exec chmod 644 {} \;'
cmd = shlex.split(command)
res = subprocess.call(cmd)
if res != 0:
count = count + 1
if count == 3:
break
else:
break
######
path = "/usr/local/CyberCP/public/rainloop/rainloop/v/1.12.1/include.php"
data = open(path, 'r').readlines()
writeToFile = open(path, 'w')
for items in data:
if items.find("$sCustomDataPath = '';") > -1:
writeToFile.writelines(
" $sCustomDataPath = '/usr/local/lscp/cyberpanel/rainloop/data';\n")
else:
writeToFile.writelines(items)
os.chdir(cwd)
except BaseException, msg:
Upgrade.stdOut(str(msg) + " [downoad_and_install_raindloop]", 0)
return 1
@staticmethod @staticmethod
def downloadLink(): def downloadLink():
try: try:
@@ -57,6 +369,16 @@ class Upgrade:
data = json.loads(r.text) data = json.loads(r.text)
version_number = str(data['version']) version_number = str(data['version'])
version_build = str(data['build']) version_build = str(data['build'])
try:
path = "/usr/local/CyberCP/version.txt"
writeToFile = open(path, 'w')
writeToFile.writelines(version_number + '\n')
writeToFile.writelines(version_build)
writeToFile.close()
except:
pass
return (version_number + "." + version_build + ".tar.gz") return (version_number + "." + version_build + ".tar.gz")
except BaseException, msg: except BaseException, msg:
Upgrade.stdOut(str(msg) + ' [downloadLink]') Upgrade.stdOut(str(msg) + ' [downloadLink]')
@@ -98,9 +420,6 @@ class Upgrade:
command = "pip install --ignore-installed -r /usr/local/CyberCP/requirments.txt" command = "pip install --ignore-installed -r /usr/local/CyberCP/requirments.txt"
Upgrade.executioner(command, 'CyberPanel requirements', 1) Upgrade.executioner(command, 'CyberPanel requirements', 1)
command = "systemctl stop gunicorn.socket"
Upgrade.executioner(command, '', 0)
command = "virtualenv --system-site-packages /usr/local/CyberCP" command = "virtualenv --system-site-packages /usr/local/CyberCP"
Upgrade.executioner(command, 'Setting up VirtualEnv [Two]', 1) Upgrade.executioner(command, 'Setting up VirtualEnv [Two]', 1)
@@ -108,47 +427,6 @@ class Upgrade:
except OSError, msg: except OSError, msg:
Upgrade.stdOut(str(msg) + " [setupVirtualEnv]", 0) Upgrade.stdOut(str(msg) + " [setupVirtualEnv]", 0)
@staticmethod
def updateGunicornConf():
try:
path = '/etc/systemd/system/gunicorn.service'
cont = """[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
PIDFile=/run/gunicorn/pid
User=cyberpanel
Group=cyberpanel
RuntimeDirectory=gunicorn
WorkingDirectory=/usr/local/CyberCP
ExecStart=/usr/local/CyberCP/bin/gunicorn --pid /run/gunicorn/gucpid --timeout 2000 --workers 2 \
--bind 127.0.0.1:5003 CyberCP.wsgi
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target"""
writeToFile = open(path, 'w')
writeToFile.write(cont)
writeToFile.close()
##
command = 'systemctl daemon-reload'
Upgrade.executioner(command, 'daemon-reload', 0)
##
command = 'systemctl restart gunicorn.socket'
Upgrade.executioner(command, 'restart gunicorn.socket', 0)
except BaseException, msg:
Upgrade.stdOut(str(msg) + " [updateGunicornConf]")
@staticmethod @staticmethod
def fileManager(): def fileManager():
## Copy File manager files ## Copy File manager files
@@ -186,13 +464,16 @@ WantedBy=multi-user.target"""
@staticmethod @staticmethod
def staticContent(): def staticContent():
command = "rm -rf /usr/local/lscp/cyberpanel/static" command = "rm -rf /usr/local/CyberCP/public/static"
Upgrade.executioner(command, 'Remove old static content', 0) Upgrade.executioner(command, 'Remove old static content', 0)
## ##
command = "mv /usr/local/CyberCP/static /usr/local/lscp/cyberpanel" if not os.path.exists("/usr/local/CyberCP/public"):
Upgrade.executioner(command, 'Update new static content', 0) os.mkdir("/usr/local/CyberCP/public")
shutil.move("/usr/local/CyberCP/static", "/usr/local/CyberCP/public/")
@staticmethod @staticmethod
def upgradeVersion(): def upgradeVersion():
@@ -255,6 +536,13 @@ WantedBy=multi-user.target"""
cursor.execute('ALTER TABLE loginSystem_administrator ADD token varchar(500)') cursor.execute('ALTER TABLE loginSystem_administrator ADD token varchar(500)')
except: except:
pass pass
try:
cursor.execute('ALTER TABLE loginSystem_administrator ADD api integer')
except:
pass
try: try:
cursor.execute('ALTER TABLE loginSystem_administrator ADD acl_id integer') cursor.execute('ALTER TABLE loginSystem_administrator ADD acl_id integer')
except: except:
@@ -968,9 +1256,6 @@ WantedBy=multi-user.target"""
command = 'usermod -a -G lsadm lscpd' command = 'usermod -a -G lsadm lscpd'
Upgrade.executioner(command, 'Add group LSCPD', 0) Upgrade.executioner(command, 'Add group LSCPD', 0)
command = 'chown -R lscpd:lscpd /usr/local/lscp/cyberpanel'
Upgrade.executioner(command, 'chown cyberpanel', 0)
command = 'systemctl daemon-reload' command = 'systemctl daemon-reload'
Upgrade.executioner(command, 'daemon-reload LSCPD', 0) Upgrade.executioner(command, 'daemon-reload LSCPD', 0)
@@ -990,6 +1275,15 @@ WantedBy=multi-user.target"""
Upgrade.stdOut("Fixing permissions..") Upgrade.stdOut("Fixing permissions..")
command = "usermod -G lscpd,lsadm,nobody lscpd"
Upgrade.executioner(command, 'chown core code', 0)
command = "usermod -G lscpd,lsadm,nogroup lscpd"
Upgrade.executioner(command, 'chown core code', 0)
###### fix Core CyberPanel permissions
command = "find /usr/local/CyberCP -type d -exec chmod 0755 {} \;" command = "find /usr/local/CyberCP -type d -exec chmod 0755 {} \;"
Upgrade.executioner(command, 'chown core code', 0) Upgrade.executioner(command, 'chown core code', 0)
@@ -999,11 +1293,50 @@ WantedBy=multi-user.target"""
command = "chmod -R 755 /usr/local/CyberCP/bin" command = "chmod -R 755 /usr/local/CyberCP/bin"
Upgrade.executioner(command, 'chown core code', 0) Upgrade.executioner(command, 'chown core code', 0)
## change owner
command = "chown -R root:root /usr/local/CyberCP" command = "chown -R root:root /usr/local/CyberCP"
Upgrade.executioner(command, 'chown core code', 0) Upgrade.executioner(command, 'chown core code', 0)
command = 'chown -R lscpd:lscpd /usr/local/lscp/cyberpanel' ########### Fix LSCPD
Upgrade.executioner(command, 'chown static content', 0)
command = "find /usr/local/lscp -type d -exec chmod 0755 {} \;"
Upgrade.executioner(command, 'chown core code', 0)
command = "find /usr/local/lscp -type f -exec chmod 0644 {} \;"
Upgrade.executioner(command, 'chown core code', 0)
command = "chmod -R 755 /usr/local/lscp/bin"
Upgrade.executioner(command, 'chown core code', 0)
command = "chmod -R 755 /usr/local/lscp/fcgi-bin"
Upgrade.executioner(command, 'chown core code', 0)
command = "chown -R lscpd:lscpd /usr/local/CyberCP/public/phpmyadmin/tmp"
Upgrade.executioner(command, 'chown core code', 0)
## change owner
command = "chown -R root:root /usr/local/lscp"
Upgrade.executioner(command, 'chown core code', 0)
command = 'openssl req -newkey rsa:1024 -new -nodes -x509 -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout /usr/local/lscp/conf/key.pem -out /usr/local/lscp/conf/cert.pem'
Upgrade.executioner(command, 'generate cyberpanel ssl', 0)
command = "chown -R lscpd:lscpd /usr/local/lscp/cyberpanel/rainloop/data"
Upgrade.executioner(command, 'chown core code', 0)
command = "chmod 700 /usr/local/CyberCP/cli/cyberPanel.py"
Upgrade.executioner(command, 'chown core code', 0)
command = "chmod 700 /usr/local/CyberCP/plogical/upgradeCritical.py"
Upgrade.executioner(command, 'chown core code', 0)
command = "chmod 700 /usr/local/CyberCP/postfixSenderPolicy/client.py"
Upgrade.executioner(command, 'chown core code', 0)
command = "chmod 600 /usr/local/CyberCP/CyberCP/settings.py"
Upgrade.executioner(command, 'chown core code', 0)
Upgrade.stdOut("Permissions updated.") Upgrade.stdOut("Permissions updated.")
@@ -1025,21 +1358,34 @@ WantedBy=multi-user.target"""
'lsphp7?-sqlite3 lsphp7?-tidy' 'lsphp7?-sqlite3 lsphp7?-tidy'
Upgrade.executioner(command, 'Install PHP 73, 0') Upgrade.executioner(command, 'Install PHP 73, 0')
@staticmethod
def someDirectories():
command = "mkdir -p /usr/local/lscpd/admin/"
Upgrade.executioner(command, 0)
command = "mkdir -p /usr/local/lscp/cyberpanel/logs"
Upgrade.executioner(command, 0)
@staticmethod @staticmethod
def upgrade(): def upgrade():
#Upgrade.stdOut("Upgrades are currently disabled")
#return 0
os.chdir("/usr/local") os.chdir("/usr/local")
## Current Version ## Current Version
Version = version.objects.get(pk=1) Version = version.objects.get(pk=1)
command = "systemctl stop gunicorn.socket"
Upgrade.executioner(command, 'stop gunicorn', 0)
command = "systemctl stop lscpd" command = "systemctl stop lscpd"
Upgrade.executioner(command, 'stop lscpd', 0) Upgrade.executioner(command, 'stop lscpd', 0)
Upgrade.fixSudoers()
Upgrade.mountTemp()
Upgrade.dockerUsers()
Upgrade.setupComposer()
## ##
versionNumbring = Upgrade.downloadLink() versionNumbring = Upgrade.downloadLink()
@@ -1056,6 +1402,8 @@ WantedBy=multi-user.target"""
Upgrade.installPYDNS() Upgrade.installPYDNS()
Upgrade.downloadAndUpgrade(versionNumbring) Upgrade.downloadAndUpgrade(versionNumbring)
Upgrade.download_install_phpmyadmin()
Upgrade.downoad_and_install_raindloop()
## ##
@@ -1070,7 +1418,6 @@ WantedBy=multi-user.target"""
## ##
Upgrade.setupVirtualEnv() Upgrade.setupVirtualEnv()
Upgrade.updateGunicornConf()
## ##
@@ -1082,6 +1429,8 @@ WantedBy=multi-user.target"""
Upgrade.installPHP73() Upgrade.installPHP73()
Upgrade.setupCLI() Upgrade.setupCLI()
Upgrade.setupPythonWSGI()
Upgrade.someDirectories()
Upgrade.installLSCPD() Upgrade.installLSCPD()
Upgrade.fixPermissions() Upgrade.fixPermissions()
time.sleep(3) time.sleep(3)

View File

@@ -422,8 +422,8 @@ class virtualHostUtilities:
def issueSSLForHostName(virtualHost, path): def issueSSLForHostName(virtualHost, path):
try: try:
destPrivKey = "/usr/local/lscp/key.pem" destPrivKey = "/usr/local/lscp/conf/key.pem"
destCert = "/usr/local/lscp/cert.pem" destCert = "/usr/local/lscp/conf/cert.pem"
pathToStoreSSLFullChain = '/etc/letsencrypt/live/' + virtualHost + '/fullchain.pem' pathToStoreSSLFullChain = '/etc/letsencrypt/live/' + virtualHost + '/fullchain.pem'
pathToStoreSSLPrivKey = '/etc/letsencrypt/live/' + virtualHost + '/privkey.pem' pathToStoreSSLPrivKey = '/etc/letsencrypt/live/' + virtualHost + '/privkey.pem'
@@ -434,8 +434,6 @@ class virtualHostUtilities:
if os.path.exists(destCert): if os.path.exists(destCert):
os.remove(destCert) os.remove(destCert)
adminEmail = "email@" + virtualHost adminEmail = "email@" + virtualHost
if not os.path.exists(pathToStoreSSLFullChain): if not os.path.exists(pathToStoreSSLFullChain):
@@ -1002,9 +1000,8 @@ class virtualHostUtilities:
data = [int(totalUsageInMB), int(percentage)] data = [int(totalUsageInMB), int(percentage)]
return data return data
except BaseException, msg: except BaseException:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [getDiskUsage]") return [int(totalUsageInMB), int(0)]
return [int(0), int(0)]
@staticmethod @staticmethod
def permissionControl(path): def permissionControl(path):

View File

@@ -1437,7 +1437,7 @@ class WebsiteManager:
try: try:
statusFile = data['statusFile'] statusFile = data['statusFile']
statusData = open(statusFile, 'r').readlines() statusData = ProcessUtilities.outputExecutioner("sudo cat " + statusFile).splitlines()
lastLine = statusData[-1] lastLine = statusData[-1]
@@ -1617,7 +1617,7 @@ class WebsiteManager:
# return execPath # return execPath
output = subprocess.Popen(shlex.split(execPath)) ProcessUtilities.popenExecutioner(execPath)
data_ret = {'status': 1, "installStatus": 1, 'tempStatusPath': tempStatusPath} data_ret = {'status': 1, "installStatus": 1, 'tempStatusPath': tempStatusPath}
json_data = json.dumps(data_ret) json_data = json.dumps(data_ret)

View File

@@ -1,10 +1,12 @@
import sys
sys.path.append('/usr/local/CyberCP')
import subprocess import subprocess
import shlex import shlex
import argparse import argparse
import os import os
import tarfile
import shutil import shutil
import time import time
from plogical.processUtilities import ProcessUtilities
class pluginInstaller: class pluginInstaller:
installLogPath = "/home/cyberpanel/modSecInstallLog" installLogPath = "/home/cyberpanel/modSecInstallLog"
@@ -285,8 +287,9 @@ class pluginInstaller:
@staticmethod @staticmethod
def restartGunicorn(): def restartGunicorn():
command = 'systemctl restart gunicorn.socket' command = 'systemctl restart lscpd'
subprocess.call(shlex.split(command)) ProcessUtilities.normalExecutioner(command)

View File

@@ -20,7 +20,6 @@ enum34==1.1.6
funcsigs==1.0.2 funcsigs==1.0.2
future==0.16.0 future==0.16.0
futures==3.2.0 futures==3.2.0
gunicorn==19.8.1
idna==2.6 idna==2.6
iniparse==0.4 iniparse==0.4
ipaddress==1.0.16 ipaddress==1.0.16

View File

@@ -18,6 +18,8 @@ try:
from random import randint from random import randint
import subprocess, shlex import subprocess, shlex
from plogical.processUtilities import ProcessUtilities from plogical.processUtilities import ProcessUtilities
from websiteFunctions.models import Websites, Backups
from plogical.virtualHostUtilities import virtualHostUtilities
except: except:
import threading as multi import threading as multi
from random import randint from random import randint
@@ -93,18 +95,41 @@ class S3Backups(multi.Thread):
return json_data return json_data
def setupCron(self): def setupCron(self):
try:
command = "sudo cat /etc/crontab"
crons = ProcessUtilities.outputExecutioner(command).splitlines()
cronCheck = 1
for items in crons:
if items.find('s3Backups.py') > -1:
cronCheck = 0
tempPath = '/home/cyberpanel/' + str(randint(10000, 99999)) tempPath = '/home/cyberpanel/' + str(randint(10000, 99999))
writeToFile = open(tempPath, 'w') writeToFile = open(tempPath, "w")
writeToFile.write('0 0 * * * /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/s3Backups/s3Backups.py > /home/cyberpanel/error-logs.txt 2>&1\n')
for items in crons:
writeToFile.writelines(items + "\n")
if cronCheck:
writeToFile.writelines("0 0 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/s3Backups/s3Backups.py > /home/cyberpanel/error-logs.txt 2>&1\n")
writeToFile.close() writeToFile.close()
command = 'sudo crontab -u cyberpanel ' + tempPath command = 'sudo mv ' + tempPath + " /etc/crontab"
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
command = 'chown root:root /etc/crontab'
ProcessUtilities.executioner(command)
try: try:
os.remove(tempPath) os.remove(tempPath)
except: except:
pass pass
except BaseException, msg:
logging.writeToFile(str(msg) + " [S3Backups.setupCron]")
def connectAccount(self): def connectAccount(self):
try: try:
@@ -389,25 +414,64 @@ class S3Backups(multi.Thread):
return proc.ajaxPre(0, str(msg)) return proc.ajaxPre(0, str(msg))
def createBackup(self, virtualHost): def createBackup(self, virtualHost):
finalData = json.dumps({'websiteToBeBacked': virtualHost})
r = requests.post("http://localhost:5003/backup/submitBackupCreation", data=finalData) website = Websites.objects.get(domain=virtualHost)
# defining paths
data = json.loads(r.text) ## /home/example.com/backup
try: backupPath = os.path.join("/home", virtualHost, "backup/")
backupPath = data['tempStorage'] domainUser = website.externalApp
except: backupName = 'backup-' + domainUser + "-" + time.strftime("%I-%M-%S-%a-%b-%Y")
pass
## /home/example.com/backup/backup-example-06-50-03-Thu-Feb-2018
tempStoragePath = os.path.join(backupPath, backupName)
execPath = "sudo nice -n 10 python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
execPath = execPath + " submitBackupCreation --tempStoragePath " + tempStoragePath + " --backupName " \
+ backupName + " --backupPath " + backupPath + ' --backupDomain ' + virtualHost
ProcessUtilities.popenExecutioner(execPath)
time.sleep(2)
while (1): while (1):
r = requests.post("http://localhost:5003/backup/backupStatus", data=finalData)
time.sleep(2)
data = json.loads(r.text)
if data['backupStatus'] == 0: backupDomain = virtualHost
return 0, data['error_message'] status = os.path.join("/home", backupDomain, "backup/status")
elif data['abort'] == 1: backupFileNamePath = os.path.join("/home", backupDomain, "backup/backupFileName")
return 1, backupPath pid = os.path.join("/home", backupDomain, "backup/pid")
## read file name
try:
fileName = open(backupFileNamePath, 'r').read()
except:
fileName = "Fetching.."
## file name read ends
if os.path.exists(status):
status = open(status, 'r').read()
if status.find("Completed") > -1:
### Removing Files
command = 'sudo rm -f ' + status
ProcessUtilities.normalExecutioner(command)
command = 'sudo rm -f ' + backupFileNamePath
ProcessUtilities.normalExecutioner(command)
command = 'sudo rm -f ' + pid
ProcessUtilities.normalExecutioner(command)
return 1, tempStoragePath
elif status.find("[5009]") > -1:
backupObs = Backups.objects.filter(fileName=fileName)
for items in backupObs:
items.delete()
return 0, status
def forceRunAWSBackup(self): def forceRunAWSBackup(self):
try: try:
@@ -1310,7 +1374,7 @@ def main():
file.close() file.close()
finalData = json.dumps({'randomFile': pathToFile}) finalData = json.dumps({'randomFile': pathToFile})
requests.post("http://localhost:5003/api/runAWSBackups", data=finalData, verify=False) requests.post("https://localhost:8090/api/runAWSBackups", data=finalData, verify=False)
if __name__ == "__main__": if __name__ == "__main__":

View File

@@ -37,8 +37,6 @@ class ServerStatusUtil:
def installLiteSpeed(licenseKey, statusFile): def installLiteSpeed(licenseKey, statusFile):
try: try:
logging.CyberCPLogFileWriter.writeToFile(os.environ.get('TERM'))
cwd = os.getcwd() cwd = os.getcwd()
try: try:

View File

@@ -8,7 +8,6 @@ from loginSystem.views import loadLoginPage
import json import json
import subprocess import subprocess
import psutil import psutil
import shlex
import socket import socket
from plogical.acl import ACLManager from plogical.acl import ACLManager
import os import os
@@ -17,6 +16,7 @@ import time
import serverStatusUtil import serverStatusUtil
from plogical.processUtilities import ProcessUtilities from plogical.processUtilities import ProcessUtilities
from plogical.httpProc import httpProc from plogical.httpProc import httpProc
from plogical.installUtilities import installUtilities
# Create your views here. # Create your views here.
@@ -96,12 +96,12 @@ def stopOrRestartLitespeed(request):
reboot = data['reboot'] reboot = data['reboot']
if reboot == 1: if reboot == 1:
if ProcessUtilities.restartLitespeed() == 1: if installUtilities.reStartLiteSpeedSocket() == 1:
status = {"reboot": 1, "shutdown": 0} status = {"reboot": 1, "shutdown": 0}
else: else:
status = {"reboot": 0, "shutdown": 0, "error_message": "Please see CyberCP main log file."} status = {"reboot": 0, "shutdown": 0, "error_message": "Please see CyberCP main log file."}
else: else:
if ProcessUtilities.stopLitespeed() == 1: if installUtilities.stopLiteSpeedSocket() == 1:
status = {"reboot": 0, "shutdown": 1} status = {"reboot": 0, "shutdown": 1}
else: else:
status = {"reboot": 0, "shutdown": 0, "error_message": "Please see CyberCP main log file."} status = {"reboot": 0, "shutdown": 0, "error_message": "Please see CyberCP main log file."}