mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-10-26 07:46:35 +01:00
code refactoring
This commit is contained in:
@@ -36,12 +36,11 @@ class cyberPanel:
|
||||
|
||||
def createWebsite(self, package, owner, domainName, email, php, ssl, dkim, openBasedir):
|
||||
try:
|
||||
|
||||
externalApp = "".join(re.findall("[a-zA-Z]+", domainName))[:7]
|
||||
numberOfWebsites = Websites.objects.count() + ChildDomains.objects.count()
|
||||
sslpath = "/home/" + domainName + "/public_html"
|
||||
phpSelection = 'PHP ' + php
|
||||
|
||||
result = virtualHostUtilities.createVirtualHost(domainName, email, phpSelection, externalApp, numberOfWebsites, ssl, sslpath, dkim,
|
||||
result = virtualHostUtilities.createVirtualHost(domainName, email, phpSelection, externalApp, ssl, dkim,
|
||||
openBasedir, owner, package)
|
||||
|
||||
if result[0] == 1:
|
||||
@@ -59,7 +58,7 @@ class cyberPanel:
|
||||
path = '/home/' + masterDomain + '/public_html/' + domainName
|
||||
phpSelection = 'PHP ' + php
|
||||
|
||||
result = virtualHostUtilities.createDomain(masterDomain, domainName, phpSelection, path, ssl, dkim, openBasedir, '0', owner)
|
||||
result = virtualHostUtilities.createDomain(masterDomain, domainName, phpSelection, path, ssl, dkim, openBasedir, owner)
|
||||
|
||||
if result[0] == 1:
|
||||
self.printStatus(1,'None')
|
||||
|
||||
@@ -36,3 +36,13 @@ class CyberCPLogFileWriter:
|
||||
|
||||
except subprocess.CalledProcessError,msg:
|
||||
return "File was empty"
|
||||
|
||||
@staticmethod
|
||||
def statusWriter(tempStatusPath, mesg):
|
||||
try:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines(mesg)
|
||||
statusFile.close()
|
||||
except BaseException, msg:
|
||||
CyberCPLogFileWriter.writeToFile(str(msg) + ' [statusWriter]')
|
||||
|
||||
|
||||
@@ -203,7 +203,6 @@ class backupUtilities:
|
||||
except BaseException, msg:
|
||||
return 0,str(msg)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def startBackup(tempStoragePath,backupName,backupPath):
|
||||
try:
|
||||
@@ -264,13 +263,11 @@ class backupUtilities:
|
||||
##### Saving SSL Certificates if any
|
||||
|
||||
try:
|
||||
pathToStoreSSL = sslUtilities.Server_root + "/conf/vhosts/" + "SSL-" + domainName
|
||||
if os.path.exists(pathToStoreSSL):
|
||||
pathToStoreSSLPrivKey = pathToStoreSSL + "/privkey.pem"
|
||||
pathToStoreSSLFullChain = pathToStoreSSL + "/fullchain.pem"
|
||||
sslStoragePath = '/etc/letsencrypt/live/' + domainName
|
||||
|
||||
copy(pathToStoreSSLPrivKey, tempStoragePath + "/privkey.pem")
|
||||
copy(pathToStoreSSLFullChain, tempStoragePath + "/fullchain.pem")
|
||||
if os.path.exists(sslStoragePath):
|
||||
make_archive(os.path.join(tempStoragePath, "sslData-" + domainName), 'gztar',
|
||||
sslStoragePath)
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
||||
|
||||
@@ -285,20 +282,11 @@ class backupUtilities:
|
||||
|
||||
actualChildDomain = childDomain.find('domain').text
|
||||
|
||||
pathToStoreSSL = sslUtilities.Server_root + "/conf/vhosts/" + "SSL-" + actualChildDomain
|
||||
|
||||
if os.path.exists(pathToStoreSSL):
|
||||
pathToStoreSSLPrivKey = pathToStoreSSL + "/privkey.pem"
|
||||
pathToStoreSSLFullChain = pathToStoreSSL + "/fullchain.pem"
|
||||
|
||||
tempKeyPath = os.path.join(tempStoragePath, actualChildDomain)
|
||||
|
||||
if not os.path.exists(tempKeyPath):
|
||||
os.mkdir(tempKeyPath)
|
||||
|
||||
copy(pathToStoreSSLPrivKey, tempKeyPath + "/privkey.pem")
|
||||
copy(pathToStoreSSLFullChain, tempKeyPath + "/fullchain.pem")
|
||||
sslStoragePath = '/etc/letsencrypt/live/' + actualChildDomain
|
||||
|
||||
if os.path.exists(sslStoragePath):
|
||||
make_archive(os.path.join(tempStoragePath, "sslData-" + actualChildDomain), 'gztar',
|
||||
sslStoragePath)
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
||||
|
||||
@@ -381,12 +369,10 @@ class backupUtilities:
|
||||
|
||||
####### Pre-creation checks ends
|
||||
|
||||
numberOfWebsites = Websites.objects.count() + ChildDomains.objects.count()
|
||||
|
||||
## Create Configurations
|
||||
|
||||
result = virtualHostUtilities.createVirtualHost(domain, admin.email, phpSelection, externalApp,
|
||||
numberOfWebsites, 0, 'CyberPanel', 1, 0,
|
||||
result = virtualHostUtilities.createVirtualHost(domain, admin.email, phpSelection, externalApp, 0, 1, 0,
|
||||
admin.userName, 'Default')
|
||||
|
||||
if result[0] == 0:
|
||||
@@ -489,24 +475,15 @@ class backupUtilities:
|
||||
if result[0] == 1:
|
||||
## Let us try to restore SSL.
|
||||
|
||||
if os.path.exists(completPath + "/privkey.pem"):
|
||||
|
||||
pathToStoreSSL = sslUtilities.Server_root + "/conf/vhosts/" + "SSL-" + masterDomain
|
||||
|
||||
if not os.path.exists(pathToStoreSSL):
|
||||
os.mkdir(pathToStoreSSL)
|
||||
sslStoragePath = completPath + "/sslData-" + masterDomain + '.tar.gz'
|
||||
|
||||
if os.path.exists(sslStoragePath):
|
||||
sslHome = '/etc/letsencrypt/live/' + masterDomain
|
||||
tar = tarfile.open(sslStoragePath)
|
||||
tar.extractall(sslHome)
|
||||
tar.close()
|
||||
sslUtilities.installSSLForDomain(masterDomain)
|
||||
|
||||
pathToStoreSSLPrivKey = pathToStoreSSL + "/privkey.pem"
|
||||
pathToStoreSSLFullChain = pathToStoreSSL + "/fullchain.pem"
|
||||
|
||||
copy(completPath + "/privkey.pem", pathToStoreSSLPrivKey)
|
||||
copy(completPath + "/fullchain.pem", pathToStoreSSLFullChain)
|
||||
|
||||
command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + pathToStoreSSL
|
||||
cmd = shlex.split(command)
|
||||
subprocess.call(cmd)
|
||||
else:
|
||||
status = open(os.path.join(completPath, 'status'), "w")
|
||||
status.write("Error Message: " + result[1] +
|
||||
@@ -537,50 +514,32 @@ class backupUtilities:
|
||||
phpSelection = childDomain.find('phpSelection').text
|
||||
path = childDomain.find('path').text
|
||||
|
||||
finalData = json.dumps(
|
||||
{'masterDomain': masterDomain, 'domainName': domain, 'phpSelection': phpSelection,
|
||||
'path': path,
|
||||
'ssl': 0, 'restore': 1,
|
||||
'dkimCheck': 0,
|
||||
'openBasedir':0})
|
||||
r = requests.post("http://localhost:5003/websites/submitDomainCreation", data=finalData,
|
||||
verify=False)
|
||||
retValues = virtualHostUtilities.createDomain(masterDomain, domain, phpSelection, path, 0, 0, 0, 'admin')
|
||||
|
||||
data = json.loads(r.text)
|
||||
|
||||
if data['createWebSiteStatus'] == 1:
|
||||
if retValues[0] == 1:
|
||||
rmtree(websiteHome)
|
||||
|
||||
## Let us try to restore SSL for Child Domains.
|
||||
|
||||
tempPath = os.path.join(completPath, domain)
|
||||
try:
|
||||
sslStoragePath = completPath + "/sslData-" + domain + '.tar.gz'
|
||||
|
||||
if os.path.exists(tempPath + "/privkey.pem"):
|
||||
if os.path.exists(sslStoragePath):
|
||||
sslHome = '/etc/letsencrypt/live/' + domain
|
||||
tar = tarfile.open(sslStoragePath)
|
||||
tar.extractall(sslHome)
|
||||
tar.close()
|
||||
sslUtilities.installSSLForDomain(domain)
|
||||
except:
|
||||
logging.CyberCPLogFileWriter.writeToFile('While restoring backup we had minor issues for rebuilding vhost conf for: ' + domain + '. However this will be auto healed.')
|
||||
|
||||
pathToStoreSSL = sslUtilities.Server_root + "/conf/vhosts/" + "SSL-" + domain
|
||||
|
||||
if not os.path.exists(pathToStoreSSL):
|
||||
os.mkdir(pathToStoreSSL)
|
||||
|
||||
sslUtilities.installSSLForDomain(domain)
|
||||
|
||||
pathToStoreSSLPrivKey = pathToStoreSSL + "/privkey.pem"
|
||||
pathToStoreSSLFullChain = pathToStoreSSL + "/fullchain.pem"
|
||||
|
||||
copy(tempPath + "/privkey.pem", pathToStoreSSLPrivKey)
|
||||
copy(tempPath + "/fullchain.pem", pathToStoreSSLFullChain)
|
||||
|
||||
command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + pathToStoreSSL
|
||||
cmd = shlex.split(command)
|
||||
|
||||
continue
|
||||
else:
|
||||
status = open(os.path.join(completPath,'status'), "w")
|
||||
status.write("Error Message: " + data[
|
||||
'error_message'] + ". Not able to create child domains, aborting. [5009]")
|
||||
status.write("Error Message: " + retValues[1] + ". Not able to create child domains, aborting. [5009]")
|
||||
status.close()
|
||||
return 0
|
||||
|
||||
except BaseException, msg:
|
||||
status = open(os.path.join(completPath,'status'), "w")
|
||||
status.write("Error Message: " + str(msg) +". Not able to create child domains, aborting. [5009]")
|
||||
@@ -909,7 +868,6 @@ class backupUtilities:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [verifyHostKey]")
|
||||
return [0,str(msg)+" [verifyHostKey]"]
|
||||
|
||||
|
||||
@staticmethod
|
||||
def createBackupDir(IPAddress,port):
|
||||
|
||||
|
||||
@@ -32,13 +32,9 @@ class sslUtilities:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [IO Error with main config file [checkIfSSLMap]]")
|
||||
return 0
|
||||
|
||||
|
||||
@staticmethod
|
||||
def installSSLForDomain(virtualHostName):
|
||||
|
||||
|
||||
pathToStoreSSL = sslUtilities.Server_root + "/conf/vhosts/" + "SSL-" + virtualHostName
|
||||
|
||||
confPath = sslUtilities.Server_root + "/conf/vhosts/" + virtualHostName
|
||||
completePathToConfigFile = confPath + "/vhost.conf"
|
||||
|
||||
@@ -52,8 +48,8 @@ class sslUtilities:
|
||||
listener = "listener SSL {" + "\n"
|
||||
address = " address *:443" + "\n"
|
||||
secure = " secure 1" + "\n"
|
||||
keyFile = " keyFile " + pathToStoreSSL + "/privkey.pem" + "\n"
|
||||
certFile = " certFile " + pathToStoreSSL + "/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"
|
||||
@@ -110,8 +106,8 @@ class sslUtilities:
|
||||
writeSSLConfig = open(completePathToConfigFile,"a")
|
||||
|
||||
vhssl = "vhssl {" + "\n"
|
||||
keyFile = " keyFile " + pathToStoreSSL + "/privkey.pem" + "\n"
|
||||
certFile = " certFile " + pathToStoreSSL + "/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"
|
||||
final = "}"
|
||||
@@ -136,7 +132,6 @@ class sslUtilities:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installSSLForDomain]]")
|
||||
return 0
|
||||
|
||||
|
||||
@staticmethod
|
||||
def checkSSLListener():
|
||||
try:
|
||||
@@ -162,7 +157,6 @@ class sslUtilities:
|
||||
except BaseException, msg:
|
||||
return [0, "347 " + str(msg) + " [issueSSLForDomain]"]
|
||||
|
||||
|
||||
@staticmethod
|
||||
def obtainSSLForADomain(virtualHostName,adminEmail,sslpath, aliasDomain = None):
|
||||
try:
|
||||
@@ -176,6 +170,10 @@ class sslUtilities:
|
||||
|
||||
if aliasDomain == None:
|
||||
|
||||
existingCertPath = '/etc/letsencrypt/live/' + virtualHostName + '/README'
|
||||
if os.path.exists(existingCertPath):
|
||||
return 1
|
||||
|
||||
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
|
||||
@@ -196,48 +194,14 @@ class sslUtilities:
|
||||
logging.CyberCPLogFileWriter.writeToFile('Failed to obtain SSL, issuing self-signed SSL for: ' + virtualHostName)
|
||||
return 0
|
||||
|
||||
pathToStoreSSL = sslUtilities.Server_root + "/conf/vhosts/" + "SSL-" + virtualHostName
|
||||
|
||||
if not os.path.exists(pathToStoreSSL):
|
||||
os.mkdir(pathToStoreSSL)
|
||||
|
||||
pathToStoreSSLPrivKey = pathToStoreSSL + "/privkey.pem"
|
||||
pathToStoreSSLFullChain = pathToStoreSSL + "/fullchain.pem"
|
||||
|
||||
##
|
||||
|
||||
if output.find('Congratulations!') > -1:
|
||||
|
||||
###### Copy SSL To config location ######
|
||||
|
||||
srcPrivKey = "/etc/letsencrypt/live/" + virtualHostName + "/privkey.pem"
|
||||
srcFullChain = "/etc/letsencrypt/live/" + virtualHostName + "/fullchain.pem"
|
||||
|
||||
if os.path.exists(pathToStoreSSLPrivKey):
|
||||
os.remove(pathToStoreSSLPrivKey)
|
||||
if os.path.exists(pathToStoreSSLFullChain):
|
||||
os.remove(pathToStoreSSLFullChain)
|
||||
|
||||
shutil.copy(srcPrivKey, pathToStoreSSLPrivKey)
|
||||
shutil.copy(srcFullChain, pathToStoreSSLFullChain)
|
||||
|
||||
return 1
|
||||
|
||||
elif output.find('no action taken.') > -1:
|
||||
|
||||
###### Copy SSL To config location ######
|
||||
|
||||
srcPrivKey = "/etc/letsencrypt/live/" + virtualHostName + "/privkey.pem"
|
||||
srcFullChain = "/etc/letsencrypt/live/" + virtualHostName + "/fullchain.pem"
|
||||
|
||||
if os.path.exists(pathToStoreSSLPrivKey):
|
||||
os.remove(pathToStoreSSLPrivKey)
|
||||
if os.path.exists(pathToStoreSSLFullChain):
|
||||
os.remove(pathToStoreSSLFullChain)
|
||||
|
||||
shutil.copy(srcPrivKey, pathToStoreSSLPrivKey)
|
||||
shutil.copy(srcFullChain, pathToStoreSSLFullChain)
|
||||
|
||||
return 1
|
||||
elif output.find('Failed authorization procedure') > -1:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
@@ -301,43 +265,10 @@ class sslUtilities:
|
||||
"Failed to obtain DNS records for " + virtualHostName + ", issuing self signed certificate.")
|
||||
return 0
|
||||
|
||||
## SSL Paths
|
||||
|
||||
pathToStoreSSL = sslUtilities.Server_root + "/conf/vhosts/" + "SSL-" + virtualHostName
|
||||
|
||||
if not os.path.exists(pathToStoreSSL):
|
||||
os.mkdir(pathToStoreSSL)
|
||||
|
||||
pathToStoreSSLPrivKey = pathToStoreSSL + "/privkey.pem"
|
||||
pathToStoreSSLFullChain = pathToStoreSSL + "/fullchain.pem"
|
||||
|
||||
|
||||
##
|
||||
|
||||
output = subprocess.check_output(shlex.split(command))
|
||||
|
||||
data = output.split('\n')
|
||||
|
||||
if output.find('Congratulations!') > -1:
|
||||
|
||||
###### Copy SSL To config location ######
|
||||
|
||||
|
||||
for items in data:
|
||||
if items.find(virtualHostName) > -1 and items.find('fullchain.pem') > -1:
|
||||
srcFullChain = items.strip(' ')
|
||||
elif items.find(virtualHostName) > -1 and items.find('privkey.pem') > -1:
|
||||
srcPrivKey = items.strip(' ')
|
||||
|
||||
|
||||
if os.path.exists(pathToStoreSSLPrivKey):
|
||||
os.remove(pathToStoreSSLPrivKey)
|
||||
if os.path.exists(pathToStoreSSLFullChain):
|
||||
os.remove(pathToStoreSSLFullChain)
|
||||
|
||||
shutil.copy(srcPrivKey, pathToStoreSSLPrivKey)
|
||||
shutil.copy(srcFullChain, pathToStoreSSLFullChain)
|
||||
|
||||
return 1
|
||||
|
||||
elif output.find('no action taken.') > -1:
|
||||
@@ -370,8 +301,8 @@ def issueSSLForDomain(domain, adminEmail, sslpath, aliasDomain = None):
|
||||
if not os.path.exists(pathToStoreSSL):
|
||||
os.mkdir(pathToStoreSSL)
|
||||
|
||||
pathToStoreSSLPrivKey = pathToStoreSSL + "/privkey.pem"
|
||||
pathToStoreSSLFullChain = pathToStoreSSL + "/fullchain.pem"
|
||||
pathToStoreSSLPrivKey = "/etc/letsencrypt/live/" + domain + "/privkey.pem"
|
||||
pathToStoreSSLFullChain = "/etc/letsencrypt/live/" + domain + "/fullchain.pem"
|
||||
|
||||
command = 'openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout ' + pathToStoreSSLPrivKey + ' -out ' + pathToStoreSSLFullChain
|
||||
cmd = shlex.split(command)
|
||||
|
||||
@@ -307,7 +307,7 @@ WantedBy=multi-user.target"""
|
||||
cwd = os.getcwd()
|
||||
os.chdir('/usr/local/CyberCP')
|
||||
|
||||
command = "echo 'CREATE TABLE `loginSystem_acl` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(50) NOT NULL UNIQUE, `adminStatus` integer NOT NULL, `versionManagement` integer NOT NULL, `createNewUser` integer NOT NULL, `deleteUser` integer NOT NULL, `resellerCenter` integer NOT NULL, `changeUserACL` integer NOT NULL, `createWebsite` integer NOT NULL, `modifyWebsite` integer NOT NULL, `suspendWebsite` integer NOT NULL, `deleteWebsite` integer NOT NULL, `createPackage` integer NOT NULL, `deletePackage` integer NOT NULL, `modifyPackage` integer NOT NULL, `createDatabase` integer NOT NULL, `deleteDatabase` integer NOT NULL, `listDatabases` integer NOT NULL, `createNameServer` integer NOT NULL, `createDNSZone` integer NOT NULL, `deleteZone` integer NOT NULL, `addDeleteRecords` integer NOT NULL, `createEmail` integer NOT NULL, `deleteEmail` integer NOT NULL, `emailForwarding` integer NOT NULL, `changeEmailPassword` integer NOT NULL, `dkimManager` integer NOT NULL, `createFTPAccount` integer NOT NULL, `deleteFTPAccount` integer NOT NULL, `listFTPAccounts` integer NOT NULL, `createBackup` integer NOT NULL, `restoreBackup` integer NOT NULL, `addDeleteDestinations` integer NOT NULL, `scheDuleBackups` integer NOT NULL, `remoteBackups` integer NOT NULL, `manageSSL` integer NOT NULL, `hostnameSSL` integer NOT NULL, `mailServerSSL` integer NOT NULL);' | python manage.py dbshell"
|
||||
command = "echo 'CREATE TABLE `loginSystem_acl` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(50) NOT NULL UNIQUE, `adminStatus` integer NOT NULL DEFAULT 0, `versionManagement` integer NOT NULL DEFAULT 0, `createNewUser` integer NOT NULL DEFAULT 0, `deleteUser` integer NOT NULL DEFAULT 0, `resellerCenter` integer NOT NULL DEFAULT 0, `changeUserACL` integer NOT NULL DEFAULT 0, `createWebsite` integer NOT NULL DEFAULT 0, `modifyWebsite` integer NOT NULL DEFAULT 0, `suspendWebsite` integer NOT NULL DEFAULT 0, `deleteWebsite` integer NOT NULL DEFAULT 0, `createPackage` integer NOT NULL DEFAULT 0, `deletePackage` integer NOT NULL DEFAULT 0, `modifyPackage` integer NOT NULL DEFAULT 0, `createDatabase` integer NOT NULL DEFAULT 0, `deleteDatabase` integer NOT NULL DEFAULT 0, `listDatabases` integer NOT NULL DEFAULT 0, `createNameServer` integer NOT NULL DEFAULT 0, `createDNSZone` integer NOT NULL DEFAULT 0, `deleteZone` integer NOT NULL DEFAULT 0, `addDeleteRecords` integer NOT NULL DEFAULT 0, `createEmail` integer NOT NULL DEFAULT 0, `deleteEmail` integer NOT NULL DEFAULT 0, `emailForwarding` integer NOT NULL DEFAULT 0, `changeEmailPassword` integer NOT NULL DEFAULT 0, `dkimManager` integer NOT NULL DEFAULT 0, `createFTPAccount` integer NOT NULL DEFAULT 0, `deleteFTPAccount` integer NOT NULL DEFAULT 0, `listFTPAccounts` integer NOT NULL DEFAULT 0, `createBackup` integer NOT NULL DEFAULT 0, `restoreBackup` integer NOT NULL DEFAULT 0, `addDeleteDestinations` integer NOT NULL DEFAULT 0, `scheDuleBackups` integer NOT NULL DEFAULT 0, `remoteBackups` integer NOT NULL DEFAULT 0, `manageSSL` integer NOT NULL DEFAULT 0, `hostnameSSL` integer NOT NULL DEFAULT 0, `mailServerSSL` integer NOT NULL DEFAULT 0);' | python manage.py dbshell"
|
||||
subprocess.check_output(command, shell=True)
|
||||
|
||||
command = "echo 'ALTER TABLE loginSystem_administrator ADD acl_id integer;' | python manage.py dbshell"
|
||||
|
||||
@@ -170,7 +170,6 @@ class vhost:
|
||||
else:
|
||||
return [0,"[61 Not able to create per host virtual configurations [perHostVirtualConf]"]
|
||||
|
||||
|
||||
@staticmethod
|
||||
def perHostVirtualConf(vhFile, administratorEmail,virtualHostUser, phpVersion, virtualHostName, openBasedir):
|
||||
# General Configurations tab
|
||||
@@ -498,18 +497,12 @@ RewriteFile .htaccess
|
||||
def deleteCoreConf(virtualHostName, numberOfSites):
|
||||
|
||||
virtualHostPath = "/home/" + virtualHostName
|
||||
try:
|
||||
if os.path.exists(virtualHostPath):
|
||||
shutil.rmtree(virtualHostPath)
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [Not able to remove virtual host directory from /home continuing..]")
|
||||
|
||||
try:
|
||||
confPath = vhost.Server_root + "/conf/vhosts/" + virtualHostName
|
||||
confPath = vhost.Server_root + "/conf/vhosts/" + virtualHostName
|
||||
if os.path.exists(confPath):
|
||||
shutil.rmtree(confPath)
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [Not able to remove virtual host configuration directory from /conf ]")
|
||||
|
||||
try:
|
||||
data = open("/usr/local/lsws/conf/httpd_config.conf").readlines()
|
||||
@@ -545,7 +538,6 @@ RewriteFile .htaccess
|
||||
writeDataToFile.writelines(items)
|
||||
if (items.find("}") > -1 and check == 0):
|
||||
check = 1
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [Not able to remove virtual host configuration from main configuration file.]")
|
||||
@@ -751,7 +743,6 @@ RewriteFile .htaccess
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createAliasSSLMap]")
|
||||
|
||||
|
||||
## Child Domain Functions
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -13,7 +13,6 @@ import sslUtilities
|
||||
from os.path import join
|
||||
from os import listdir, rmdir
|
||||
from shutil import move
|
||||
import randomPassword as randomPassword
|
||||
from multiprocessing import Process
|
||||
from websiteFunctions.models import Websites, ChildDomains
|
||||
from loginSystem.models import Administrator
|
||||
@@ -25,6 +24,7 @@ import CyberCPLogFileWriter as logging
|
||||
from dnsUtilities import DNS
|
||||
from vhost import vhost
|
||||
from applicationInstaller import ApplicationInstaller
|
||||
from acl import ACLManager
|
||||
|
||||
|
||||
## If you want justice, you have come to the wrong place.
|
||||
@@ -35,55 +35,48 @@ class virtualHostUtilities:
|
||||
Server_root = "/usr/local/lsws"
|
||||
cyberPanel = "/usr/local/CyberCP"
|
||||
@staticmethod
|
||||
def createVirtualHost(virtualHostName, administratorEmail, phpVersion, virtualHostUser, numberOfSites, ssl, sslPath,
|
||||
def createVirtualHost(virtualHostName, administratorEmail, phpVersion, virtualHostUser, ssl,
|
||||
dkimCheck, openBasedir, websiteOwner, packageName, tempStatusPath = '/home/cyberpanel/fakePath'):
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Running some checks..,0')
|
||||
statusFile.close()
|
||||
|
||||
try:
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Running some checks..,0')
|
||||
|
||||
####### Limitations check
|
||||
|
||||
admin = Administrator.objects.get(userName=websiteOwner)
|
||||
|
||||
if ACLManager.websitesLimitCheck(admin, 1) == 0:
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'You\'ve reached maximum websites limit as a reseller. [404]')
|
||||
return 0, 'You\'ve reached maximum websites limit as a reseller.'
|
||||
|
||||
####### Limitations Check End
|
||||
|
||||
if Websites.objects.filter(domain=virtualHostName).count() > 0:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("This website already exists. [404]")
|
||||
statusFile.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'This website already exists. [404]')
|
||||
return 0, "This website already exists."
|
||||
|
||||
if ChildDomains.objects.filter(domain=virtualHostName).count() > 0:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("This website already exists as child domain. [404]")
|
||||
statusFile.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'This website already exists as child domain. [404]')
|
||||
return 0, "This website already exists as child domain."
|
||||
|
||||
####### Limitations Check End
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Creating DNS records..,10')
|
||||
statusFile.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Creating DNS records..,10')
|
||||
|
||||
##### Zone creation
|
||||
|
||||
admin = Administrator.objects.get(userName=websiteOwner)
|
||||
|
||||
DNS.dnsTemplate(virtualHostName, admin)
|
||||
|
||||
## zone creation
|
||||
## Zone creation
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Setting up directories..,25')
|
||||
statusFile.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Setting up directories..,25')
|
||||
|
||||
if vhost.checkIfVirtualHostExists(virtualHostName) == 1:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("Virtual Host Directory already exists. [404]")
|
||||
statusFile.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Virtual Host Directory already exists. [404]')
|
||||
return 0, "Virtual Host Directory already exists!"
|
||||
|
||||
if vhost.checkIfAliasExists(virtualHostName) == 1:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("This domain exists as Alias. [404]")
|
||||
statusFile.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'This domain exists as Alias. [404]')
|
||||
return 0, "This domain exists as Alias."
|
||||
|
||||
if dkimCheck == 1:
|
||||
@@ -99,19 +92,16 @@ class virtualHostUtilities:
|
||||
if retValues[0] == 0:
|
||||
raise BaseException(retValues[1])
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Creating configurations..,50')
|
||||
statusFile.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Creating configurations..,50')
|
||||
|
||||
retValues = vhost.createConfigInMainVirtualHostFile(virtualHostName)
|
||||
if retValues[0] == 0:
|
||||
raise BaseException(retValues[1])
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Setting up SSL..,70')
|
||||
statusFile.close()
|
||||
|
||||
if ssl == 1:
|
||||
sslPath = "/home/" + virtualHostName + "/public_html"
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Setting up SSL..,70')
|
||||
installUtilities.installUtilities.reStartLiteSpeed()
|
||||
retValues = sslUtilities.issueSSLForDomain(virtualHostName, administratorEmail, sslPath)
|
||||
if retValues[0] == 0:
|
||||
@@ -126,9 +116,8 @@ class virtualHostUtilities:
|
||||
|
||||
## Create Configurations ends here
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('DKIM Setup..,90')
|
||||
statusFile.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'DKIM Setup..,90')
|
||||
|
||||
|
||||
## DKIM Check
|
||||
|
||||
@@ -143,17 +132,15 @@ class virtualHostUtilities:
|
||||
|
||||
website.save()
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("Website successfully created. [200]")
|
||||
statusFile.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Website successfully created. [200]')
|
||||
|
||||
return 1, 'None'
|
||||
|
||||
except BaseException, msg:
|
||||
vhost.deleteVirtualHostConfigurations(virtualHostName, numberOfSites)
|
||||
numberOfWebsites = str(Websites.objects.count() + ChildDomains.objects.count())
|
||||
vhost.deleteVirtualHostConfigurations(virtualHostName, numberOfWebsites)
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createVirtualHost]")
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines(str(msg) + " [404]")
|
||||
statusFile.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, str(msg) + " [404]")
|
||||
return 0, str(msg)
|
||||
|
||||
@staticmethod
|
||||
@@ -450,11 +437,6 @@ class virtualHostUtilities:
|
||||
|
||||
FNULL = open(os.devnull, 'w')
|
||||
|
||||
pathToStoreSSL = virtualHostUtilities.Server_root + "/conf/vhosts/" + "SSL-" + virtualHost
|
||||
|
||||
pathToStoreSSLPrivKey = pathToStoreSSL + "/privkey.pem"
|
||||
pathToStoreSSLFullChain = pathToStoreSSL + "/fullchain.pem"
|
||||
|
||||
destPrivKey = "/usr/local/lscp/key.pem"
|
||||
destCert = "/usr/local/lscp/cert.pem"
|
||||
|
||||
@@ -464,18 +446,16 @@ class virtualHostUtilities:
|
||||
if os.path.exists(destCert):
|
||||
os.remove(destCert)
|
||||
|
||||
letsEncryptPath = "/etc/letsencrypt/live/" + virtualHost
|
||||
adminEmail = "email@" + virtualHost
|
||||
|
||||
if os.path.exists(letsEncryptPath) and os.path.exists(pathToStoreSSL):
|
||||
pass
|
||||
else:
|
||||
adminEmail = "email@" + virtualHost
|
||||
retValues = sslUtilities.issueSSLForDomain(virtualHost, adminEmail, path)
|
||||
|
||||
retValues = sslUtilities.issueSSLForDomain(virtualHost, adminEmail, path)
|
||||
if retValues[0] == 0:
|
||||
print "0," + str(retValues[1])
|
||||
return 0, retValues[1]
|
||||
|
||||
if retValues[0] == 0:
|
||||
print "0," + str(retValues[1])
|
||||
return 0,retValues[1]
|
||||
pathToStoreSSLFullChain = '/etc/letsencrypt/live/' + virtualHost + '/fullchain.pem'
|
||||
pathToStoreSSLPrivKey = '/etc/letsencrypt/live/' + virtualHost + '/privkey.pem'
|
||||
|
||||
shutil.copy(pathToStoreSSLPrivKey, destPrivKey)
|
||||
shutil.copy(pathToStoreSSLFullChain, destCert)
|
||||
@@ -505,23 +485,15 @@ class virtualHostUtilities:
|
||||
|
||||
FNULL = open(os.devnull, 'w')
|
||||
|
||||
pathToStoreSSL = virtualHostUtilities.Server_root + "/conf/vhosts/" + "SSL-" + virtualHost
|
||||
srcFullChain = '/etc/letsencrypt/live/' + virtualHost + '/fullchain.pem'
|
||||
srcPrivKey = '/etc/letsencrypt/live/' + virtualHost + '/privkey.pem'
|
||||
|
||||
srcPrivKey = pathToStoreSSL + "/privkey.pem"
|
||||
srcFullChain = pathToStoreSSL + "/fullchain.pem"
|
||||
adminEmail = "email@" + virtualHost
|
||||
retValues = sslUtilities.issueSSLForDomain(virtualHost, adminEmail, path)
|
||||
|
||||
letsEncryptPath = "/etc/letsencrypt/live/" + virtualHost
|
||||
|
||||
if os.path.exists(letsEncryptPath) and os.path.exists(pathToStoreSSL):
|
||||
pass
|
||||
else:
|
||||
adminEmail = "email@" + virtualHost
|
||||
|
||||
retValues = sslUtilities.issueSSLForDomain(virtualHost, adminEmail, path)
|
||||
|
||||
if retValues[0] == 0:
|
||||
print "0," + str(retValues[1])
|
||||
return 0,retValues[1]
|
||||
if retValues[0] == 0:
|
||||
print "0," + str(retValues[1])
|
||||
return 0, retValues[1]
|
||||
|
||||
## MailServer specific functions
|
||||
|
||||
@@ -778,6 +750,8 @@ class virtualHostUtilities:
|
||||
def saveSSL(virtualHost, pathToStoreSSL, keyPath, certPath, sslCheck):
|
||||
try:
|
||||
|
||||
pathToStoreSSL = '/etc/letsencrypt/live/' + virtualHost
|
||||
|
||||
if not os.path.exists(pathToStoreSSL):
|
||||
os.mkdir(pathToStoreSSL)
|
||||
|
||||
@@ -792,8 +766,11 @@ class virtualHostUtilities:
|
||||
fullchain.write(open(certPath, "r").read())
|
||||
fullchain.close()
|
||||
|
||||
if sslCheck == "0":
|
||||
sslUtilities.sslUtilities.installSSLForDomain(virtualHost)
|
||||
os.remove(keyPath)
|
||||
os.remove(certPath)
|
||||
|
||||
website = Websites.objects.get(domain=virtualHost)
|
||||
sslUtilities.sslUtilities.installSSLForDomain(virtualHost, website.adminEmail)
|
||||
|
||||
installUtilities.installUtilities.reStartLiteSpeed()
|
||||
|
||||
@@ -811,28 +788,23 @@ class virtualHostUtilities:
|
||||
print "0," + str(msg)
|
||||
|
||||
@staticmethod
|
||||
def createDomain(masterDomain, virtualHostName, phpVersion, path, ssl, dkimCheck, openBasedir, restore, owner=None, tempStatusPath = '/home/cyberpanel/fakePath'):
|
||||
def createDomain(masterDomain, virtualHostName, phpVersion, path, ssl, dkimCheck, openBasedir, owner, tempStatusPath = '/home/cyberpanel/fakePath'):
|
||||
try:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Running some checks..,0')
|
||||
statusFile.close()
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Running some checks..,0')
|
||||
|
||||
## Check if this domain either exists as website or child domain
|
||||
|
||||
if restore == '0':
|
||||
admin = Administrator.objects.get(userName=owner)
|
||||
DNS.dnsTemplate(virtualHostName, admin)
|
||||
admin = Administrator.objects.get(userName=owner)
|
||||
DNS.dnsTemplate(virtualHostName, admin)
|
||||
|
||||
|
||||
if Websites.objects.filter(domain=virtualHostName).count() > 0:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("This Domain already exists as a website. [404]")
|
||||
statusFile.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'This Domain already exists as a website. [404]')
|
||||
return 0, "This Domain already exists as a website."
|
||||
|
||||
if ChildDomains.objects.filter(domain=virtualHostName).count() > 0:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("This domain already exists as child domain. [404]")
|
||||
statusFile.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'This domain already exists as child domain. [404]')
|
||||
return 0, "This domain already exists as child domain."
|
||||
|
||||
####### Limitations check
|
||||
@@ -845,9 +817,8 @@ class virtualHostUtilities:
|
||||
elif domainsInPackage > master.childdomains_set.all().count():
|
||||
pass
|
||||
else:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("Exceeded maximum number of domains for this package. [404]")
|
||||
statusFile.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath,
|
||||
'Exceeded maximum number of domains for this package. [404]')
|
||||
return 0, "Exceeded maximum number of domains for this package"
|
||||
|
||||
|
||||
@@ -855,20 +826,15 @@ class virtualHostUtilities:
|
||||
|
||||
|
||||
if vhost.checkIfVirtualHostExists(virtualHostName) == 1:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("Virtual Host Directory already exists. [404]")
|
||||
statusFile.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath,'Virtual Host Directory already exists. [404]')
|
||||
return 0, "Virtual Host Directory already exists!"
|
||||
|
||||
if vhost.checkIfAliasExists(virtualHostName) == 1:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("This domain exists as Alias. [404]")
|
||||
statusFile.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath,'This domain exists as Alias. [404]')
|
||||
return 0, "This domain exists as Alias."
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('DKIM Setup..,30')
|
||||
statusFile.close()
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'DKIM Setup..,30')
|
||||
|
||||
if dkimCheck == 1:
|
||||
if mailUtilities.checkIfDKIMInstalled() == 0:
|
||||
@@ -880,9 +846,7 @@ class virtualHostUtilities:
|
||||
|
||||
FNULL = open(os.devnull, 'w')
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Creating configurations..,50')
|
||||
statusFile.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Creating configurations..,50')
|
||||
|
||||
retValues = vhost.createDirectoryForDomain(masterDomain, virtualHostName, phpVersion, path,
|
||||
master.adminEmail, master.externalApp, openBasedir)
|
||||
@@ -896,12 +860,8 @@ class virtualHostUtilities:
|
||||
|
||||
## Now restart litespeed after initial configurations are done
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Creating SSL..,50')
|
||||
statusFile.close()
|
||||
|
||||
|
||||
if ssl == 1:
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Creating SSL..,50')
|
||||
installUtilities.installUtilities.reStartLiteSpeed()
|
||||
retValues = sslUtilities.issueSSLForDomain(virtualHostName, master.adminEmail, path)
|
||||
installUtilities.installUtilities.reStartLiteSpeed()
|
||||
@@ -916,27 +876,23 @@ class virtualHostUtilities:
|
||||
|
||||
## DKIM Check
|
||||
|
||||
if restore == '0':
|
||||
if dkimCheck == 1:
|
||||
DNS.createDKIMRecords(virtualHostName)
|
||||
if dkimCheck == 1:
|
||||
DNS.createDKIMRecords(virtualHostName)
|
||||
|
||||
|
||||
website = ChildDomains(master=master, domain=virtualHostName, path=path, phpSelection=phpVersion, ssl=ssl)
|
||||
|
||||
website.save()
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("Domain successfully created. [200]")
|
||||
statusFile.close()
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Domain successfully created. [200]')
|
||||
return 1, "None"
|
||||
|
||||
except BaseException, msg:
|
||||
numberOfWebsites = Websites.objects.count() + ChildDomains.objects.count()
|
||||
vhost.deleteCoreConf(virtualHostName, numberOfWebsites)
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, str(msg) + ". [404]")
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [createDomain]")
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines(str(msg) + ". [404]")
|
||||
statusFile.close()
|
||||
return 0, str(msg)
|
||||
|
||||
@staticmethod
|
||||
@@ -1082,7 +1038,7 @@ def main():
|
||||
except:
|
||||
tempStatusPath = '/home/cyberpanel/fakePath'
|
||||
|
||||
virtualHostUtilities.createVirtualHost(args.virtualHostName, args.administratorEmail, args.phpVersion, args.virtualHostUser, int(args.numberOfSites), int(args.ssl), args.sslPath, dkimCheck, openBasedir, args.websiteOwner, args.package, tempStatusPath)
|
||||
virtualHostUtilities.createVirtualHost(args.virtualHostName, args.administratorEmail, args.phpVersion, args.virtualHostUser, int(args.ssl), dkimCheck, openBasedir, args.websiteOwner, args.package, tempStatusPath)
|
||||
elif args.function == "deleteVirtualHostConfigurations":
|
||||
vhost.deleteVirtualHostConfigurations(args.virtualHostName,int(args.numberOfSites))
|
||||
elif args.function == "createDomain":
|
||||
@@ -1101,7 +1057,7 @@ def main():
|
||||
except:
|
||||
tempStatusPath = '/home/cyberpanel/fakePath'
|
||||
|
||||
virtualHostUtilities.createDomain(args.masterDomain, args.virtualHostName, args.phpVersion, args.path, int(args.ssl), dkimCheck, openBasedir, args.restore, args.websiteOwner, tempStatusPath)
|
||||
virtualHostUtilities.createDomain(args.masterDomain, args.virtualHostName, args.phpVersion, args.path, int(args.ssl), dkimCheck, openBasedir, args.websiteOwner, tempStatusPath)
|
||||
elif args.function == "issueSSL":
|
||||
virtualHostUtilities.issueSSL(args.virtualHostName,args.path,args.administratorEmail)
|
||||
elif args.function == "changePHP":
|
||||
|
||||
@@ -132,7 +132,16 @@ def siteState(request):
|
||||
|
||||
def submitWebsiteCreation(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
userID = request.session['userID']
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
elif currentACL['createWebsite'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('createWebSiteStatus', 0)
|
||||
|
||||
if request.method == 'POST':
|
||||
|
||||
data = json.loads(request.body)
|
||||
@@ -146,41 +155,15 @@ def submitWebsiteCreation(request):
|
||||
tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
|
||||
####### Limitations check
|
||||
|
||||
currentACL = ACLManager.loadedACL(val)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
elif currentACL['createWebsite'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('createWebSiteStatus', 0)
|
||||
|
||||
newOwner = Administrator.objects.get(userName=websiteOwner)
|
||||
|
||||
if ACLManager.websitesLimitCheck(newOwner, 1) == 0:
|
||||
data_ret = {'createWebSiteStatus': 0,
|
||||
'error_message': "You've reached maximum websites limit as a reseller."}
|
||||
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
####### Limitations Check End
|
||||
|
||||
numberOfWebsites = str(Websites.objects.count() + ChildDomains.objects.count())
|
||||
sslpath = "/home/" + domain + "/public_html"
|
||||
|
||||
## Create Configurations
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
execPath = execPath + " createVirtualHost --virtualHostName " + domain + \
|
||||
" --administratorEmail " + adminEmail + " --phpVersion '" + phpSelection + \
|
||||
"' --virtualHostUser " + externalApp + " --numberOfSites " + numberOfWebsites + \
|
||||
" --ssl " + str(data['ssl']) + " --sslPath " + sslpath + " --dkimCheck " + str(data['dkimCheck'])\
|
||||
+ " --openBasedir " + str(data['openBasedir']) + ' --websiteOwner ' + websiteOwner \
|
||||
+ ' --package ' + packageName + ' --tempStatusPath ' + tempStatusPath
|
||||
"' --virtualHostUser " + externalApp + " --ssl " + str(data['ssl']) + " --dkimCheck " \
|
||||
+ str(data['dkimCheck']) + " --openBasedir " + str(data['openBasedir']) + \
|
||||
' --websiteOwner ' + websiteOwner + ' --package ' + packageName + ' --tempStatusPath ' + tempStatusPath
|
||||
|
||||
subprocess.Popen(shlex.split(execPath))
|
||||
time.sleep(2)
|
||||
@@ -206,41 +189,26 @@ def submitDomainCreation(request):
|
||||
path = data['path']
|
||||
tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
try:
|
||||
restore = data['restore']
|
||||
restore = '1'
|
||||
if currentACL['admin'] != 1:
|
||||
data['openBasedir'] = 1
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
if len(path) > 0:
|
||||
path = path.lstrip("/")
|
||||
path = "/home/" + masterDomain + "/public_html/" + path
|
||||
else:
|
||||
path = "/home/" + masterDomain + "/public_html/" + domain
|
||||
|
||||
execPath = execPath + " createDomain --masterDomain " + masterDomain + " --virtualHostName " + domain + \
|
||||
" --phpVersion '" + phpSelection + "' --ssl " + str(data['ssl']) + " --dkimCheck " + \
|
||||
str(data['dkimCheck']) + " --openBasedir " + str(data['openBasedir']) + ' --path ' + path \
|
||||
+ ' --restore ' + restore + ' --tempStatusPath ' + tempStatusPath
|
||||
|
||||
except:
|
||||
restore = '0'
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
if len(path) > 0:
|
||||
path = path.lstrip("/")
|
||||
path = "/home/" + masterDomain + "/public_html/" + path
|
||||
else:
|
||||
path = "/home/" + masterDomain + "/public_html/" + domain
|
||||
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] != 1:
|
||||
data['openBasedir'] = 1
|
||||
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
execPath = execPath + " createDomain --masterDomain " + masterDomain + " --virtualHostName " + domain + \
|
||||
" --phpVersion '" + phpSelection + "' --ssl " + str(data['ssl']) + " --dkimCheck " + str(data['dkimCheck']) \
|
||||
+ " --openBasedir " + str(data['openBasedir']) + ' --path ' + path \
|
||||
+ ' --restore ' + restore + ' --websiteOwner ' + admin.userName + ' --tempStatusPath ' + tempStatusPath
|
||||
execPath = execPath + " createDomain --masterDomain " + masterDomain + " --virtualHostName " + domain + \
|
||||
" --phpVersion '" + phpSelection + "' --ssl " + str(data['ssl']) + " --dkimCheck " + str(data['dkimCheck']) \
|
||||
+ " --openBasedir " + str(data['openBasedir']) + ' --path ' + path + ' --websiteOwner ' \
|
||||
+ admin.userName + ' --tempStatusPath ' + tempStatusPath
|
||||
|
||||
subprocess.Popen(shlex.split(execPath))
|
||||
time.sleep(2)
|
||||
|
||||
Reference in New Issue
Block a user