Let's Encrypt SSL for MailServer.

This commit is contained in:
usmannasir
2018-04-26 17:59:47 +05:00
parent 236f07d926
commit ff9161322a
11 changed files with 637 additions and 136 deletions

View File

@@ -40,8 +40,8 @@
<label class="col-sm-3 control-label">{% trans "Select Frequency" %}</label> <label class="col-sm-3 control-label">{% trans "Select Frequency" %}</label>
<div class="col-sm-6"> <div class="col-sm-6">
<select ng-change="scheduleBtnView()" ng-model="backupFreq" class="form-control"> <select ng-change="scheduleBtnView()" ng-model="backupFreq" class="form-control">
<option>{% trans "Daily" %}</option> <option>Daily</option>
<option>{% trans "Weekly" %}</option> <option>Weekly</option>
</select> </select>
</div> </div>
</div> </div>

View File

@@ -449,6 +449,7 @@
<ul> <ul>
<li><a href="{% url 'manageSSL' %}" title="{% trans 'Manage SSL' %}"><span>{% trans "Manage SSL" %}</span></a></li> <li><a href="{% url 'manageSSL' %}" title="{% trans 'Manage SSL' %}"><span>{% trans "Manage SSL" %}</span></a></li>
<li id="sslA"><a href="{% url 'sslForHostName' %}" title="{% trans 'Hostname SSL' %}"><span>{% trans "Hostname SSL" %}</span></a></li> <li id="sslA"><a href="{% url 'sslForHostName' %}" title="{% trans 'Hostname SSL' %}"><span>{% trans "Hostname SSL" %}</span></a></li>
<li id="sslA"><a href="{% url 'sslForMailServer' %}" title="{% trans 'MailServer SSL' %}"><span>{% trans "MailServer SSL" %}</span></a></li>
</ul> </ul>
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->

View File

@@ -48,7 +48,7 @@
<li ng-click="fetchRecordsTabs('spfRecord')" id="spfRecord"><a href="">SPF</a></li> <li ng-click="fetchRecordsTabs('spfRecord')" id="spfRecord"><a href="">SPF</a></li>
<li ng-click="fetchRecordsTabs('nsRecord')" id="nsRecord"><a href="">NS</a></li> <li ng-click="fetchRecordsTabs('nsRecord')" id="nsRecord"><a href="">NS</a></li>
<li ng-click="fetchRecordsTabs('soaRecord')" id="soaRecord" ><a href="">SOA</a></li> <li ng-click="fetchRecordsTabs('soaRecord')" id="soaRecord" ><a href="">SOA</a></li>
<li ng-click="fetchRecordsTabs('srvRecord')" id="soaRecord" ><a href="">SRV</a></li> <li ng-click="fetchRecordsTabs('srvRecord')" id="srvRecord" ><a href="">SRV</a></li>
</ul> </ul>
</div> </div>

View File

@@ -111,6 +111,7 @@
<foldersAlwaysOnTop value="true" /> <foldersAlwaysOnTop value="true" />
</navigator> </navigator>
<panes> <panes>
<pane id="Scratches" />
<pane id="ProjectPane"> <pane id="ProjectPane">
<subPane> <subPane>
<expand> <expand>
@@ -128,7 +129,6 @@
</subPane> </subPane>
</pane> </pane>
<pane id="Scope" /> <pane id="Scope" />
<pane id="Scratches" />
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
@@ -165,25 +165,26 @@
<workItem from="1512401100852" duration="2365000" /> <workItem from="1512401100852" duration="2365000" />
<workItem from="1523948661253" duration="7874000" /> <workItem from="1523948661253" duration="7874000" />
<workItem from="1524303326266" duration="7000" /> <workItem from="1524303326266" duration="7000" />
<workItem from="1524730597265" duration="8000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="36374000" /> <option name="totallyTimeSpent" value="36382000" />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="1466" y="-4" width="1303" height="780" extended-state="6" /> <frame x="1466" y="-4" width="1303" height="780" extended-state="6" />
<layout> <layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.23443505" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> <window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.23443505" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" /> <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" /> <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
@@ -256,6 +257,35 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/php/caller.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="558">
<caret line="31" column="23" lean-forward="false" selection-start-line="31" selection-start-column="23" selection-end-line="31" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#deleteFolderOrFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#compress#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#extract#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/fileManager.php"> <entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0"> <state relative-caret-position="0">

View File

@@ -175,3 +175,90 @@ app.controller('sslIssueForHostNameCtrl', function($scope,$http) {
}); });
/* Java script code to issue SSL for hostname */ /* Java script code to issue SSL for hostname */
/* Java script code to issue SSL for MailServer */
app.controller('sslIssueForMailServer', function($scope,$http) {
$scope.sslIssueCtrl = true;
$scope.manageSSLLoading = true;
$scope.issueSSLBtn = true;
$scope.canNotIssue = true;
$scope.sslIssued = true;
$scope.couldNotConnect = true;
$scope.showbtn = function () {
$scope.issueSSLBtn = false;
};
$scope.issueSSL = function(){
$scope.manageSSLLoading = false;
var url = "/manageSSL/obtainMailServerSSL";
var data = {
virtualHost:$scope.virtualHost,
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.SSL === 1){
$scope.sslIssueCtrl = true;
$scope.manageSSLLoading = true;
$scope.issueSSLBtn = false;
$scope.canNotIssue = true;
$scope.sslIssued = false;
$scope.couldNotConnect = true;
$scope.sslDomain = $scope.virtualHost;
}
else
{
$scope.sslIssueCtrl = true;
$scope.manageSSLLoading = true;
$scope.issueSSLBtn = false;
$scope.canNotIssue = false;
$scope.sslIssued = true;
$scope.couldNotConnect = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.sslIssueCtrl = true;
$scope.manageSSLLoading = true;
$scope.issueSSLBtn = false;
$scope.canNotIssue = true;
$scope.sslIssued = true;
$scope.couldNotConnect = false;
}
};
});
/* Java script code to issue SSL for MailServer */

View File

@@ -0,0 +1,81 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "Issue SSL For MailServer - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container">
<div id="page-title">
<h2>{% trans "Issue SSL For MailServer" %}</h2>
<p>{% trans "Lets Encrypt SSL for MailServer (Postfix/Dovecot)." %}</p>
</div>
<div ng-controller="sslIssueForMailServer" class="panel">
<div class="panel-body">
<h3 class="title-hero">
{% trans "Issue SSL For MailServer" %} <img ng-hide="manageSSLLoading" src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
<form action="/" class="form-horizontal bordered-row">
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Website" %}</label>
<div class="col-sm-6">
<select ng-change="showbtn()" ng-model="virtualHost" class="form-control">
{% for items in websiteList %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
</div>
<div ng-hide="issueSSLBtn" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="issueSSL()" class="btn btn-primary btn-lg btn-block">{% trans "Issue SSL" %}</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<div ng-hide="canNotIssue" class="alert alert-danger">
<p>{% trans "Cannot issue SSL. Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="sslIssued" class="alert alert-success">
<p>{% trans "SSL Issued, your mail server now uses Lets Encrypt!" %}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-success">
<p>{% trans "Could not connect to server, please refresh this page." %}</p>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -9,5 +9,8 @@ urlpatterns = [
url(r'^issueSSL', views.issueSSL, name='issueSSL'), url(r'^issueSSL', views.issueSSL, name='issueSSL'),
url(r'^sslForHostName', views.sslForHostName, name='sslForHostName'), url(r'^sslForHostName', views.sslForHostName, name='sslForHostName'),
url(r'^obtainHostNameSSL', views.obtainHostNameSSL, name='obtainHostNameSSL'), url(r'^obtainHostNameSSL$', views.obtainHostNameSSL, name='obtainHostNameSSL'),
url(r'^sslForMailServer', views.sslForMailServer, name='sslForMailServer'),
url(r'^obtainMailServerSSL', views.obtainMailServerSSL, name='obtainMailServerSSL'),
] ]

View File

@@ -167,7 +167,6 @@ def sslForHostName(request):
except KeyError: except KeyError:
return redirect(loadLoginPage) return redirect(loadLoginPage)
def obtainHostNameSSL(request): def obtainHostNameSSL(request):
try: try:
val = request.session['userID'] val = request.session['userID']
@@ -213,3 +212,92 @@ def obtainHostNameSSL(request):
'error_message': str(msg)} 'error_message': str(msg)}
json_data = json.dumps(data_ret) json_data = json.dumps(data_ret)
return HttpResponse(json_data) return HttpResponse(json_data)
def sslForMailServer(request):
try:
val = request.session['userID']
admin = Administrator.objects.get(pk=request.session['userID'])
if admin.type==1:
pass
else:
return HttpResponse("You should be admin to issue SSL For Hostname.")
if admin.type == 1:
websites = Websites.objects.all()
websitesName = []
for items in websites:
websitesName.append(items.domain)
else:
if admin.type == 2:
websites = admin.websites_set.all()
admins = Administrator.objects.filter(owner=admin.pk)
websitesName = []
for items in websites:
websitesName.append(items.domain)
for items in admins:
webs = items.websites_set.all()
for web in webs:
websitesName.append(web.domain)
else:
websitesName = []
websites = Websites.objects.filter(admin=admin)
for items in websites:
websitesName.append(items.domain)
return render(request, 'manageSSL/sslForMailServer.html',{'websiteList':websitesName})
except KeyError:
return redirect(loadLoginPage)
def obtainMailServerSSL(request):
try:
val = request.session['userID']
try:
if request.method == 'POST':
data = json.loads(request.body)
virtualHost = data['virtualHost']
website = Websites.objects.get(domain=virtualHost)
path = "/home/" + virtualHost + "/public_html"
## ssl issue
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
execPath = execPath + " issueSSLForMailServer --virtualHostName " + virtualHost + " --path " + path
logging.writeToFile(execPath)
output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {"SSL": 1,
'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
data_ret = {"SSL": 0,
'error_message': output}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
## ssl issue ends
except BaseException,msg:
data_ret = {"SSL": 0,
'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except KeyError,msg:
data_ret = {"SSL": 0,
'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)

View File

@@ -1577,6 +1577,141 @@ def issueSSLForHostName(virtualHost,path):
str(msg) + " [issueSSLForHostName]") str(msg) + " [issueSSLForHostName]")
print "0,"+str(msg) print "0,"+str(msg)
def issueSSLForMailServer(virtualHost,path):
try:
FNULL = open(os.devnull, 'w')
srcPrivKey = "/etc/letsencrypt/live/" + virtualHost + "/privkey.pem"
srcFullChain = "/etc/letsencrypt/live/" + virtualHost + "/fullchain.pem"
pathToStoreSSL = virtualHostUtilities.Server_root + "/conf/vhosts/" + "SSL-" + virtualHost
pathToStoreSSLPrivKey = pathToStoreSSL + "/privkey.pem"
pathToStoreSSLFullChain = pathToStoreSSL + "/fullchain.pem"
## removing old certs
if os.path.exists(pathToStoreSSLPrivKey):
os.remove(pathToStoreSSLPrivKey)
if os.path.exists(pathToStoreSSLFullChain):
os.remove(pathToStoreSSLFullChain)
adminEmail = "email@" + virtualHost
if not (os.path.exists(srcPrivKey) and os.path.exists(srcFullChain)):
retValues = sslUtilities.issueSSLForDomain(virtualHost, adminEmail, path)
if retValues[0] == 0:
print "0," + str(retValues[1])
return
else:
###### Copy SSL To config location ######
try:
os.mkdir(pathToStoreSSL)
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [Directory for SSL already exists.. Continuing [issueSSLForHostName]]")
srcPrivKey = "/etc/letsencrypt/live/" + virtualHost + "/privkey.pem"
srcFullChain = "/etc/letsencrypt/live/" + virtualHost + "/fullchain.pem"
shutil.copy(srcPrivKey, pathToStoreSSLPrivKey)
shutil.copy(srcFullChain, pathToStoreSSLFullChain)
## MailServer specific functions
if os.path.exists("/etc/postfix/cert.pem"):
os.remove("/etc/postfix/cert.pem")
if os.path.exists("/etc/postfix/key.pem"):
os.remove("/etc/postfix/key.pem")
if os.path.exists("/etc/pki/dovecot/private/dovecot.pem"):
os.remove("/etc/pki/dovecot/private/dovecot.pem")
if os.path.exists("/etc/pki/dovecot/certs/dovecot.pem"):
os.remove("/etc/pki/dovecot/certs/dovecot.pem")
if os.path.exists("/etc/dovecot/key.pem"):
os.remove("/etc/dovecot/key.pem")
if os.path.exists("/etc/dovecot/cert.pem"):
os.remove("/etc/dovecot/cert.pem")
## Postfix
shutil.copy(srcPrivKey, "/etc/postfix/key.pem")
shutil.copy(srcFullChain, "/etc/postfix/cert.pem")
## Dovecot
shutil.copy(srcPrivKey, "/etc/pki/dovecot/private/dovecot.pem")
shutil.copy(srcFullChain, "/etc/pki/dovecot/certs/dovecot.pem")
## Dovecot 2ND
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"
data = open(filePath,'r').readlines()
writeFile = open(filePath,'w')
for items in data:
if items.find('postmaster_address') > -1:
writeFile.writelines(' postmaster_address = postmaster@' + virtualHost + '\n')
else:
writeFile.writelines(items)
writeFile.close()
## Update myhostname address postfix
filePath = "/etc/postfix/main.cf"
data = open(filePath, 'r').readlines()
writeFile = open(filePath, 'w')
for items in data:
if items.find('myhostname') > -1:
writeFile.writelines('myhostname = ' + virtualHost + '\n')
else:
writeFile.writelines(items)
writeFile.close()
command = 'systemctl restart postfix'
subprocess.call(shlex.split(command))
command = 'systemctl restart dovecot'
subprocess.call(shlex.split(command))
print "1,None"
except BaseException,msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [issueSSLForHostName]")
print "0,"+str(msg)
def saveSSL(virtualHost,pathToStoreSSL,keyPath,certPath,sslCheck): def saveSSL(virtualHost,pathToStoreSSL,keyPath,certPath,sslCheck):
@@ -1693,6 +1828,8 @@ def main():
installJoomla(args.virtualHostName,args.path,args.virtualHostUser,args.dbName,args.dbUser,args.dbPassword,args.username,args.password,args.prefix,args.sitename) installJoomla(args.virtualHostName,args.path,args.virtualHostUser,args.dbName,args.dbUser,args.dbPassword,args.username,args.password,args.prefix,args.sitename)
elif args.function == "issueSSLForHostName": elif args.function == "issueSSLForHostName":
issueSSLForHostName(args.virtualHostName,args.path) issueSSLForHostName(args.virtualHostName,args.path)
elif args.function == "issueSSLForMailServer":
issueSSLForMailServer(args.virtualHostName,args.path)
elif args.function == "findDomainBW": elif args.function == "findDomainBW":
virtualHostUtilities.findDomainBW(args.virtualHostName, int(args.bandwidth)) virtualHostUtilities.findDomainBW(args.virtualHostName, int(args.bandwidth))

View File

@@ -47,7 +47,7 @@ app.controller('createNameserver', function($scope,$http) {
function ListInitialDatas(response) { function ListInitialDatas(response) {
if(response.data.NSCreation == 1){ if(response.data.NSCreation === 1){
$scope.createNameserverLoading = true; $scope.createNameserverLoading = true;
$scope.nameserverCreationFailed = true; $scope.nameserverCreationFailed = true;
$scope.nameserverCreated = false; $scope.nameserverCreated = false;
@@ -119,7 +119,7 @@ app.controller('createDNSZone', function($scope,$http) {
function ListInitialDatas(response) { function ListInitialDatas(response) {
if(response.data.zoneCreation == 1){ if(response.data.zoneCreation === 1){
$scope.createDNSZoneLoading = true; $scope.createDNSZoneLoading = true;
$scope.dnsZoneCreationFailed = true; $scope.dnsZoneCreationFailed = true;
$scope.dnsZoneCreated = false; $scope.dnsZoneCreated = false;
@@ -160,23 +160,46 @@ app.controller('createDNSZone', function($scope,$http) {
app.controller('addModifyDNSRecords', function($scope,$http) { app.controller('addModifyDNSRecords', function($scope,$http) {
$scope.addRecordsBox = true; $scope.addRecordsBox = true;
$scope.currentRecords = true; $scope.currentRecords = true;
$scope.canNotFetchRecords = true; $scope.canNotFetchRecords = true;
$scope.recordsFetched = true; $scope.recordsFetched = true;
$scope.recordDeleted = true; $scope.recordDeleted = true;
$scope.recordAdded = true; $scope.recordAdded = true;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.recordsLoading = true; $scope.recordsLoading = true;
$scope.recordDeleted = true; $scope.recordDeleted = true;
$scope.couldNotDeleteRecords = true; $scope.couldNotDeleteRecords = true;
$scope.couldNotAddRecord = true; $scope.couldNotAddRecord = true;
$scope.recordValueDefault = false; $scope.recordValueDefault = false;
$scope.recordValueMX = true;
$scope.recordValueAAAA = true; // Hide records boxes
$scope.recordValueCNAME = true; $(".aaaaRecord").hide();
$scope.recordValueSPF = true; $(".cNameRecord").hide();
$scope.recordValueTXT = true; $(".mxRecord").hide();
$(".txtRecord").hide();
$(".spfRecord").hide();
$(".nsRecord").hide();
$(".soaRecord").hide();
$(".srvRecord").hide();
var currentSelection = "aRecord";
$("#"+currentSelection).addClass("active");
$scope.fetchRecordsTabs = function (recordType) {
$("#"+currentSelection).removeClass("active");
$("."+currentSelection).hide();
$scope.recordsLoading = false;
currentSelection = recordType;
$("#"+currentSelection).addClass("active");
$("."+currentSelection).show();
populateCurrentRecords();
};
$scope.fetchRecords = function(){ $scope.fetchRecords = function(){
@@ -186,7 +209,7 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
}; };
$scope.addDNSRecord = function(){ $scope.addDNSRecord = function(type){
$scope.recordsLoading = false; $scope.recordsLoading = false;
@@ -194,56 +217,82 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
url = "/dns/addDNSRecord"; url = "/dns/addDNSRecord";
var selectedZone = $scope.selectedZone;
var recordName = $scope.recordName;
var recordType = $scope.recordType;
//specific values
var recordContentMX = "";
var recordContentA = "";
var recordContentAAAA = "";
var recordContentCNAME = "";
var recordContentSPF = "";
var recordContentTXT = "";
// Record specific values // Record specific values
if($scope.recordType=="MX"){ var data = {};
recordContentMX = $scope.recordContentMX;
if(type === "MX"){
data.selectedZone = $scope.selectedZone;
data.recordName = $scope.recordName;
data.recordContentMX = $scope.recordContentMX;
data.priority = $scope.priority;
data.ttl = $scope.ttl;
data.recordType = type;
} }
else if($scope.recordType=="A"){ else if(type === "A"){
recordContentA = $scope.recordContentA;
data.selectedZone = $scope.selectedZone;
data.recordName = $scope.recordName;
data.recordContentA = $scope.recordContentA;
data.ttl = $scope.ttl;
data.recordType = type;
} }
else if($scope.recordType=="AAAA"){ else if(type === "AAAA"){
recordContentAAAA = $scope.recordContentAAAA; data.selectedZone = $scope.selectedZone;
data.recordName = $scope.recordName;
data.recordContentAAAA = $scope.recordContentAAAA;
data.ttl = $scope.ttl;
data.recordType = type;
} }
else if($scope.recordType=="CNAME"){ else if(type === "CNAME"){
recordContentCNAME = $scope.recordContentCNAME; data.selectedZone = $scope.selectedZone;
data.recordName = $scope.recordName;
data.recordContentCNAME = $scope.recordContentCNAME;
data.ttl = $scope.ttl;
data.recordType = type;
} }
else if($scope.recordType=="SPF"){ else if(type === "SPF"){
recordContentSPF = $scope.recordContentSPF; data.selectedZone = $scope.selectedZone;
data.recordName = $scope.recordName;
data.recordContentSPF = $scope.recordContentSPF;
data.ttl = $scope.ttl;
data.recordType = type;
} }
else if($scope.recordType=="TXT"){ else if(type === "SOA"){
recordContentTXT = $scope.recordContentTXT; data.selectedZone = $scope.selectedZone;
data.recordName = $scope.selectedZone;
data.recordContentSOA = $scope.recordContentSOA;
data.ttl = $scope.ttl;
data.recordType = type;
}
else if(type === "TXT"){
data.selectedZone = $scope.selectedZone;
data.recordName = $scope.recordName;
data.recordContentTXT = $scope.recordContentTXT;
data.ttl = $scope.ttl;
data.recordType = type;
}
else if(type === "NS"){
data.selectedZone = $scope.selectedZone;
data.recordName = $scope.selectedZone;
data.recordContentNS = $scope.recordContentNS;
data.ttl = $scope.ttl;
data.recordType = type;
}
else if(type === "SRV"){
data.selectedZone = $scope.selectedZone;
data.recordName = $scope.recordName;
data.recordContentSRV = $scope.recordContentSRV;
data.priority = $scope.priority;
data.ttl = $scope.ttl;
data.recordType = type;
} }
var data = {
selectedZone:selectedZone,
recordName:recordName,
recordType:recordType,
recordContentA:recordContentA,
recordContentMX:recordContentMX,
recordContentAAAA:recordContentAAAA,
recordContentCNAME:recordContentCNAME,
recordContentSPF:recordContentSPF,
recordContentTXT:recordContentTXT,
};
var config = { var config = {
headers : { headers : {
@@ -258,7 +307,7 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
function ListInitialDatas(response) { function ListInitialDatas(response) {
if(response.data.add_status == 1){ if(response.data.add_status === 1){
populateCurrentRecords(); populateCurrentRecords();
@@ -313,6 +362,7 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
var data = { var data = {
selectedZone:selectedZone, selectedZone:selectedZone,
currentSelection:currentSelection
}; };
var config = { var config = {
@@ -327,9 +377,7 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
function ListInitialDatas(response) { function ListInitialDatas(response) {
if(response.data.fetchStatus === 1){
if(response.data.fetchStatus == 1){
$scope.records = JSON.parse(response.data.data); $scope.records = JSON.parse(response.data.data);
@@ -378,7 +426,6 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
}; };
$scope.deleteRecord = function(id){ $scope.deleteRecord = function(id){
@@ -469,66 +516,6 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
// MX Record Settings
$scope.detectType = function(){
if($scope.recordType=="MX")
{
$scope.recordValueDefault = true;
$scope.recordValueMX = false;
$scope.recordValueAAAA = true;
$scope.recordValueCNAME = true;
$scope.recordValueSPF = true;
$scope.recordValueTXT = true;
}
else if($scope.recordType=="A"){
$scope.recordValueDefault = false;
$scope.recordValueMX = true;
$scope.recordValueAAAA = true;
$scope.recordValueCNAME = true;
$scope.recordValueSPF = true;
$scope.recordValueTXT = true;
}
else if($scope.recordType=="AAAA"){
$scope.recordValueDefault = true;
$scope.recordValueMX = true;
$scope.recordValueAAAA = false;
$scope.recordValueCNAME = true;
$scope.recordValueSPF = true;
$scope.recordValueTXT = true;
}
else if($scope.recordType=="CNAME"){
$scope.recordValueDefault = true;
$scope.recordValueMX = true;
$scope.recordValueAAAA = true;
$scope.recordValueCNAME = false;
$scope.recordValueSPF = true;
$scope.recordValueTXT = true;
}
else if($scope.recordType=="SPF"){
$scope.recordValueDefault = true;
$scope.recordValueMX = true;
$scope.recordValueAAAA = true;
$scope.recordValueCNAME = true;
$scope.recordValueSPF = false;
$scope.recordValueTXT = true;
}
else if($scope.recordType=="TXT"){
$scope.recordValueDefault = true;
$scope.recordValueMX = true;
$scope.recordValueAAAA = true;
$scope.recordValueCNAME = true;
$scope.recordValueSPF = true;
$scope.recordValueTXT = false;
}
};
}); });
/* Java script code to delete DNS Zone */ /* Java script code to delete DNS Zone */
@@ -549,7 +536,7 @@ app.controller('deleteDNSZone', function($scope,$http) {
$scope.deleteZoneButton = false; $scope.deleteZoneButton = false;
$scope.deleteFailure = true; $scope.deleteFailure = true;
$scope.deleteSuccess = true; $scope.deleteSuccess = true;
} };
$scope.deleteZoneFinal = function(){ $scope.deleteZoneFinal = function(){

View File

@@ -175,3 +175,90 @@ app.controller('sslIssueForHostNameCtrl', function($scope,$http) {
}); });
/* Java script code to issue SSL for hostname */ /* Java script code to issue SSL for hostname */
/* Java script code to issue SSL for MailServer */
app.controller('sslIssueForMailServer', function($scope,$http) {
$scope.sslIssueCtrl = true;
$scope.manageSSLLoading = true;
$scope.issueSSLBtn = true;
$scope.canNotIssue = true;
$scope.sslIssued = true;
$scope.couldNotConnect = true;
$scope.showbtn = function () {
$scope.issueSSLBtn = false;
};
$scope.issueSSL = function(){
$scope.manageSSLLoading = false;
var url = "/manageSSL/obtainMailServerSSL";
var data = {
virtualHost:$scope.virtualHost,
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.SSL === 1){
$scope.sslIssueCtrl = true;
$scope.manageSSLLoading = true;
$scope.issueSSLBtn = false;
$scope.canNotIssue = true;
$scope.sslIssued = false;
$scope.couldNotConnect = true;
$scope.sslDomain = $scope.virtualHost;
}
else
{
$scope.sslIssueCtrl = true;
$scope.manageSSLLoading = true;
$scope.issueSSLBtn = false;
$scope.canNotIssue = false;
$scope.sslIssued = true;
$scope.couldNotConnect = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.sslIssueCtrl = true;
$scope.manageSSLLoading = true;
$scope.issueSSLBtn = false;
$scope.canNotIssue = true;
$scope.sslIssued = true;
$scope.couldNotConnect = false;
}
};
});
/* Java script code to issue SSL for MailServer */