mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-10-26 07:46:35 +01:00
bug fix to tuning
This commit is contained in:
31
plogical/alias.py
Normal file
31
plogical/alias.py
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/usr/local/CyberCP/bin/python2
|
||||
import os,sys
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
import django
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
from loginSystem.models import Administrator, ACL
|
||||
from django.shortcuts import HttpResponse
|
||||
from packages.models import Package
|
||||
from websiteFunctions.models import Websites
|
||||
from dns.models import Domains
|
||||
import json
|
||||
|
||||
class AliasManager:
|
||||
|
||||
def __init__(self, domain):
|
||||
self.domain = domain
|
||||
|
||||
def fetchAlisForDomains(self):
|
||||
website = Websites.objects.get(domain=self.domain)
|
||||
|
||||
finalAlisList = []
|
||||
noAlias = 0
|
||||
|
||||
aliases = website.aliasdomains_set.all()
|
||||
|
||||
for items in aliases:
|
||||
finalAlisList.append(items.aliasDomain)
|
||||
noAlias = 1
|
||||
|
||||
return noAlias, finalAlisList
|
||||
@@ -204,23 +204,21 @@ class backupUtilities:
|
||||
return 0,str(msg)
|
||||
|
||||
@staticmethod
|
||||
def startBackup(tempStoragePath,backupName,backupPath):
|
||||
def startBackup(tempStoragePath, backupName, backupPath):
|
||||
try:
|
||||
|
||||
##### Writing the name of backup file.
|
||||
|
||||
## /home/example.com/backup/backupFileName
|
||||
|
||||
backupFileNamePath = os.path.join(backupPath,"backupFileName")
|
||||
status = open(backupFileNamePath, "w")
|
||||
status.write(backupName)
|
||||
status.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(backupFileNamePath, backupName)
|
||||
|
||||
#####
|
||||
|
||||
status = os.path.join(backupPath,'status')
|
||||
|
||||
status = open(os.path.join(backupPath,'status'),"w")
|
||||
status.write("Making archive of home directory.\n")
|
||||
status.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "Making archive of home directory.\n")
|
||||
|
||||
##### Parsing XML Meta file!
|
||||
|
||||
@@ -236,11 +234,16 @@ class backupUtilities:
|
||||
|
||||
make_archive(os.path.join(tempStoragePath,"public_html"), 'gztar', os.path.join("/home",domainName,"public_html"))
|
||||
|
||||
##### Saving SSL Certificates if any
|
||||
|
||||
sslStoragePath = '/etc/letsencrypt/live/' + domainName
|
||||
|
||||
if os.path.exists(sslStoragePath):
|
||||
make_archive(os.path.join(tempStoragePath, "sslData-" + domainName), 'gztar', sslStoragePath)
|
||||
|
||||
## backup email accounts
|
||||
|
||||
status = open(os.path.join(backupPath, 'status'), "w")
|
||||
status.write("Backing up email accounts!\n")
|
||||
status.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "Backing up email accounts!\n")
|
||||
|
||||
try:
|
||||
make_archive(os.path.join(tempStoragePath,domainName),'gztar',os.path.join("/home","vmail",domainName))
|
||||
@@ -254,23 +257,11 @@ class backupUtilities:
|
||||
|
||||
dbName = database.find('dbName').text
|
||||
|
||||
status = open(os.path.join(backupPath,'status'), "w")
|
||||
status.write("Backing up database: " + dbName)
|
||||
status.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "Backing up database: " + dbName)
|
||||
|
||||
if mysqlUtilities.mysqlUtilities.createDatabaseBackup(dbName, tempStoragePath) == 0:
|
||||
raise BaseException
|
||||
|
||||
##### Saving SSL Certificates if any
|
||||
|
||||
try:
|
||||
sslStoragePath = '/etc/letsencrypt/live/' + domainName
|
||||
|
||||
if os.path.exists(sslStoragePath):
|
||||
make_archive(os.path.join(tempStoragePath, "sslData-" + domainName), 'gztar',
|
||||
sslStoragePath)
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
||||
|
||||
|
||||
## Child Domains SSL.
|
||||
|
||||
@@ -285,8 +276,7 @@ class backupUtilities:
|
||||
sslStoragePath = '/etc/letsencrypt/live/' + actualChildDomain
|
||||
|
||||
if os.path.exists(sslStoragePath):
|
||||
make_archive(os.path.join(tempStoragePath, "sslData-" + actualChildDomain), 'gztar',
|
||||
sslStoragePath)
|
||||
make_archive(os.path.join(tempStoragePath, "sslData-" + actualChildDomain), 'gztar', sslStoragePath)
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
||||
|
||||
@@ -298,9 +288,7 @@ class backupUtilities:
|
||||
rmtree(tempStoragePath)
|
||||
|
||||
|
||||
status = open(os.path.join(backupPath,'status'), "w")
|
||||
status.write("Completed\n")
|
||||
status.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "Completed\n")
|
||||
|
||||
|
||||
except BaseException,msg:
|
||||
@@ -315,9 +303,7 @@ class backupUtilities:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
||||
|
||||
status = open(os.path.join(backupPath,'status'), "w")
|
||||
status.write(backupName + "\n")
|
||||
status.write("Aborted, please check CyberPanel main log file. [5009]")
|
||||
status.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "Aborted, please check CyberPanel main log file. [5009]")
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
||||
|
||||
@staticmethod
|
||||
@@ -441,16 +427,14 @@ class backupUtilities:
|
||||
if not os.path.exists(completPath):
|
||||
os.mkdir(completPath)
|
||||
|
||||
## writing pid of restore process
|
||||
## Writing pid of restore process
|
||||
|
||||
pid = open(os.path.join(completPath,'pid'), "w")
|
||||
pid.write(str(os.getpid()))
|
||||
pid.close()
|
||||
pid = os.path.join(completPath,'pid')
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(pid, str(os.getpid()))
|
||||
|
||||
status = open(os.path.join(completPath,'status'), "w")
|
||||
status.write("Extracting Main Archive!")
|
||||
status.close()
|
||||
status = os.path.join(completPath,'status')
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "Extracting Main Archive!")
|
||||
|
||||
## Converting /home/backup/backup-example-06-50-03-Thu-Feb-2018.tar.gz -> /home/backup/backup-example-06-50-03-Thu-Feb-2018
|
||||
|
||||
@@ -459,10 +443,7 @@ class backupUtilities:
|
||||
tar.close()
|
||||
|
||||
|
||||
|
||||
status = open(os.path.join(completPath,'status'), "w")
|
||||
status.write("Creating Accounts,Databases and DNS records!")
|
||||
status.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "Creating Accounts,Databases and DNS records!")
|
||||
|
||||
########### Creating website and its dabases
|
||||
|
||||
@@ -485,24 +466,18 @@ class backupUtilities:
|
||||
sslUtilities.installSSLForDomain(masterDomain)
|
||||
|
||||
else:
|
||||
status = open(os.path.join(completPath, 'status'), "w")
|
||||
status.write("Error Message: " + result[1] +
|
||||
". Not able to create Account, Databases and DNS Records, aborting. [5009]")
|
||||
status.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + result[1] + ". Not able to create Account, Databases and DNS Records, aborting. [5009]")
|
||||
return 0
|
||||
|
||||
########### Creating child/sub/addon/parked domains
|
||||
|
||||
status = open(os.path.join(completPath,'status'), "w")
|
||||
status.write("Creating Child Domains!")
|
||||
status.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "Creating Child Domains!")
|
||||
|
||||
## Reading meta file to create subdomains
|
||||
|
||||
externalApp = backupMetaData.find('externalApp').text
|
||||
websiteHome = os.path.join("/home",masterDomain,"public_html")
|
||||
|
||||
|
||||
### Restoring Child Domains if any.
|
||||
|
||||
childDomains = backupMetaData.findall('ChildDomains/domain')
|
||||
@@ -517,7 +492,8 @@ class backupUtilities:
|
||||
retValues = virtualHostUtilities.createDomain(masterDomain, domain, phpSelection, path, 0, 0, 0, 'admin')
|
||||
|
||||
if retValues[0] == 1:
|
||||
rmtree(websiteHome)
|
||||
if os.path.exists(websiteHome):
|
||||
rmtree(websiteHome)
|
||||
|
||||
## Let us try to restore SSL for Child Domains.
|
||||
|
||||
@@ -533,12 +509,9 @@ class backupUtilities:
|
||||
except:
|
||||
logging.CyberCPLogFileWriter.writeToFile('While restoring backup we had minor issues for rebuilding vhost conf for: ' + domain + '. However this will be auto healed.')
|
||||
|
||||
|
||||
continue
|
||||
else:
|
||||
status = open(os.path.join(completPath,'status'), "w")
|
||||
status.write("Error Message: " + retValues[1] + ". Not able to create child domains, aborting. [5009]")
|
||||
status.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + retValues[1] + ". Not able to create child domains, aborting. [5009]")
|
||||
return 0
|
||||
except BaseException, msg:
|
||||
status = open(os.path.join(completPath,'status'), "w")
|
||||
@@ -549,20 +522,16 @@ class backupUtilities:
|
||||
|
||||
## Restore Aliases
|
||||
|
||||
status = open(os.path.join(completPath, 'status'), "w")
|
||||
status.write("Restoring Domain Aliases!")
|
||||
status.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "Restoring Domain Aliases!")
|
||||
|
||||
aliases = backupMetaData.findall('Aliases/alias')
|
||||
|
||||
for items in aliases:
|
||||
virtualHostUtilities.createAlias(masterDomain, items.text, 0, "", "")
|
||||
virtualHostUtilities.createAlias(masterDomain, items.text, 0, "", "", "admin")
|
||||
|
||||
## Restoring email accounts
|
||||
|
||||
status = open(os.path.join(completPath, 'status'), "w")
|
||||
status.write("Restoring email accounts!")
|
||||
status.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "Restoring email accounts!")
|
||||
|
||||
emailAccounts = backupMetaData.findall('emails/emailAccount')
|
||||
|
||||
@@ -578,9 +547,7 @@ class backupUtilities:
|
||||
raise BaseException(result[1])
|
||||
|
||||
except BaseException, msg:
|
||||
status = open(os.path.join(completPath,'status'), "w")
|
||||
status.write("Error Message: " + str(msg) +". Not able to create email accounts, aborting. [5009]")
|
||||
status.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + str(msg) +". Not able to create email accounts, aborting. [5009]")
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startRestore]")
|
||||
return 0
|
||||
|
||||
@@ -588,9 +555,7 @@ class backupUtilities:
|
||||
|
||||
## restoring databases
|
||||
|
||||
status = open(os.path.join(completPath,'status'), "w")
|
||||
status.write("Restoring Databases")
|
||||
status.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "Restoring Databases!")
|
||||
|
||||
databases = backupMetaData.findall('Databases/database')
|
||||
|
||||
@@ -602,10 +567,7 @@ class backupUtilities:
|
||||
|
||||
## Databases restored
|
||||
|
||||
|
||||
status = open(os.path.join(completPath, 'status'), "w")
|
||||
status.write("Extracting web home data!")
|
||||
status.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "Extracting web home data!")
|
||||
|
||||
# /home/backup/backup-example-06-50-03-Thu-Feb-2018/public_html.tar.gz
|
||||
|
||||
@@ -615,9 +577,7 @@ class backupUtilities:
|
||||
|
||||
## extracting email accounts
|
||||
|
||||
status = open(os.path.join(completPath, 'status'), "w")
|
||||
status.write("Extracting email accounts!")
|
||||
status.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "Extracting email accounts!")
|
||||
|
||||
try:
|
||||
pathToCompressedEmails = os.path.join(completPath, masterDomain + ".tar.gz")
|
||||
@@ -638,9 +598,7 @@ class backupUtilities:
|
||||
|
||||
##
|
||||
|
||||
status = open(os.path.join(completPath,'status'), "w")
|
||||
status.write("Done")
|
||||
status.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "Done")
|
||||
|
||||
installUtilities.reStartLiteSpeed()
|
||||
|
||||
@@ -921,8 +879,14 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
|
||||
## /home/example.com/backup - backupPath
|
||||
## /home/cyberpanel/1047.xml - metaPath
|
||||
|
||||
status = os.path.join(backupPath, 'status')
|
||||
result = backupUtilities.prepareBackupMeta(backupDomain, backupName, tempStoragePath, backupPath)
|
||||
|
||||
if result[0] == 0:
|
||||
logging.CyberCPLogFileWriter.writeToFile(result[1] + ' [5009]')
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, result[1] + ' [5009]')
|
||||
return
|
||||
|
||||
backupUtilities.prepareBackupMeta(backupDomain, backupName, tempStoragePath, backupPath)
|
||||
|
||||
p = Process(target=backupUtilities.startBackup, args=(tempStoragePath, backupName, backupPath,))
|
||||
p.start()
|
||||
@@ -930,12 +894,10 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
|
||||
pid.write(str(p.pid))
|
||||
pid.close()
|
||||
|
||||
print "1,None"
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [submitBackupCreation]")
|
||||
print "0," + str(msg)
|
||||
|
||||
def cancelBackupCreation(backupCancellationDomain,fileName):
|
||||
try:
|
||||
|
||||
@@ -32,6 +32,31 @@ class sslUtilities:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [IO Error with main config file [checkIfSSLMap]]")
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def checkSSLListener():
|
||||
try:
|
||||
data = open("/usr/local/lsws/conf/httpd_config.conf").readlines()
|
||||
for items in data:
|
||||
if items.find("listener SSL") > -1:
|
||||
return 1
|
||||
|
||||
except BaseException,msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [IO Error with main config file [checkSSLListener]]")
|
||||
return str(msg)
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def getDNSRecords(virtualHostName):
|
||||
try:
|
||||
|
||||
withoutWWW = socket.gethostbyname(virtualHostName)
|
||||
withWWW = socket.gethostbyname('www.' + virtualHostName)
|
||||
|
||||
return [1, withWWW, withoutWWW]
|
||||
|
||||
except BaseException, msg:
|
||||
return [0, "347 " + str(msg) + " [issueSSLForDomain]"]
|
||||
|
||||
@staticmethod
|
||||
def installSSLForDomain(virtualHostName):
|
||||
|
||||
@@ -41,15 +66,15 @@ class sslUtilities:
|
||||
try:
|
||||
map = " map " + virtualHostName + " " + virtualHostName + "\n"
|
||||
|
||||
if sslUtilities.checkSSLListener()!=1:
|
||||
if sslUtilities.checkSSLListener() != 1:
|
||||
|
||||
writeDataToFile = open("/usr/local/lsws/conf/httpd_config.conf", 'a')
|
||||
|
||||
listener = "listener SSL {" + "\n"
|
||||
address = " address *:443" + "\n"
|
||||
secure = " secure 1" + "\n"
|
||||
keyFile = " keyFile /etc/letsencrypt/live/"+ virtualHostName + "/privkey.pem\n"
|
||||
certFile = " certFile /etc/letsencrypt/live/"+ virtualHostName + "/fullchain.pem\n"
|
||||
keyFile = " keyFile /etc/letsencrypt/live/" + virtualHostName + "/privkey.pem\n"
|
||||
certFile = " certFile /etc/letsencrypt/live/" + virtualHostName + "/fullchain.pem\n"
|
||||
certChain = " certChain 1" + "\n"
|
||||
sslProtocol = " sslProtocol 30" + "\n"
|
||||
map = " map " + virtualHostName + " " + virtualHostName + "\n"
|
||||
@@ -78,7 +103,7 @@ class sslUtilities:
|
||||
sslCheck = 0
|
||||
|
||||
for items in data:
|
||||
if items.find("listener")>-1 and items.find("SSL") > -1:
|
||||
if items.find("listener") > -1 and items.find("SSL") > -1:
|
||||
sslCheck = 1
|
||||
|
||||
if (sslCheck == 1):
|
||||
@@ -91,19 +116,18 @@ class sslUtilities:
|
||||
|
||||
###################### Write per host Configs for SSL ###################
|
||||
|
||||
data = open(completePathToConfigFile,"r").readlines()
|
||||
data = open(completePathToConfigFile, "r").readlines()
|
||||
|
||||
## check if vhssl is already in vhconf file
|
||||
|
||||
vhsslPresense = 0
|
||||
|
||||
for items in data:
|
||||
if items.find("vhssl")>-1:
|
||||
if items.find("vhssl") > -1:
|
||||
vhsslPresense = 1
|
||||
|
||||
|
||||
if vhsslPresense == 0:
|
||||
writeSSLConfig = open(completePathToConfigFile,"a")
|
||||
writeSSLConfig = open(completePathToConfigFile, "a")
|
||||
|
||||
vhssl = "vhssl {" + "\n"
|
||||
keyFile = " keyFile /etc/letsencrypt/live/" + virtualHostName + "/privkey.pem\n"
|
||||
@@ -121,53 +145,22 @@ class sslUtilities:
|
||||
writeSSLConfig.writelines(sslProtocol)
|
||||
writeSSLConfig.writelines(final)
|
||||
|
||||
|
||||
writeSSLConfig.writelines("\n")
|
||||
|
||||
writeSSLConfig.close()
|
||||
|
||||
return 1
|
||||
|
||||
except BaseException,msg:
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installSSLForDomain]]")
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def checkSSLListener():
|
||||
try:
|
||||
data = open("/usr/local/lsws/conf/httpd_config.conf").readlines()
|
||||
for items in data:
|
||||
if items.find("listener SSL") > -1:
|
||||
return 1
|
||||
|
||||
except BaseException,msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [IO Error with main config file [checkSSLListener]]")
|
||||
return str(msg)
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def getDNSRecords(virtualHostName):
|
||||
try:
|
||||
|
||||
withoutWWW = socket.gethostbyname(virtualHostName)
|
||||
withWWW = socket.gethostbyname('www.' + virtualHostName)
|
||||
|
||||
return [1, withWWW, withoutWWW]
|
||||
|
||||
except BaseException, msg:
|
||||
return [0, "347 " + str(msg) + " [issueSSLForDomain]"]
|
||||
|
||||
@staticmethod
|
||||
def obtainSSLForADomain(virtualHostName,adminEmail,sslpath, aliasDomain = None):
|
||||
try:
|
||||
|
||||
## Obtaining Server IP
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
serverIPAddress = ipData.split('\n', 1)[0]
|
||||
|
||||
if aliasDomain == None:
|
||||
|
||||
existingCertPath = '/etc/letsencrypt/live/' + virtualHostName + '/README'
|
||||
@@ -176,21 +169,22 @@ class sslUtilities:
|
||||
|
||||
try:
|
||||
logging.CyberCPLogFileWriter.writeToFile("Trying to obtain SSL for: " + virtualHostName + " and: www." + virtualHostName)
|
||||
|
||||
command = "/usr/local/CyberCP/bin/certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName + " -d www." + virtualHostName
|
||||
output = subprocess.check_output(shlex.split(command))
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
"Successfully obtained SSL for: " + virtualHostName + " and: www." + virtualHostName)
|
||||
except subprocess.CalledProcessError, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile("Successfully obtained SSL for: " + virtualHostName + " and: www." + virtualHostName)
|
||||
|
||||
|
||||
except subprocess.CalledProcessError:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
"Failed to obtain SSL for: " + virtualHostName + " and: www." + virtualHostName)
|
||||
|
||||
try:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
"Trying to obtain SSL for: " + virtualHostName)
|
||||
logging.CyberCPLogFileWriter.writeToFile("Trying to obtain SSL for: " + virtualHostName)
|
||||
command = "/usr/local/CyberCP/bin/certbot certonly -n --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName
|
||||
output = subprocess.check_output(shlex.split(command))
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
"Successfully obtained SSL for: " + virtualHostName)
|
||||
except subprocess.CalledProcessError, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile("Successfully obtained SSL for: " + virtualHostName)
|
||||
except subprocess.CalledProcessError:
|
||||
logging.CyberCPLogFileWriter.writeToFile('Failed to obtain SSL, issuing self-signed SSL for: ' + virtualHostName)
|
||||
return 0
|
||||
|
||||
@@ -214,6 +208,11 @@ class sslUtilities:
|
||||
|
||||
else:
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
serverIPAddress = ipData.split('\n', 1)[0]
|
||||
|
||||
ipRecords = sslUtilities.getDNSRecords(virtualHostName)
|
||||
|
||||
if ipRecords[0] == 1:
|
||||
@@ -265,21 +264,20 @@ class sslUtilities:
|
||||
"Failed to obtain DNS records for " + virtualHostName + ", issuing self signed certificate.")
|
||||
return 0
|
||||
|
||||
output = subprocess.check_output(shlex.split(command))
|
||||
output = subprocess.check_output(shlex.split(command))
|
||||
|
||||
if output.find('Congratulations!') > -1:
|
||||
|
||||
return 1
|
||||
|
||||
elif output.find('no action taken.') > -1:
|
||||
return 1
|
||||
elif output.find('Failed authorization procedure') > -1:
|
||||
logging.CyberCPLogFileWriter.writeToFile('Failed authorization procedure for ' + virtualHostName + " while issuing Let's Encrypt SSL.")
|
||||
return 0
|
||||
elif output.find('Too many SSL requests for this domain, please try to get SSL at later time.') > -1:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
'Too many SSL requests for ' + virtualHostName + " please try to get SSL at later time.")
|
||||
return 0
|
||||
if output.find('Congratulations!') > -1:
|
||||
return 1
|
||||
elif output.find('no action taken.') > -1:
|
||||
return 1
|
||||
elif output.find('Failed authorization procedure') > -1:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
'Failed authorization procedure for ' + virtualHostName + " while issuing Let's Encrypt SSL.")
|
||||
return 0
|
||||
elif output.find('Too many SSL requests for this domain, please try to get SSL at later time.') > -1:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
'Too many SSL requests for ' + virtualHostName + " please try to get SSL at later time.")
|
||||
return 0
|
||||
|
||||
except BaseException,msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [Failed to obtain SSL. [obtainSSLForADomain]]")
|
||||
|
||||
@@ -8,7 +8,7 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
import shutil
|
||||
import installUtilities
|
||||
from websiteFunctions.models import Websites, ChildDomains
|
||||
from websiteFunctions.models import Websites, ChildDomains, aliasDomains
|
||||
import subprocess
|
||||
import shlex
|
||||
import CyberCPLogFileWriter as logging
|
||||
@@ -413,7 +413,6 @@ RewriteFile .htaccess
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return 0
|
||||
|
||||
|
||||
@staticmethod
|
||||
def createConfigInMainVirtualHostFile(virtualHostName):
|
||||
|
||||
@@ -688,20 +687,10 @@ RewriteFile .htaccess
|
||||
@staticmethod
|
||||
def checkIfAliasExists(aliasDomain):
|
||||
try:
|
||||
confPath = os.path.join(vhost.Server_root, "conf/httpd_config.conf")
|
||||
data = open(confPath, 'r').readlines()
|
||||
|
||||
for items in data:
|
||||
if items.find(aliasDomain) > -1:
|
||||
domains = filter(None, items.split(" "))
|
||||
for domain in domains:
|
||||
if domain.strip(',').strip('\n') == aliasDomain:
|
||||
return 1
|
||||
|
||||
return 0
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [checkIfAliasExists]")
|
||||
alias = aliasDomains.objects.get(aliasDomain=aliasDomain)
|
||||
return 1
|
||||
except BaseException, msg:
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def checkIfSSLAliasExists(data, aliasDomain):
|
||||
|
||||
@@ -147,27 +147,19 @@ class virtualHostUtilities:
|
||||
def issueSSL(virtualHost, path, adminEmail):
|
||||
try:
|
||||
|
||||
FNULL = open(os.devnull, 'w')
|
||||
|
||||
retValues = sslUtilities.issueSSLForDomain(virtualHost, adminEmail, path)
|
||||
|
||||
if retValues[0] == 0:
|
||||
print "0," + str(retValues[1])
|
||||
return
|
||||
return 0, str(retValues[1])
|
||||
|
||||
installUtilities.installUtilities.reStartLiteSpeed()
|
||||
|
||||
vhostPath = virtualHostUtilities.Server_root + "/conf/vhosts"
|
||||
command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + vhostPath
|
||||
cmd = shlex.split(command)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
print "1,None"
|
||||
return 1, None
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [issueSSL]")
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [issueSSL]")
|
||||
print "0," + str(msg)
|
||||
return 0, str(msg)
|
||||
|
||||
@@ -435,8 +427,6 @@ class virtualHostUtilities:
|
||||
def issueSSLForHostName(virtualHost, path):
|
||||
try:
|
||||
|
||||
FNULL = open(os.devnull, 'w')
|
||||
|
||||
destPrivKey = "/usr/local/lscp/key.pem"
|
||||
destCert = "/usr/local/lscp/cert.pem"
|
||||
|
||||
@@ -464,18 +454,12 @@ class virtualHostUtilities:
|
||||
cmd = shlex.split(command)
|
||||
subprocess.call(cmd)
|
||||
|
||||
vhostPath = virtualHostUtilities.Server_root + "/conf/vhosts"
|
||||
command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + vhostPath
|
||||
cmd = shlex.split(command)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
print "1,None"
|
||||
return 1,'None'
|
||||
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [issueSSLForHostName]")
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [issueSSLForHostName]")
|
||||
print "0," + str(msg)
|
||||
return 0, str(msg)
|
||||
|
||||
@@ -483,8 +467,6 @@ class virtualHostUtilities:
|
||||
def issueSSLForMailServer(virtualHost, path):
|
||||
try:
|
||||
|
||||
FNULL = open(os.devnull, 'w')
|
||||
|
||||
srcFullChain = '/etc/letsencrypt/live/' + virtualHost + '/fullchain.pem'
|
||||
srcPrivKey = '/etc/letsencrypt/live/' + virtualHost + '/privkey.pem'
|
||||
|
||||
@@ -530,11 +512,6 @@ class virtualHostUtilities:
|
||||
shutil.copy(srcPrivKey, "/etc/dovecot/key.pem")
|
||||
shutil.copy(srcFullChain, "/etc/dovecot/cert.pem")
|
||||
|
||||
vhostPath = virtualHostUtilities.Server_root + "/conf/vhosts"
|
||||
command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + vhostPath
|
||||
cmd = shlex.split(command)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
## Update postmaster address dovecot
|
||||
|
||||
filePath = "/etc/dovecot/dovecot.conf"
|
||||
@@ -582,35 +559,36 @@ class virtualHostUtilities:
|
||||
@staticmethod
|
||||
def createAlias(masterDomain, aliasDomain, ssl, sslPath, administratorEmail, owner=None):
|
||||
try:
|
||||
if owner != None:
|
||||
admin = Administrator.objects.get(userName=owner)
|
||||
DNS.dnsTemplate(aliasDomain, owner)
|
||||
|
||||
if vhost.checkIfAliasExists(aliasDomain) == 0:
|
||||
admin = Administrator.objects.get(userName=owner)
|
||||
DNS.dnsTemplate(aliasDomain, admin)
|
||||
|
||||
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
||||
data = open(confPath, 'r').readlines()
|
||||
writeToFile = open(confPath, 'w')
|
||||
listenerTrueCheck = 0
|
||||
|
||||
for items in data:
|
||||
if items.find("listener") > -1 and items.find("Default") > -1:
|
||||
listenerTrueCheck = 1
|
||||
if items.find(masterDomain) > -1 and items.find('map') > -1 and listenerTrueCheck == 1:
|
||||
data = filter(None, items.split(" "))
|
||||
if data[1] == masterDomain:
|
||||
writeToFile.writelines(items.rstrip('\n') + ", " + aliasDomain + "\n")
|
||||
listenerTrueCheck = 0
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
|
||||
writeToFile.close()
|
||||
|
||||
installUtilities.installUtilities.reStartLiteSpeed()
|
||||
else:
|
||||
if vhost.checkIfAliasExists(aliasDomain) == 1:
|
||||
print "0, This domain already exists as vHost or Alias."
|
||||
return
|
||||
|
||||
|
||||
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
||||
data = open(confPath, 'r').readlines()
|
||||
writeToFile = open(confPath, 'w')
|
||||
listenerTrueCheck = 0
|
||||
|
||||
for items in data:
|
||||
if items.find("listener") > -1 and items.find("Default") > -1:
|
||||
listenerTrueCheck = 1
|
||||
if items.find(masterDomain) > -1 and items.find('map') > -1 and listenerTrueCheck == 1:
|
||||
data = filter(None, items.split(" "))
|
||||
if data[1] == masterDomain:
|
||||
writeToFile.writelines(items.rstrip('\n') + ", " + aliasDomain + "\n")
|
||||
listenerTrueCheck = 0
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
|
||||
writeToFile.close()
|
||||
|
||||
installUtilities.installUtilities.reStartLiteSpeed()
|
||||
|
||||
if ssl == 1:
|
||||
retValues = sslUtilities.issueSSLForDomain(masterDomain, administratorEmail, sslPath, aliasDomain)
|
||||
if retValues[0] == 0:
|
||||
@@ -747,7 +725,7 @@ class virtualHostUtilities:
|
||||
print "0," + str(msg)
|
||||
|
||||
@staticmethod
|
||||
def saveSSL(virtualHost, pathToStoreSSL, keyPath, certPath, sslCheck):
|
||||
def saveSSL(virtualHost, keyPath, certPath):
|
||||
try:
|
||||
|
||||
pathToStoreSSL = '/etc/letsencrypt/live/' + virtualHost
|
||||
@@ -769,8 +747,8 @@ class virtualHostUtilities:
|
||||
os.remove(keyPath)
|
||||
os.remove(certPath)
|
||||
|
||||
website = Websites.objects.get(domain=virtualHost)
|
||||
sslUtilities.sslUtilities.installSSLForDomain(virtualHost, website.adminEmail)
|
||||
|
||||
sslUtilities.sslUtilities.installSSLForDomain(virtualHost)
|
||||
|
||||
installUtilities.installUtilities.reStartLiteSpeed()
|
||||
|
||||
@@ -1071,7 +1049,7 @@ def main():
|
||||
elif args.function == "saveRewriteRules":
|
||||
virtualHostUtilities.saveRewriteRules(args.virtualHostName,args.path,args.tempPath)
|
||||
elif args.function == "saveSSL":
|
||||
virtualHostUtilities.saveSSL(args.virtualHostName,args.path,args.tempKeyPath,args.tempCertPath,args.sslCheck)
|
||||
virtualHostUtilities.saveSSL(args.virtualHostName,args.tempKeyPath,args.tempCertPath)
|
||||
elif args.function == "installWordPress":
|
||||
virtualHostUtilities.installWordPress(args.virtualHostName,args.path,args.virtualHostUser,args.dbName,args.dbUser,args.dbPassword)
|
||||
elif args.function == "installJoomla":
|
||||
|
||||
245
tuning/views.py
245
tuning/views.py
@@ -12,15 +12,20 @@ from websiteFunctions.models import Websites,ChildDomains
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
import subprocess
|
||||
import shlex
|
||||
from plogical.acl import ACLManager
|
||||
# Create your views here.
|
||||
|
||||
|
||||
def loadTuningHome(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
if admin.type == 3:
|
||||
return HttpResponse("You don't have enough privileges to access this page.")
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request,'tuning/index.html',{})
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
@@ -29,11 +34,12 @@ def loadTuningHome(request):
|
||||
def liteSpeedTuning(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
if admin.type == 3:
|
||||
return HttpResponse("You don't have enough privileges to access this page.")
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
return render(request,'tuning/liteSpeedTuning.html',{})
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
@@ -42,24 +48,14 @@ def liteSpeedTuning(request):
|
||||
def phpTuning(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
if admin.type == 3:
|
||||
return HttpResponse("You don't have enough privileges to access this page.")
|
||||
|
||||
admin = Administrator.objects.get(pk=request.session['userID'])
|
||||
|
||||
websites = Websites.objects.all()
|
||||
websitesName = []
|
||||
|
||||
for items in websites:
|
||||
websitesName.append(items.domain)
|
||||
|
||||
childs = ChildDomains.objects.all()
|
||||
|
||||
for items in childs:
|
||||
websitesName.append(items.domain)
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
|
||||
return render(request,'tuning/phpTuning.html',{'websiteList':websitesName})
|
||||
except KeyError:
|
||||
@@ -69,79 +65,76 @@ def phpTuning(request):
|
||||
def tuneLitespeed(request):
|
||||
|
||||
try:
|
||||
val = request.session['userID']
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('fetch_status', 0)
|
||||
try:
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
|
||||
if admin.type == 1:
|
||||
if request.method == 'POST':
|
||||
data = json.loads(request.body)
|
||||
status = data['status']
|
||||
if request.method == 'POST':
|
||||
data = json.loads(request.body)
|
||||
status = data['status']
|
||||
|
||||
if status == "fetch":
|
||||
|
||||
if status=="fetch":
|
||||
json_data = json.dumps(tuning.fetchTuningDetails())
|
||||
|
||||
json_data = json.dumps(tuning.fetchTuningDetails())
|
||||
data_ret = {'fetch_status': 1, 'error_message': "None", "tuning_data": json_data, 'tuneStatus': 0}
|
||||
|
||||
data_ret = {'fetch_status': 1, 'error_message': "None","tuning_data":json_data,'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
else:
|
||||
if not data['maxConn']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Max Connections", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
if not data['maxSSLConn']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Max SSL Connections", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
if not data['keepAlive']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Keep Alive", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
if not data['inMemCache']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Cache Size in memory", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
if not data['gzipCompression']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Enable GZIP Compression",
|
||||
'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
maxConn = data['maxConn']
|
||||
maxSSLConn = data['maxSSLConn']
|
||||
connTime = data['connTime']
|
||||
keepAlive = data['keepAlive']
|
||||
inMemCache = data['inMemCache']
|
||||
gzipCompression = data['gzipCompression']
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/tuning.py"
|
||||
|
||||
execPath = execPath + " saveTuningDetails --maxConn " + maxConn + " --maxSSLConn " + maxSSLConn + " --connTime " + connTime + " --keepAlive " + keepAlive + " --inMemCache '" + inMemCache + "' --gzipCompression " + gzipCompression
|
||||
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "None", 'tuneStatus': 1}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
if not data['maxConn']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Max Connections", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
if not data['maxSSLConn']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Max SSL Connections", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
if not data['keepAlive']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Keep Alive", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
if not data['inMemCache']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Cache Size in memory", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
||||
if not data['gzipCompression']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Enable GZIP Compression", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
||||
maxConn = data['maxConn']
|
||||
maxSSLConn = data['maxSSLConn']
|
||||
connTime = data['connTime']
|
||||
keepAlive = data['keepAlive']
|
||||
inMemCache = data['inMemCache']
|
||||
gzipCompression = data['gzipCompression']
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/tuning.py"
|
||||
|
||||
execPath = execPath + " saveTuningDetails --maxConn " + maxConn + " --maxSSLConn " + maxSSLConn + " --connTime " + connTime + " --keepAlive " + keepAlive + " --inMemCache '" + inMemCache + "' --gzipCompression " + gzipCompression
|
||||
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "None", 'tuneStatus': 1}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "None", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
else:
|
||||
data_ret = {'fetch_status': 0, 'error_message': "You don't have enough privileges.", 'tuneStatus': 0}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
data_ret = {'fetch_status': 1, 'error_message': "None", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException,msg:
|
||||
data_ret = {'fetch_status': 0, 'error_message': str(msg), 'tuneStatus': 0}
|
||||
@@ -156,57 +149,53 @@ def tuneLitespeed(request):
|
||||
|
||||
def tunePHP(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('fetch_status', 0)
|
||||
try:
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
if admin.type == 1:
|
||||
if request.method == 'POST':
|
||||
data = json.loads(request.body)
|
||||
status = data['status']
|
||||
domainSelection = str(data['domainSelection'])
|
||||
if request.method == 'POST':
|
||||
data = json.loads(request.body)
|
||||
status = data['status']
|
||||
domainSelection = str(data['domainSelection'])
|
||||
|
||||
if status=="fetch":
|
||||
if status == "fetch":
|
||||
|
||||
json_data = json.dumps(tuning.fetchPHPDetails(domainSelection))
|
||||
json_data = json.dumps(tuning.fetchPHPDetails(domainSelection))
|
||||
|
||||
data_ret = {'fetch_status': 1, 'error_message': "None","tuning_data":json_data,'tuneStatus': 0}
|
||||
data_ret = {'fetch_status': 1, 'error_message': "None", "tuning_data": json_data, 'tuneStatus': 0}
|
||||
|
||||
final_json = json.dumps(data_ret)
|
||||
|
||||
return HttpResponse(final_json)
|
||||
|
||||
else:
|
||||
initTimeout = str(data['initTimeout'])
|
||||
maxConns = str(data['maxConns'])
|
||||
memSoftLimit = data['memSoftLimit']
|
||||
memHardLimit = data['memHardLimit']
|
||||
procSoftLimit = str(data['procSoftLimit'])
|
||||
procHardLimit = str(data['procHardLimit'])
|
||||
persistConn = data['persistConn']
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/tuning.py"
|
||||
|
||||
execPath = execPath + " tunePHP --virtualHost " + domainSelection + " --initTimeout " + initTimeout + " --maxConns " + maxConns + " --memSoftLimit " + memSoftLimit + " --memHardLimit '" + memHardLimit + "' --procSoftLimit " + procSoftLimit + " --procHardLimit " + procHardLimit + " --persistConn " + persistConn
|
||||
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'tuneStatus': 1, 'fetch_status': 0, 'error_message': "None"}
|
||||
final_json = json.dumps(data_ret)
|
||||
|
||||
return HttpResponse(final_json)
|
||||
|
||||
else:
|
||||
initTimeout = str(data['initTimeout'])
|
||||
maxConns = str(data['maxConns'])
|
||||
memSoftLimit = data['memSoftLimit']
|
||||
memHardLimit = data['memHardLimit']
|
||||
procSoftLimit = str(data['procSoftLimit'])
|
||||
procHardLimit = str(data['procHardLimit'])
|
||||
persistConn = data['persistConn']
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/tuning.py"
|
||||
|
||||
execPath = execPath + " tunePHP --virtualHost " + domainSelection +" --initTimeout " + initTimeout + " --maxConns " + maxConns + " --memSoftLimit " + memSoftLimit + " --memHardLimit '" + memHardLimit + "' --procSoftLimit " + procSoftLimit + " --procHardLimit " + procHardLimit + " --persistConn " + persistConn
|
||||
|
||||
|
||||
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'tuneStatus': 1,'fetch_status': 0, 'error_message': "None"}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
data_ret = {'fetch_status': 0, 'error_message': output, 'tuneStatus': 0}
|
||||
logging.CyberCPLogFileWriter.writeToFile(output + " [tunePHP]]")
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
data_ret = {'fetch_status': 0, 'error_message': "You don't have enough privileges.", 'tuneStatus': 0}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
data_ret = {'fetch_status': 0, 'error_message': output, 'tuneStatus': 0}
|
||||
logging.CyberCPLogFileWriter.writeToFile(output + " [tunePHP]]")
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException,msg:
|
||||
data_ret = {'fetch_status': 0, 'error_message': str(msg),'tuneStatus': 0}
|
||||
|
||||
@@ -25,6 +25,7 @@ from plogical.mailUtilities import mailUtilities
|
||||
from plogical.applicationInstaller import ApplicationInstaller
|
||||
import time
|
||||
from plogical.acl import ACLManager
|
||||
from plogical.alias import AliasManager
|
||||
# Create your views here.
|
||||
|
||||
def loadWebsitesHome(request):
|
||||
@@ -1064,14 +1065,6 @@ def saveSSL(request):
|
||||
data = json.loads(request.body)
|
||||
domain = data['virtualHost']
|
||||
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
try:
|
||||
website = ChildDomains.objects.get(domain=domain)
|
||||
except:
|
||||
website = Websites.objects.get(domain=domain)
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
## writing data temporary to file
|
||||
@@ -1089,55 +1082,24 @@ def saveSSL(request):
|
||||
|
||||
## writing data temporary to file
|
||||
|
||||
pathToStoreSSL = virtualHostUtilities.Server_root + "/conf/vhosts/" + "SSL-" + domain
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
if website.ssl == 0:
|
||||
## save configuration data
|
||||
execPath = execPath + " saveSSL --virtualHostName " + domain + " --tempKeyPath " + tempKeyPath + " --tempCertPath " + tempCertPath
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
execPath = execPath + " saveSSL --virtualHostName " + domain + " --path " + pathToStoreSSL + " --tempKeyPath " + tempKeyPath + " --tempCertPath " + tempCertPath + " --sslCheck 0"
|
||||
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
website.ssl = 1
|
||||
website.save()
|
||||
data_ret = {'sslStatus': 1, 'error_message': "None"}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
output)
|
||||
data_ret = {'sslStatus': 0, 'error_message': output}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
## save configuration data ends
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'sslStatus': 1, 'error_message': "None"}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
## save configuration data
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
output)
|
||||
data_ret = {'sslStatus': 0, 'error_message': output}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
execPath = execPath + " saveSSL --virtualHostName " + domain + " --path " + pathToStoreSSL + " --tempKeyPath " + tempKeyPath + " --tempCertPath " + tempCertPath + " --sslCheck 1"
|
||||
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
website.ssl = 1
|
||||
website.save()
|
||||
data_ret = {'sslStatus': 1, 'error_message': "None"}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
output)
|
||||
data_ret = {'sslStatus': 0, 'error_message': output}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
## save configuration data ends
|
||||
## save configuration data ends
|
||||
|
||||
|
||||
except BaseException,msg:
|
||||
@@ -1568,22 +1530,24 @@ def addNewCron(request):
|
||||
final_json = json.dumps(status)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def domainAlias(request,domain):
|
||||
def domainAlias(request, domain):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
try:
|
||||
website = Websites.objects.get(domain=domain)
|
||||
|
||||
finalAlisList = []
|
||||
noAlias = 0
|
||||
if ACLManager.checkOwnership(domain, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
|
||||
aliasManager = AliasManager(domain)
|
||||
noAlias, finalAlisList = aliasManager.fetchAlisForDomains()
|
||||
|
||||
path = "/home/" + domain + "/public_html"
|
||||
|
||||
aliases = website.aliasdomains_set.all()
|
||||
|
||||
for items in aliases:
|
||||
finalAlisList.append(items.aliasDomain)
|
||||
noAlias = 1
|
||||
|
||||
return render(request, 'websiteFunctions/domainAlias.html', {
|
||||
'masterDomain': domain,
|
||||
'aliases':finalAlisList,
|
||||
@@ -1599,16 +1563,23 @@ def domainAlias(request,domain):
|
||||
def submitAliasCreation(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
if request.method == 'POST':
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.checkOwnership(domain, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
|
||||
data = json.loads(request.body)
|
||||
|
||||
masterDomain = data['masterDomain']
|
||||
aliasDomain = data['aliasDomain']
|
||||
ssl = data['ssl']
|
||||
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
sslpath = "/home/" + masterDomain + "/public_html"
|
||||
|
||||
## Create Configurations
|
||||
@@ -1633,8 +1604,6 @@ def submitAliasCreation(request):
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'createAliasStatus': 0, 'error_message': str(msg), "existsStatus": 0}
|
||||
json_data = json.dumps(data_ret)
|
||||
|
||||
Reference in New Issue
Block a user