mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-09 14:56:10 +01:00
make mail child domain optional
This commit is contained in:
@@ -58,7 +58,7 @@ class virtualHostUtilities:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def createVirtualHost(virtualHostName, administratorEmail, phpVersion, virtualHostUser, ssl,
|
def createVirtualHost(virtualHostName, administratorEmail, phpVersion, virtualHostUser, ssl,
|
||||||
dkimCheck, openBasedir, websiteOwner, packageName, apache,
|
dkimCheck, openBasedir, websiteOwner, packageName, apache,
|
||||||
tempStatusPath='/home/cyberpanel/fakePath'):
|
tempStatusPath='/home/cyberpanel/fakePath', mailDomain = None):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Running some checks..,0')
|
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Running some checks..,0')
|
||||||
@@ -206,56 +206,57 @@ class virtualHostUtilities:
|
|||||||
|
|
||||||
### For autodiscover of mail clients.
|
### For autodiscover of mail clients.
|
||||||
|
|
||||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Creating mail child domain..,80')
|
if mailDomain:
|
||||||
childDomain = 'mail.%s' % (virtualHostName)
|
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Creating mail child domain..,80')
|
||||||
childPath = '/home/%s/public_html/%s' % (virtualHostName, childDomain)
|
childDomain = 'mail.%s' % (virtualHostName)
|
||||||
|
childPath = '/home/%s/public_html/%s' % (virtualHostName, childDomain)
|
||||||
|
|
||||||
virtualHostUtilities.createDomain(virtualHostName, childDomain, 'PHP 7.2', childPath, 1, 0, 0, admin.userName, 0, "/home/cyberpanel/" + str(randint(1000, 9999)))
|
virtualHostUtilities.createDomain(virtualHostName, childDomain, 'PHP 7.2', childPath, 1, 0, 0, admin.userName, 0, "/home/cyberpanel/" + str(randint(1000, 9999)))
|
||||||
|
|
||||||
## update dovecot conf to enable auto-discover
|
## update dovecot conf to enable auto-discover
|
||||||
|
|
||||||
dovecotPath = '/etc/dovecot/dovecot.conf'
|
dovecotPath = '/etc/dovecot/dovecot.conf'
|
||||||
|
|
||||||
if os.path.exists(dovecotPath):
|
if os.path.exists(dovecotPath):
|
||||||
dovecotContent = open(dovecotPath, 'r').read()
|
dovecotContent = open(dovecotPath, 'r').read()
|
||||||
|
|
||||||
if dovecotContent.find(childDomain) == -1:
|
if dovecotContent.find(childDomain) == -1:
|
||||||
content = """\nlocal_name %s {
|
content = """\nlocal_name %s {
|
||||||
ssl_cert = </etc/letsencrypt/live/%s/fullchain.pem
|
ssl_cert = </etc/letsencrypt/live/%s/fullchain.pem
|
||||||
ssl_key = </etc/letsencrypt/live/%s/privkey.pem
|
ssl_key = </etc/letsencrypt/live/%s/privkey.pem
|
||||||
}\n""" % (childDomain, childDomain, childDomain)
|
}\n""" % (childDomain, childDomain, childDomain)
|
||||||
|
|
||||||
writeToFile = open(dovecotPath, 'a')
|
writeToFile = open(dovecotPath, 'a')
|
||||||
writeToFile.write(content)
|
writeToFile.write(content)
|
||||||
|
writeToFile.close()
|
||||||
|
|
||||||
|
command = 'systemctl restart dovecot'
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
|
### Update postfix configurations
|
||||||
|
|
||||||
|
postFixPath = '/etc/postfix/main.cf'
|
||||||
|
|
||||||
|
postFixContent = open(postFixPath, 'r').read()
|
||||||
|
|
||||||
|
if postFixContent.find('tls_server_sni_maps') == -1:
|
||||||
|
writeToFile = open(postFixPath, 'a')
|
||||||
|
writeToFile.write('\ntls_server_sni_maps = hash:/etc/postfix/vmail_ssl.map\n')
|
||||||
|
writeToFile.close()
|
||||||
|
|
||||||
|
postfixMapFile = '/etc/postfix/vmail_ssl.map'
|
||||||
|
|
||||||
|
mapContent = '%s /etc/letsencrypt/live/%s/privkey.pem /etc/letsencrypt/live/%s/fullchain.pem\n' % (childDomain, childDomain, childDomain)
|
||||||
|
|
||||||
|
writeToFile = open(postfixMapFile, 'a')
|
||||||
|
writeToFile.write(mapContent)
|
||||||
writeToFile.close()
|
writeToFile.close()
|
||||||
|
|
||||||
command = 'systemctl restart dovecot'
|
command = 'postmap -F hash:/etc/postfix/vmail_ssl.map'
|
||||||
ProcessUtilities.executioner(command)
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
### Update postfix configurations
|
command = 'systemctl restart postfix'
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
postFixPath = '/etc/postfix/main.cf'
|
|
||||||
|
|
||||||
postFixContent = open(postFixPath, 'r').read()
|
|
||||||
|
|
||||||
if postFixContent.find('tls_server_sni_maps') == -1:
|
|
||||||
writeToFile = open(postFixPath, 'a')
|
|
||||||
writeToFile.write('\ntls_server_sni_maps = hash:/etc/postfix/vmail_ssl.map\n')
|
|
||||||
writeToFile.close()
|
|
||||||
|
|
||||||
postfixMapFile = '/etc/postfix/vmail_ssl.map'
|
|
||||||
|
|
||||||
mapContent = '%s /etc/letsencrypt/live/%s/privkey.pem /etc/letsencrypt/live/%s/fullchain.pem\n' % (childDomain, childDomain, childDomain)
|
|
||||||
|
|
||||||
writeToFile = open(postfixMapFile, 'a')
|
|
||||||
writeToFile.write(mapContent)
|
|
||||||
writeToFile.close()
|
|
||||||
|
|
||||||
command = 'postmap -F hash:/etc/postfix/vmail_ssl.map'
|
|
||||||
ProcessUtilities.executioner(command)
|
|
||||||
|
|
||||||
command = 'systemctl restart postfix'
|
|
||||||
ProcessUtilities.executioner(command)
|
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
@@ -1391,6 +1392,7 @@ def main():
|
|||||||
|
|
||||||
parser.add_argument('--openBasedirValue', help='open_base dir protection value!')
|
parser.add_argument('--openBasedirValue', help='open_base dir protection value!')
|
||||||
parser.add_argument('--tempStatusPath', help='Temporary Status file path.')
|
parser.add_argument('--tempStatusPath', help='Temporary Status file path.')
|
||||||
|
parser.add_argument('--mailDomain', help='To create or not to create mail domain.')
|
||||||
|
|
||||||
## Switch Server
|
## Switch Server
|
||||||
|
|
||||||
@@ -1421,7 +1423,7 @@ def main():
|
|||||||
|
|
||||||
virtualHostUtilities.createVirtualHost(args.virtualHostName, args.administratorEmail, args.phpVersion,
|
virtualHostUtilities.createVirtualHost(args.virtualHostName, args.administratorEmail, args.phpVersion,
|
||||||
args.virtualHostUser, int(args.ssl), dkimCheck, openBasedir,
|
args.virtualHostUser, int(args.ssl), dkimCheck, openBasedir,
|
||||||
args.websiteOwner, args.package, apache, tempStatusPath)
|
args.websiteOwner, args.package, apache, tempStatusPath, int(args.mailDomain))
|
||||||
elif args.function == "deleteVirtualHostConfigurations":
|
elif args.function == "deleteVirtualHostConfigurations":
|
||||||
vhost.deleteVirtualHostConfigurations(args.virtualHostName)
|
vhost.deleteVirtualHostConfigurations(args.virtualHostName)
|
||||||
elif args.function == "createDomain":
|
elif args.function == "createDomain":
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ app.controller('createWebsite', function ($scope, $http, $timeout, $window) {
|
|||||||
|
|
||||||
$scope.currentStatus = "Starting creation..";
|
$scope.currentStatus = "Starting creation..";
|
||||||
|
|
||||||
var ssl, dkimCheck, openBasedir;
|
var ssl, dkimCheck, openBasedir, mailDomain;
|
||||||
|
|
||||||
if ($scope.sslCheck === true) {
|
if ($scope.sslCheck === true) {
|
||||||
ssl = 1;
|
ssl = 1;
|
||||||
@@ -65,6 +65,13 @@ app.controller('createWebsite', function ($scope, $http, $timeout, $window) {
|
|||||||
openBasedir = 0
|
openBasedir = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($scope.mailDomain === true) {
|
||||||
|
mailDomain = 1;
|
||||||
|
} else {
|
||||||
|
mailDomain = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
url = "/websites/submitWebsiteCreation";
|
url = "/websites/submitWebsiteCreation";
|
||||||
|
|
||||||
var package = $scope.packageForWebsite;
|
var package = $scope.packageForWebsite;
|
||||||
@@ -82,7 +89,8 @@ app.controller('createWebsite', function ($scope, $http, $timeout, $window) {
|
|||||||
ssl: ssl,
|
ssl: ssl,
|
||||||
websiteOwner: websiteOwner,
|
websiteOwner: websiteOwner,
|
||||||
dkimCheck: dkimCheck,
|
dkimCheck: dkimCheck,
|
||||||
openBasedir: openBasedir
|
openBasedir: openBasedir,
|
||||||
|
mailDomain: mailDomain
|
||||||
};
|
};
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
|
|||||||
@@ -105,6 +105,15 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<label class="col-sm-3 control-label"></label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<input ng-model="mailDomain" type="checkbox" value="">
|
||||||
|
Create Mail Domain
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-hide="installationDetailsForm" class="form-group">
|
<div ng-hide="installationDetailsForm" class="form-group">
|
||||||
|
|||||||
@@ -199,6 +199,8 @@ class WebsiteManager:
|
|||||||
except:
|
except:
|
||||||
externalApp = "".join(re.findall("[a-zA-Z]+", domain))[:7]
|
externalApp = "".join(re.findall("[a-zA-Z]+", domain))[:7]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
counter = 0
|
counter = 0
|
||||||
while 1:
|
while 1:
|
||||||
@@ -215,6 +217,11 @@ class WebsiteManager:
|
|||||||
except:
|
except:
|
||||||
apacheBackend = "0"
|
apacheBackend = "0"
|
||||||
|
|
||||||
|
try:
|
||||||
|
mailDomain = str(data['mailDomain'])
|
||||||
|
except:
|
||||||
|
mailDomain = "1"
|
||||||
|
|
||||||
import pwd
|
import pwd
|
||||||
counter = 0
|
counter = 0
|
||||||
while 1:
|
while 1:
|
||||||
@@ -232,7 +239,7 @@ class WebsiteManager:
|
|||||||
" --administratorEmail " + adminEmail + " --phpVersion '" + phpSelection + \
|
" --administratorEmail " + adminEmail + " --phpVersion '" + phpSelection + \
|
||||||
"' --virtualHostUser " + externalApp + " --ssl " + str(data['ssl']) + " --dkimCheck " \
|
"' --virtualHostUser " + externalApp + " --ssl " + str(data['ssl']) + " --dkimCheck " \
|
||||||
+ str(data['dkimCheck']) + " --openBasedir " + str(data['openBasedir']) + \
|
+ str(data['dkimCheck']) + " --openBasedir " + str(data['openBasedir']) + \
|
||||||
' --websiteOwner ' + websiteOwner + ' --package ' + packageName + ' --tempStatusPath ' + tempStatusPath + " --apache " + apacheBackend
|
' --websiteOwner ' + websiteOwner + ' --package ' + packageName + ' --tempStatusPath ' + tempStatusPath + " --apache " + apacheBackend + " --mailDomain %s" % (mailDomain)
|
||||||
|
|
||||||
ProcessUtilities.popenExecutioner(execPath)
|
ProcessUtilities.popenExecutioner(execPath)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|||||||
Reference in New Issue
Block a user