mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-05-07 01:07:05 +02:00
virtualenv
This commit is contained in:
@@ -557,6 +557,7 @@
|
||||
<div class="sidebar-submenu">
|
||||
|
||||
<ul>
|
||||
<li><a href="{% url 'emailPolicyServer' %}" title="{% trans 'Email Policy Server' %}"><span>{% trans "Email Policy Server" %}</span></a></li>
|
||||
<li><a href="{% url 'listDomains' %}" title="{% trans 'Email Limits' %}"><span>{% trans "Email Limits" %}</span></a></li>
|
||||
<li><a href="{% url 'SpamAssassin' %}" title="{% trans 'SpamAssassin Configurations' %}"><span>{% trans "SpamAssassin" %}</span></a></li>
|
||||
</ul>
|
||||
|
||||
@@ -954,4 +954,139 @@ app.controller('SpamAssassin', function($scope, $http, $timeout, $window) {
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
/* Java script code for SpamAssassin */
|
||||
|
||||
|
||||
/* Java script code for Email Policy Server */
|
||||
|
||||
app.controller('policyServer', function($scope, $http, $timeout, $window) {
|
||||
|
||||
$scope.policyServerLoading = true;
|
||||
$scope.failedToFetch = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.changesApplied = true;
|
||||
|
||||
|
||||
///// SpamAssassin configs
|
||||
|
||||
var report_safe = false;
|
||||
|
||||
|
||||
$('#policServerStatus').change(function() {
|
||||
policServerStatus = $(this).prop('checked');
|
||||
});
|
||||
|
||||
fetchPolicServerStatus();
|
||||
function fetchPolicServerStatus(){
|
||||
|
||||
$scope.policyServerLoading = false;
|
||||
|
||||
$('#policServerStatus').bootstrapToggle('off');
|
||||
|
||||
url = "/emailPremium/fetchPolicyServerStatus";
|
||||
|
||||
var data = {};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
$scope.policyServerLoading = true;
|
||||
|
||||
if(response.data.status === 1){
|
||||
|
||||
if (response.data.installCheck === 1) {
|
||||
$('#policServerStatus').bootstrapToggle('on');
|
||||
}
|
||||
|
||||
}else{
|
||||
$scope.failedToFetch = false;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.changesApplied = true;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.policyServerLoading = true;
|
||||
$scope.failedToFetch = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.changesApplied = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$scope.savePolicServerStatus = function () {
|
||||
|
||||
$scope.policyServerLoading = false;
|
||||
$scope.failedToFetch = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.changesApplied = true;
|
||||
|
||||
|
||||
|
||||
url = "/emailPremium/savePolicyServerStatus";
|
||||
|
||||
var data = {
|
||||
policServerStatus:policServerStatus
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.policyServerLoading = true;
|
||||
|
||||
if(response.data.status === 1){
|
||||
|
||||
$scope.failedToFetch = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.changesApplied = false;
|
||||
|
||||
}
|
||||
else{
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
$scope.failedToFetch = false;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.changesApplied = true;
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.policyServerLoading = true;
|
||||
$scope.failedToFetch = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.changesApplied = true;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
|
||||
/* Java script code for Email Policy Server */
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
|
||||
<div class="content-box-wrapper">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="datatable-example">
|
||||
|
||||
@@ -17,9 +17,24 @@
|
||||
|
||||
<div ng-controller="listDomains" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
|
||||
<h3 class="title-hero">
|
||||
{% trans "Domains" %} <img ng-hide="emailLimitsLoading" src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
|
||||
{% if installCheck == 0 %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
|
||||
<h3>{% trans "Email Policy Server is not enabled " %}
|
||||
<a href="{% url 'emailPolicyServer' %}">
|
||||
<button class="btn btn-alt btn-hover btn-blue-alt">
|
||||
<span>{% trans "Enable Now." %}</span>
|
||||
<i class="glyph-icon icon-arrow-right"></i>
|
||||
</button></a></h3>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="datatable-example">
|
||||
@@ -82,6 +97,8 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
81
emailPremium/templates/emailPremium/policyServer.html
Normal file
81
emailPremium/templates/emailPremium/policyServer.html
Normal file
@@ -0,0 +1,81 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Email Policy Server - 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 "Email Policy Server Configurations!" %} </h2>
|
||||
<p>{% trans "Turn ON Email Policy Server to use Email Limits Feature. " %}</p>
|
||||
</div>
|
||||
|
||||
<div ng-controller="policyServer" class="example-box-wrapper">
|
||||
<div style="border-radius: 25px;border-color:#3498db" class="content-box">
|
||||
<h3 class="content-box-header bg-blue">
|
||||
{% trans "Email Policy Server" %} <img ng-hide="policyServerLoading" src="/static/images/loading.gif">
|
||||
</h3>
|
||||
|
||||
<div class="content-box-wrapper">
|
||||
<div class="row">
|
||||
|
||||
<div style="padding: 2%" class="col-md-12">
|
||||
<form action="/" id="createPackages" class="form-horizontal bordered-row">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label">Server Status</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="checkbox" id="policServerStatus" data-toggle="toggle">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="savePolicServerStatus()" class="btn btn-primary btn-lg btn-block">{% trans "Save changes." %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
|
||||
<div ng-hide="failedToFetch" class="alert alert-danger">
|
||||
<p>{% trans "Error message: " %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="changesApplied" class="alert alert-success">
|
||||
<p>{% trans "Changes successfully applied." %}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="couldNotConnect" class="alert alert-danger">
|
||||
<p>{% trans "Could not connect. Please refresh this page." %} </p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
@@ -30,6 +30,10 @@ urlpatterns = [
|
||||
url(r'^installStatusSpamAssassin$', views.installStatusSpamAssassin, name='installStatusSpamAssassin'),
|
||||
url(r'^fetchSpamAssassinSettings$', views.fetchSpamAssassinSettings, name='fetchSpamAssassinSettings'),
|
||||
url(r'^saveSpamAssassinConfigurations$', views.saveSpamAssassinConfigurations, name='saveSpamAssassinConfigurations'),
|
||||
url(r'^emailPolicyServer$', views.emailPolicyServer, name='emailPolicyServer'),
|
||||
url(r'^fetchPolicyServerStatus$', views.fetchPolicyServerStatus, name='fetchPolicyServerStatus'),
|
||||
|
||||
url(r'^savePolicyServerStatus$', views.savePolicyServerStatus, name='savePolicyServerStatus'),
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,24 @@ def listDomains(request):
|
||||
else:
|
||||
return HttpResponse("Only administrator can view this page.")
|
||||
|
||||
## Check if Policy Server is installed.
|
||||
|
||||
command = 'sudo cat /etc/postfix/main.cf'
|
||||
output = subprocess.check_output(shlex.split(command)).split('\n')
|
||||
|
||||
installCheck = 0
|
||||
|
||||
for items in output:
|
||||
if items.find('check_policy_service inet:localhost:1089') > -1:
|
||||
installCheck = 1
|
||||
break
|
||||
|
||||
if installCheck == 0:
|
||||
return render(request, 'emailPremium/listDomains.html', {"installCheck": installCheck})
|
||||
|
||||
###
|
||||
|
||||
|
||||
|
||||
pages = float(len(websites)) / float(10)
|
||||
pagination = []
|
||||
@@ -51,7 +69,7 @@ def listDomains(request):
|
||||
pagination.append('<li><a href="\#">' + str(i) + '</a></li>')
|
||||
|
||||
|
||||
return render(request,'emailPremium/listDomains.html',{"pagination":pagination})
|
||||
return render(request,'emailPremium/listDomains.html',{"pagination":pagination, "installCheck": installCheck})
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
@@ -850,8 +868,6 @@ def saveSpamAssassinConfigurations(request):
|
||||
else:
|
||||
report_safe = "report_safe 0"
|
||||
|
||||
print report_safe
|
||||
|
||||
required_hits = "required_hits " + required_hits
|
||||
rewrite_header = "rewrite_header " + rewrite_header
|
||||
required_score = "required_score " + required_score
|
||||
@@ -898,4 +914,111 @@ def saveSpamAssassinConfigurations(request):
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
data_ret = {'saveStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
## Email Policy Server
|
||||
|
||||
def emailPolicyServer(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
|
||||
if admin.type != 1:
|
||||
return HttpResponse("Only administrator can view this page.")
|
||||
|
||||
return render(request, 'emailPremium/policyServer.html')
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def fetchPolicyServerStatus(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
try:
|
||||
if request.method == 'POST':
|
||||
|
||||
admin = Administrator.objects.get(pk=request.session['userID'])
|
||||
|
||||
if admin.type != 1:
|
||||
dic = {'status': 0, 'error_message': "Only administrator can view this page."}
|
||||
json_data = json.dumps(dic)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
command = 'sudo cat /etc/postfix/main.cf'
|
||||
output = subprocess.check_output(shlex.split(command)).split('\n')
|
||||
|
||||
installCheck = 0
|
||||
|
||||
for items in output:
|
||||
if items.find('check_policy_service inet:localhost:1089') > -1:
|
||||
installCheck = 1
|
||||
break
|
||||
|
||||
|
||||
data_ret = {'status': 1, 'error_message': 'None', 'installCheck' : installCheck}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException,msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except KeyError,msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def savePolicyServerStatus(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
try:
|
||||
if request.method == 'POST':
|
||||
|
||||
admin = Administrator.objects.get(pk=request.session['userID'])
|
||||
|
||||
if admin.type != 1:
|
||||
dic = {'status': 0, 'error_message': "Only administrator can view this page."}
|
||||
json_data = json.dumps(dic)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
data = json.loads(request.body)
|
||||
|
||||
policServerStatus = data['policServerStatus']
|
||||
|
||||
install = '0'
|
||||
|
||||
if policServerStatus == True:
|
||||
install = "1"
|
||||
|
||||
## save configuration data
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
|
||||
|
||||
execPath = execPath + " savePolicyServerStatus --install " + install
|
||||
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'status': 1, 'error_message': "None"}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
data_ret = {'status': 0, 'error_message': output}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException,msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except KeyError,msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
@@ -9,7 +9,7 @@ User=cyberpanel
|
||||
Group=cyberpanel
|
||||
RuntimeDirectory=gunicorn
|
||||
WorkingDirectory=/usr/local/CyberCP
|
||||
ExecStart=/usr/bin/gunicorn --pid /run/gunicorn/gucpid \
|
||||
ExecStart=/usr/local/CyberCP/bin/gunicorn --pid /run/gunicorn/gucpid \
|
||||
--bind 127.0.0.1:5003 CyberCP.wsgi
|
||||
ExecReload=/bin/kill -s HUP $MAINPID
|
||||
ExecStop=/bin/kill -s TERM $MAINPID
|
||||
|
||||
@@ -2716,6 +2716,112 @@ milter_default_action = accept
|
||||
logging.InstallLog.writeToFile(str(msg) + " [setupCLI]")
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def setupVirtualEnv():
|
||||
try:
|
||||
|
||||
##
|
||||
|
||||
count = 0
|
||||
while (1):
|
||||
command = "yum install -y libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel"
|
||||
res = subprocess.call(shlex.split(command))
|
||||
|
||||
if res == 1:
|
||||
count = count + 1
|
||||
preFlightsChecks.stdOut(
|
||||
"Trying to install project dependant modules, trying again, try number: " + str(count))
|
||||
if count == 3:
|
||||
logging.InstallLog.writeToFile(
|
||||
"Failed to install project dependant modules! [setupVirtualEnv]")
|
||||
preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt")
|
||||
sys.exit()
|
||||
else:
|
||||
logging.InstallLog.writeToFile("Project dependant modules installed successfully!")
|
||||
preFlightsChecks.stdOut("Project dependant modules installed successfully!!")
|
||||
break
|
||||
|
||||
##
|
||||
|
||||
|
||||
count = 0
|
||||
while (1):
|
||||
command = "pip install virtualenv"
|
||||
res = subprocess.call(shlex.split(command))
|
||||
|
||||
if res == 1:
|
||||
count = count + 1
|
||||
preFlightsChecks.stdOut(
|
||||
"Trying to install virtualenv, trying again, try number: " + str(count))
|
||||
if count == 3:
|
||||
logging.InstallLog.writeToFile(
|
||||
"Failed install virtualenv! [setupVirtualEnv]")
|
||||
preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt")
|
||||
sys.exit()
|
||||
else:
|
||||
logging.InstallLog.writeToFile("virtualenv installed successfully!")
|
||||
preFlightsChecks.stdOut("virtualenv installed successfully!")
|
||||
break
|
||||
|
||||
####
|
||||
|
||||
count = 0
|
||||
while (1):
|
||||
command = "virtualenv /usr/local/CyberCP"
|
||||
res = subprocess.call(shlex.split(command))
|
||||
|
||||
if res == 1:
|
||||
count = count + 1
|
||||
preFlightsChecks.stdOut(
|
||||
"Trying to setup virtualenv, trying again, try number: " + str(count))
|
||||
if count == 3:
|
||||
logging.InstallLog.writeToFile(
|
||||
"Failed to setup virtualenv! [setupVirtualEnv]")
|
||||
preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt")
|
||||
sys.exit()
|
||||
else:
|
||||
logging.InstallLog.writeToFile("virtualenv setuped successfully!")
|
||||
preFlightsChecks.stdOut("virtualenv setuped successfully!")
|
||||
break
|
||||
|
||||
##
|
||||
|
||||
env_path = '/usr/local/CyberCP'
|
||||
subprocess.call(['virtualenv', env_path])
|
||||
activate_this = os.path.join(env_path, 'bin', 'activate_this.py')
|
||||
execfile(activate_this, dict(__file__=activate_this))
|
||||
|
||||
##
|
||||
|
||||
count = 0
|
||||
while (1):
|
||||
command = "pip install -r /usr/local/CyberCP/requirments.txt"
|
||||
res = subprocess.call(shlex.split(command))
|
||||
|
||||
if res == 1:
|
||||
count = count + 1
|
||||
preFlightsChecks.stdOut(
|
||||
"Trying to install project dependant modules, trying again, try number: " + str(count))
|
||||
if count == 3:
|
||||
logging.InstallLog.writeToFile(
|
||||
"Failed to install project dependant modules! [setupVirtualEnv]")
|
||||
preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt")
|
||||
sys.exit()
|
||||
else:
|
||||
logging.InstallLog.writeToFile("Project dependant modules installed successfully!")
|
||||
preFlightsChecks.stdOut("Project dependant modules installed successfully!!")
|
||||
break
|
||||
|
||||
command = "systemctl restart gunicorn.socket"
|
||||
res = subprocess.call(shlex.split(command))
|
||||
|
||||
|
||||
|
||||
except OSError, msg:
|
||||
logging.InstallLog.writeToFile(str(msg) + " [setupVirtualEnv]")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
@@ -2801,6 +2907,7 @@ def main():
|
||||
checks.configureOpenDKIM()
|
||||
|
||||
checks.modSecPreReqs()
|
||||
checks.setupVirtualEnv()
|
||||
checks.installation_successfull()
|
||||
|
||||
logging.InstallLog.writeToFile("CyberPanel installation successfully completed!")
|
||||
|
||||
@@ -348,6 +348,18 @@ class DNS:
|
||||
record.save()
|
||||
return
|
||||
|
||||
if type == 'MX':
|
||||
record = Records(domainOwner=zone,
|
||||
domain_id=zone.id,
|
||||
name=name,
|
||||
type=type,
|
||||
content=value,
|
||||
ttl=ttl,
|
||||
prio=priority,
|
||||
disabled=0,
|
||||
auth=1)
|
||||
record.save()
|
||||
|
||||
|
||||
if Records.objects.filter(name=name, type=type).count() == 0:
|
||||
record = Records(domainOwner=zone,
|
||||
|
||||
@@ -520,6 +520,52 @@ milter_default_action = accept
|
||||
str(msg) + " [saveSpamAssassinConfigs]")
|
||||
print "0," + str(msg)
|
||||
|
||||
@staticmethod
|
||||
def savePolicyServerStatus(install):
|
||||
try:
|
||||
|
||||
postfixPath = '/etc/postfix/main.cf'
|
||||
|
||||
if install == '1':
|
||||
if not os.path.exists('/etc/systemd/system/cpecs.service'):
|
||||
shutil.copy("/usr/local/CyberCP/postfixSenderPolicy/cpecs.service", "/etc/systemd/system/cpecs.service")
|
||||
|
||||
command = 'systemctl start cpecs'
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
writeToFile = open(postfixPath, 'a')
|
||||
writeToFile.writelines('smtpd_data_restrictions = check_policy_service inet:localhost:1089\n')
|
||||
writeToFile.close()
|
||||
|
||||
command = 'systemctl restart postfix'
|
||||
subprocess.call(shlex.split(command))
|
||||
else:
|
||||
|
||||
data = open(postfixPath, 'r').readlines()
|
||||
writeToFile = open(postfixPath, 'w')
|
||||
|
||||
for items in data:
|
||||
if items.find('check_policy_service inet:localhost:1089') > -1:
|
||||
continue
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
|
||||
writeToFile.close()
|
||||
|
||||
command = 'systemctl stop cpecs'
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = 'systemctl restart postfix'
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
print "1,None"
|
||||
return
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [savePolicyServerStatus]")
|
||||
print "0," + str(msg)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -529,6 +575,7 @@ def main():
|
||||
parser.add_argument('--userName', help='Email Username!')
|
||||
parser.add_argument('--password', help='Email password!')
|
||||
parser.add_argument('--tempConfigPath', help='Temporary Configuration Path!')
|
||||
parser.add_argument('--install', help='Enable/Disable Policy Server!')
|
||||
|
||||
|
||||
|
||||
@@ -544,6 +591,8 @@ def main():
|
||||
mailUtilities.configureSpamAssassin()
|
||||
elif args.function == "saveSpamAssassinConfigs":
|
||||
mailUtilities.saveSpamAssassinConfigs(args.tempConfigPath)
|
||||
elif args.function == 'savePolicyServerStatus':
|
||||
mailUtilities.savePolicyServerStatus(args.install)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,46 +1,45 @@
|
||||
# Copyright 2018 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import sys
|
||||
import subprocess
|
||||
import shutil
|
||||
import argparse
|
||||
import os
|
||||
import shlex
|
||||
import time
|
||||
import string
|
||||
import random
|
||||
|
||||
# [START drive_quickstart]
|
||||
"""
|
||||
Shows basic usage of the Drive v3 API.
|
||||
def setupVirtualEnv():
|
||||
##
|
||||
|
||||
Creates a Drive v3 API service and prints the names and ids of the last 10 files
|
||||
the user has access to.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from apiclient.discovery import build
|
||||
from httplib2 import Http
|
||||
from oauth2client import file, client, tools
|
||||
|
||||
# Setup the Drive v3 API
|
||||
SCOPES = 'https://www.googleapis.com/auth/drive.metadata.readonly'
|
||||
store = file.Storage('credentials.json')
|
||||
creds = store.get()
|
||||
if not creds or creds.invalid:
|
||||
flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
|
||||
creds = tools.run_flow(flow, store)
|
||||
service = build('drive', 'v3', http=creds.authorize(Http()))
|
||||
command = "yum install -y libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel"
|
||||
res = subprocess.call(shlex.split(command))
|
||||
|
||||
# Call the Drive v3 API
|
||||
results = service.files().list(
|
||||
pageSize=10, fields="nextPageToken, files(id, name)").execute()
|
||||
items = results.get('files', [])
|
||||
if not items:
|
||||
print('No files found.')
|
||||
else:
|
||||
print('Files:')
|
||||
for item in items:
|
||||
print('{0} ({1})'.format(item['name'], item['id']))
|
||||
# [END drive_quickstart]
|
||||
##
|
||||
|
||||
|
||||
command = "pip install virtualenv"
|
||||
res = subprocess.call(shlex.split(command))
|
||||
|
||||
####
|
||||
|
||||
command = "virtualenv /usr/local/CyberCP"
|
||||
res = subprocess.call(shlex.split(command))
|
||||
|
||||
##
|
||||
env_path = '/usr/local/CyberCP'
|
||||
if not os.path.exists(env_path):
|
||||
subprocess.call(['virtualenv', env_path])
|
||||
activate_this = os.path.join(env_path, 'bin', 'activate_this.py')
|
||||
execfile(activate_this, dict(__file__=activate_this))
|
||||
|
||||
command = "pip install -r /usr/local/CyberCP/requirments.txt"
|
||||
res = subprocess.call(shlex.split(command))
|
||||
|
||||
##
|
||||
|
||||
command = "systemctl restart gunicorn.socket"
|
||||
res = subprocess.call(shlex.split(command))
|
||||
|
||||
|
||||
setupVirtualEnv()
|
||||
55
requirments.txt
Normal file
55
requirments.txt
Normal file
@@ -0,0 +1,55 @@
|
||||
acme==0.21.1
|
||||
asn1crypto==0.24.0
|
||||
Babel==0.9.6
|
||||
backports.ssl-match-hostname==3.5.0.1
|
||||
certbot==0.21.1
|
||||
certifi==2018.4.16
|
||||
cffi==1.11.5
|
||||
chardet==3.0.4
|
||||
ConfigArgParse==0.13.0
|
||||
configobj==4.7.2
|
||||
cryptography==2.2.2
|
||||
decorator==3.4.0
|
||||
Django==1.11
|
||||
enum34==1.1.6
|
||||
funcsigs==1.0.2
|
||||
future==0.16.0
|
||||
gunicorn==19.8.1
|
||||
idna==2.6
|
||||
iniparse==0.4
|
||||
ipaddress==1.0.16
|
||||
IPy==0.75
|
||||
Jinja2==2.7.2
|
||||
josepy==1.1.0
|
||||
jsonpatch==1.2
|
||||
jsonpointer==1.9
|
||||
kitchen==1.1.1
|
||||
MarkupSafe==0.11
|
||||
mock==2.0.0
|
||||
MySQL-python==1.2.5
|
||||
parsedatetime==2.4
|
||||
pbr==4.0.4
|
||||
perf==0.1
|
||||
pexpect==4.4.0
|
||||
prettytable==0.7.2
|
||||
psutil==5.4.3
|
||||
ptyprocess==0.6.0
|
||||
pycparser==2.18
|
||||
pycurl==7.19.0
|
||||
pygpgme==0.3
|
||||
pyliblzma==0.5.3
|
||||
pyOpenSSL==17.5.0
|
||||
pyRFC3339==1.1
|
||||
pyserial==2.6
|
||||
pytz==2018.4
|
||||
pyudev==0.15
|
||||
pyxattr==0.5.1
|
||||
PyYAML==3.10
|
||||
requests==2.18.4
|
||||
requests-file==1.4.3
|
||||
six==1.9.0
|
||||
tldextract==2.2.0
|
||||
urllib3==1.22
|
||||
zope.component==4.4.1
|
||||
zope.event==4.3.0
|
||||
zope.interface==4.5.0
|
||||
@@ -954,4 +954,139 @@ app.controller('SpamAssassin', function($scope, $http, $timeout, $window) {
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
/* Java script code for SpamAssassin */
|
||||
|
||||
|
||||
/* Java script code for Email Policy Server */
|
||||
|
||||
app.controller('policyServer', function($scope, $http, $timeout, $window) {
|
||||
|
||||
$scope.policyServerLoading = true;
|
||||
$scope.failedToFetch = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.changesApplied = true;
|
||||
|
||||
|
||||
///// SpamAssassin configs
|
||||
|
||||
var report_safe = false;
|
||||
|
||||
|
||||
$('#policServerStatus').change(function() {
|
||||
policServerStatus = $(this).prop('checked');
|
||||
});
|
||||
|
||||
fetchPolicServerStatus();
|
||||
function fetchPolicServerStatus(){
|
||||
|
||||
$scope.policyServerLoading = false;
|
||||
|
||||
$('#policServerStatus').bootstrapToggle('off');
|
||||
|
||||
url = "/emailPremium/fetchPolicyServerStatus";
|
||||
|
||||
var data = {};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
$scope.policyServerLoading = true;
|
||||
|
||||
if(response.data.status === 1){
|
||||
|
||||
if (response.data.installCheck === 1) {
|
||||
$('#policServerStatus').bootstrapToggle('on');
|
||||
}
|
||||
|
||||
}else{
|
||||
$scope.failedToFetch = false;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.changesApplied = true;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.policyServerLoading = true;
|
||||
$scope.failedToFetch = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.changesApplied = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$scope.savePolicServerStatus = function () {
|
||||
|
||||
$scope.policyServerLoading = false;
|
||||
$scope.failedToFetch = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.changesApplied = true;
|
||||
|
||||
|
||||
|
||||
url = "/emailPremium/savePolicyServerStatus";
|
||||
|
||||
var data = {
|
||||
policServerStatus:policServerStatus
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.policyServerLoading = true;
|
||||
|
||||
if(response.data.status === 1){
|
||||
|
||||
$scope.failedToFetch = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.changesApplied = false;
|
||||
|
||||
}
|
||||
else{
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
$scope.failedToFetch = false;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.changesApplied = true;
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.policyServerLoading = true;
|
||||
$scope.failedToFetch = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.changesApplied = true;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
|
||||
/* Java script code for Email Policy Server */
|
||||
Reference in New Issue
Block a user