mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-10 23:36:11 +01:00
complete the onboarding function
This commit is contained in:
@@ -5,7 +5,6 @@
|
|||||||
/* Utilities */
|
/* Utilities */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getCookie(name) {
|
function getCookie(name) {
|
||||||
var cookieValue = null;
|
var cookieValue = null;
|
||||||
if (document.cookie && document.cookie !== '') {
|
if (document.cookie && document.cookie !== '') {
|
||||||
@@ -576,8 +575,6 @@ app.controller('versionManagment', function ($scope, $http, $timeout) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
url = "/base/upgrade";
|
url = "/base/upgrade";
|
||||||
$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
|
$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
|
||||||
|
|
||||||
@@ -717,3 +714,156 @@ app.controller('designtheme', function ($scope, $http, $timeout) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
app.controller('OnboardingCP', function ($scope, $http, $timeout, $window) {
|
||||||
|
|
||||||
|
$scope.cyberpanelLoading = true;
|
||||||
|
$scope.ExecutionStatus = true;
|
||||||
|
$scope.ReportStatus = true;
|
||||||
|
$scope.OnboardineDone = true;
|
||||||
|
|
||||||
|
|
||||||
|
function statusFunc() {
|
||||||
|
$scope.cyberpanelLoading = false;
|
||||||
|
$scope.ExecutionStatus = false;
|
||||||
|
var url = "/emailPremium/statusFunc";
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
statusFile: statusFile
|
||||||
|
};
|
||||||
|
var config = {
|
||||||
|
headers: {
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
|
||||||
|
|
||||||
|
|
||||||
|
function ListInitialData(response) {
|
||||||
|
if (response.data.status === 1) {
|
||||||
|
if (response.data.abort === 1) {
|
||||||
|
$scope.functionProgress = {"width": "100%"};
|
||||||
|
$scope.functionStatus = response.data.currentStatus;
|
||||||
|
$scope.cyberpanelLoading = true;
|
||||||
|
$scope.OnboardineDone = false;
|
||||||
|
$timeout.cancel();
|
||||||
|
} else {
|
||||||
|
$scope.functionProgress = {"width": response.data.installationProgress + "%"};
|
||||||
|
$scope.functionStatus = response.data.currentStatus;
|
||||||
|
$timeout(statusFunc, 3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$scope.cyberpanelLoading = true;
|
||||||
|
$scope.functionStatus = response.data.error_message;
|
||||||
|
$scope.functionProgress = {"width": response.data.installationProgress + "%"};
|
||||||
|
$timeout.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function cantLoadInitialData(response) {
|
||||||
|
$scope.functionProgress = {"width": response.data.installationProgress + "%"};
|
||||||
|
$scope.functionStatus = 'Could not connect to server, please refresh this page.';
|
||||||
|
$timeout.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.RunOnboarding = function () {
|
||||||
|
$scope.cyberpanelLoading = false;
|
||||||
|
$scope.OnboardineDone = true;
|
||||||
|
|
||||||
|
var url = "/base/runonboarding";
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
hostname: $scope.hostname,
|
||||||
|
rDNSCheck: $scope.rDNSCheck
|
||||||
|
};
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
headers: {
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
|
||||||
|
|
||||||
|
function ListInitialData(response) {
|
||||||
|
$scope.cyberpanelLoading = true;
|
||||||
|
if (response.data.status === 1) {
|
||||||
|
statusFile = response.data.tempStatusPath;
|
||||||
|
statusFunc();
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
new PNotify({
|
||||||
|
title: 'Operation Failed!',
|
||||||
|
text: response.data.error_message,
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function cantLoadInitialData(response) {
|
||||||
|
$scope.cyberpanelLoading = true;
|
||||||
|
|
||||||
|
new PNotify({
|
||||||
|
title: 'Error',
|
||||||
|
text: 'Could not connect to server, please refresh this page.',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.RestartCyberPanel = function () {
|
||||||
|
$scope.cyberpanelLoading = false;
|
||||||
|
|
||||||
|
var url = "/base/RestartCyberPanel";
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
headers: {
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
|
||||||
|
$scope.cyberpanelLoading = true;
|
||||||
|
new PNotify({
|
||||||
|
title: 'Success',
|
||||||
|
text: 'Refresh your browser after 3 seconds to fetch new SSL.',
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
|
||||||
|
function ListInitialData(response) {
|
||||||
|
$scope.cyberpanelLoading = true;
|
||||||
|
if (response.data.status === 1) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
new PNotify({
|
||||||
|
title: 'Operation Failed!',
|
||||||
|
text: response.data.error_message,
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function cantLoadInitialData(response) {
|
||||||
|
$scope.cyberpanelLoading = true;
|
||||||
|
|
||||||
|
new PNotify({
|
||||||
|
title: 'Error',
|
||||||
|
text: 'Could not connect to server, please refresh this page.',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
@@ -849,22 +849,22 @@
|
|||||||
</div><!-- .sidebar-submenu -->
|
</div><!-- .sidebar-submenu -->
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
{# <li id="sidebar-menu-item-containerization">#}
|
{# <li id="sidebar-menu-item-containerization">#}
|
||||||
{# <a href="#" title="{% trans 'Containerization' %}">#}
|
{# <a href="#" title="{% trans 'Containerization' %}">#}
|
||||||
{# <i class="glyph-icon icon-linecons-fire"></i>#}
|
{# <i class="glyph-icon icon-linecons-fire"></i>#}
|
||||||
{# <span>{% trans "Containerization" %}</span>#}
|
{# <span>{% trans "Containerization" %}</span>#}
|
||||||
{# <span class="bs-label badge-yellow">{% trans "NEW" %}</span>#}
|
{# <span class="bs-label badge-yellow">{% trans "NEW" %}</span>#}
|
||||||
{# </a>#}
|
{# </a>#}
|
||||||
{# <div class="sidebar-submenu">#}
|
{# <div class="sidebar-submenu">#}
|
||||||
{##}
|
{##}
|
||||||
{# <ul>#}
|
{# <ul>#}
|
||||||
{# <li><a href="{% url 'cHome' %}"#}
|
{# <li><a href="{% url 'cHome' %}"#}
|
||||||
{# title="{% trans 'Create Website Limits' %}"><span>{% trans "Create Limits" %}</span></a>#}
|
{# title="{% trans 'Create Website Limits' %}"><span>{% trans "Create Limits" %}</span></a>#}
|
||||||
{# </li>#}
|
{# </li>#}
|
||||||
{# </ul>#}
|
{# </ul>#}
|
||||||
{##}
|
{##}
|
||||||
{# </div><!-- .sidebar-submenu -->#}
|
{# </div><!-- .sidebar-submenu -->#}
|
||||||
{# </li>#}
|
{# </li>#}
|
||||||
|
|
||||||
<li id="sidebar-menu-item-docker">
|
<li id="sidebar-menu-item-docker">
|
||||||
<a href="#" title="{% trans 'Docker' %}">
|
<a href="#" title="{% trans 'Docker' %}">
|
||||||
@@ -1120,7 +1120,13 @@
|
|||||||
<div id="page-content-wrapper">
|
<div id="page-content-wrapper">
|
||||||
<div id="page-content">
|
<div id="page-content">
|
||||||
|
|
||||||
|
{% if onboarding == 0 %}
|
||||||
|
<div ng-hide="success" class="alert alert-info">
|
||||||
|
<p>{{ onboardingError | safe }}</p>
|
||||||
|
</div>
|
||||||
|
{% elif onboarding == 3 %}
|
||||||
|
<p>Looks like something is wrong with your initial setup, please double check on <a href="/base/onboarding">Setup Wizard.</a> </p>
|
||||||
|
{% endif %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
@@ -1156,9 +1162,9 @@
|
|||||||
<script src="{% static 'containerization/containerization.js' %}?ver={{ version }}"></script>
|
<script src="{% static 'containerization/containerization.js' %}?ver={{ version }}"></script>
|
||||||
<script src="{% static 'CLManager/CLManager.js' %}?ver={{ version }}"></script>
|
<script src="{% static 'CLManager/CLManager.js' %}?ver={{ version }}"></script>
|
||||||
<script src="{% static 'IncBackups/IncBackups.js' %}?ver={{ version }}"></script>
|
<script src="{% static 'IncBackups/IncBackups.js' %}?ver={{ version }}"></script>
|
||||||
<script src="{% static 'WebTerminal/term.js' %}?ver={{ version }}"></script>
|
{# <script src="{% static 'WebTerminal/term.js' %}?ver={{ version }}"></script>#}
|
||||||
<script src="{% static 'WebTerminal/ws.js' %}?ver={{ version }}"></script>
|
{# <script src="{% static 'WebTerminal/ws.js' %}?ver={{ version }}"></script>#}
|
||||||
<script src="{% static 'WebTerminal/main.js' %}?ver={{ version }}"></script>
|
{# <script src="{% static 'WebTerminal/main.js' %}?ver={{ version }}"></script>#}
|
||||||
|
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
|
|||||||
115
baseTemplate/templates/baseTemplate/onboarding.html
Executable file
115
baseTemplate/templates/baseTemplate/onboarding.html
Executable file
@@ -0,0 +1,115 @@
|
|||||||
|
{% extends "baseTemplate/index.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% block title %}{% trans "Configure Hostname and other default Settings - 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 "Initial Configurations" %}- <a target="_blank" href="https://go.cyberpanel.net/setup-wizard"
|
||||||
|
style="height: 23px;line-height: 21px;"
|
||||||
|
class="btn btn-border btn-alt border-red btn-link font-red"
|
||||||
|
title=""><span>{% trans "Learn More" %}</span></a></h2>
|
||||||
|
<p>{% trans "Configure Hostname and other default Settings for CyberPanel" %}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-controller="OnboardingCP" class="panel">
|
||||||
|
<div class="panel-body">
|
||||||
|
<h3 class="content-box-header">
|
||||||
|
{% trans "Initial Configurations" %} <img ng-hide="cyberpanelLoading"
|
||||||
|
src="{% static 'images/loading.gif' %}">
|
||||||
|
</h3>
|
||||||
|
<div class="example-box-wrapper">
|
||||||
|
|
||||||
|
<form action="/" class="form-horizontal bordered-row panel-body">
|
||||||
|
<div ng-hide="success" class="alert alert-info">
|
||||||
|
<ul>
|
||||||
|
<li><strong>Choose this wisely, if you are not going to use email service on this server, skip rDNS checks.</strong> Ensure that the hostname you provide below is set as rDNS (reverse DNS, also called PTR record) against your
|
||||||
|
IP address. (Only required if you want to use email services on the same server)
|
||||||
|
</li>
|
||||||
|
<li>Make sure that the provided hostname also has an A record pointing to your server's
|
||||||
|
IP address.
|
||||||
|
</li>
|
||||||
|
<li>If the above conditions fail, your server may not function as expected, especially
|
||||||
|
for email services.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Hostname" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input name="dom" type="text" class="form-control"
|
||||||
|
ng-model="hostname" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Additional Features" %}</label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<input ng-model="rDNSCheck" type="checkbox" value="">
|
||||||
|
Skip rDNS/PTR Check (If you don't want to use email service on this server)
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label"></label>
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<button type="button" ng-click="RunOnboarding()"
|
||||||
|
class="btn btn-primary btn-lg btn-block">{% trans "Start Configurations" %}</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div ng-hide="OnboardineDone" class="form-group">
|
||||||
|
<label class="col-sm-3 control-label"></label>
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<button type="button" ng-click="RestartCyberPanel()"
|
||||||
|
class="btn btn-primary btn-lg btn-block">{% trans "Restart CyberPanel" %}</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-hide="ExecutionStatus" class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="form-group">
|
||||||
|
<p>Note: once configurations are completed, click Restart CyberPanel above, after clicking Restart CyberPanel refresh page to fetch new SSL from the browser.</p>
|
||||||
|
<h4 style="margin-top: 2%; margin-bottom: 2%"> {$ functionStatus $} <img
|
||||||
|
ng-hide="cyberpanelLoading" src="{% static 'images/loading.gif' %}">
|
||||||
|
</h4>
|
||||||
|
<div class="progress">
|
||||||
|
<div ng-style="functionProgress"
|
||||||
|
class="progress-bar progress-bar-striped bg-info"
|
||||||
|
role="progressbar"
|
||||||
|
aria-valuenow="50" aria-valuemin="0"
|
||||||
|
aria-valuemax="100"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div> <!-- end row -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -11,6 +11,9 @@ urlpatterns = [
|
|||||||
url(r'^getthemedata', views.getthemedata, name='getthemedata'),
|
url(r'^getthemedata', views.getthemedata, name='getthemedata'),
|
||||||
|
|
||||||
url(r'^upgrade',views.upgrade, name='upgrade'),
|
url(r'^upgrade',views.upgrade, name='upgrade'),
|
||||||
|
url(r'^onboarding$', views.onboarding, name='onboarding'),
|
||||||
|
url(r'^RestartCyberPanel$', views.RestartCyberPanel, name='RestartCyberPanel'),
|
||||||
|
url(r'^runonboarding', views.runonboarding, name='runonboarding'),
|
||||||
|
|
||||||
url(r'^UpgradeStatus',views.upgradeStatus, name='UpgradeStatus'),
|
url(r'^UpgradeStatus',views.upgradeStatus, name='UpgradeStatus'),
|
||||||
url(r'^upgradeVersion',views.upgradeVersion, name='upgradeVersion'),
|
url(r'^upgradeVersion',views.upgradeVersion, name='upgradeVersion'),
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from random import randint
|
||||||
|
|
||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from plogical.getSystemInformation import SystemInformation
|
from plogical.getSystemInformation import SystemInformation
|
||||||
@@ -56,25 +58,28 @@ def versionManagement(request):
|
|||||||
if Currentcomt == latestcomit:
|
if Currentcomt == latestcomit:
|
||||||
notechk = False
|
notechk = False
|
||||||
|
|
||||||
|
|
||||||
template = 'baseTemplate/versionManagment.html'
|
template = 'baseTemplate/versionManagment.html'
|
||||||
finalData = {'build': currentBuild, 'currentVersion': currentVersion, 'latestVersion': latestVersion,
|
finalData = {'build': currentBuild, 'currentVersion': currentVersion, 'latestVersion': latestVersion,
|
||||||
'latestBuild': latestBuild, 'latestcomit': latestcomit, "Currentcomt": Currentcomt, "Notecheck": notechk}
|
'latestBuild': latestBuild, 'latestcomit': latestcomit, "Currentcomt": Currentcomt,
|
||||||
|
"Notecheck": notechk}
|
||||||
|
|
||||||
proc = httpProc(request, template, finalData, 'versionManagement')
|
proc = httpProc(request, template, finalData, 'versionManagement')
|
||||||
return proc.render()
|
return proc.render()
|
||||||
|
|
||||||
|
|
||||||
@ensure_csrf_cookie
|
@ensure_csrf_cookie
|
||||||
def upgrade_cyberpanel(request):
|
def upgrade_cyberpanel(request):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
try:
|
try:
|
||||||
upgrade_command = 'sh <(curl https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgrade.sh || wget -O - https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgrade.sh)'
|
upgrade_command = 'sh <(curl https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgrade.sh || wget -O - https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgrade.sh)'
|
||||||
result = subprocess.run(upgrade_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
result = subprocess.run(upgrade_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||||
|
text=True)
|
||||||
|
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
response_data = {'success': True, 'message': 'CyberPanel upgrade completed successfully.'}
|
response_data = {'success': True, 'message': 'CyberPanel upgrade completed successfully.'}
|
||||||
else:
|
else:
|
||||||
response_data = {'success': False, 'message': 'CyberPanel upgrade failed. Error output: ' + result.stderr}
|
response_data = {'success': False,
|
||||||
|
'message': 'CyberPanel upgrade failed. Error output: ' + result.stderr}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
response_data = {'success': False, 'message': 'An error occurred during the upgrade: ' + str(e)}
|
response_data = {'success': False, 'message': 'An error occurred during the upgrade: ' + str(e)}
|
||||||
|
|
||||||
@@ -84,7 +89,6 @@ def getAdminStatus(request):
|
|||||||
val = request.session['userID']
|
val = request.session['userID']
|
||||||
currentACL = ACLManager.loadedACL(val)
|
currentACL = ACLManager.loadedACL(val)
|
||||||
|
|
||||||
|
|
||||||
if os.path.exists('/home/cyberpanel/postfix'):
|
if os.path.exists('/home/cyberpanel/postfix'):
|
||||||
currentACL['emailAsWhole'] = 1
|
currentACL['emailAsWhole'] = 1
|
||||||
else:
|
else:
|
||||||
@@ -162,7 +166,7 @@ def versionManagment(request):
|
|||||||
r = requests.get(u)
|
r = requests.get(u)
|
||||||
latestcomit = r.json()[0]['sha']
|
latestcomit = r.json()[0]['sha']
|
||||||
|
|
||||||
command ="git -C /usr/local/CyberCP/ rev-parse HEAD"
|
command = "git -C /usr/local/CyberCP/ rev-parse HEAD"
|
||||||
output = ProcessUtilities.outputExecutioner(command)
|
output = ProcessUtilities.outputExecutioner(command)
|
||||||
|
|
||||||
Currentcomt = output.rstrip("\n")
|
Currentcomt = output.rstrip("\n")
|
||||||
@@ -176,14 +180,13 @@ def versionManagment(request):
|
|||||||
#
|
#
|
||||||
# numCommits = output.rstrip("\n")
|
# numCommits = output.rstrip("\n")
|
||||||
|
|
||||||
if(Currentcomt == latestcomit):
|
if (Currentcomt == latestcomit):
|
||||||
notechk = False
|
notechk = False
|
||||||
|
|
||||||
|
|
||||||
template = 'baseTemplate/versionManagment.html'
|
template = 'baseTemplate/versionManagment.html'
|
||||||
finalData = {'build': currentBuild, 'currentVersion': currentVersion, 'latestVersion': latestVersion,
|
finalData = {'build': currentBuild, 'currentVersion': currentVersion, 'latestVersion': latestVersion,
|
||||||
'latestBuild': latestBuild, 'latestcomit': latestcomit, "Currentcomt": Currentcomt, "Notecheck" : notechk }
|
'latestBuild': latestBuild, 'latestcomit': latestcomit, "Currentcomt": Currentcomt,
|
||||||
|
"Notecheck": notechk}
|
||||||
|
|
||||||
proc = httpProc(request, template, finalData, 'versionManagement')
|
proc = httpProc(request, template, finalData, 'versionManagement')
|
||||||
return proc.render()
|
return proc.render()
|
||||||
@@ -335,7 +338,7 @@ def getthemedata(request):
|
|||||||
else:
|
else:
|
||||||
return ACLManager.loadErrorJson('reboot', 0)
|
return ACLManager.loadErrorJson('reboot', 0)
|
||||||
|
|
||||||
#logging.CyberCPLogFileWriter.writeToFile(str(data) + " [themedata]")
|
# logging.CyberCPLogFileWriter.writeToFile(str(data) + " [themedata]")
|
||||||
|
|
||||||
url = "https://raw.githubusercontent.com/usmannasir/CyberPanel-Themes/main/%s/design.css" % data['Themename']
|
url = "https://raw.githubusercontent.com/usmannasir/CyberPanel-Themes/main/%s/design.css" % data['Themename']
|
||||||
|
|
||||||
@@ -350,3 +353,71 @@ def getthemedata(request):
|
|||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
|
|
||||||
|
def onboarding(request):
|
||||||
|
template = 'baseTemplate/onboarding.html'
|
||||||
|
|
||||||
|
proc = httpProc(request, template, None, 'admin')
|
||||||
|
return proc.render()
|
||||||
|
|
||||||
|
|
||||||
|
def runonboarding(request):
|
||||||
|
try:
|
||||||
|
userID = request.session['userID']
|
||||||
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
|
|
||||||
|
if currentACL['admin'] == 1:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return ACLManager.loadErrorJson()
|
||||||
|
|
||||||
|
data = json.loads(request.body)
|
||||||
|
hostname = data['hostname']
|
||||||
|
|
||||||
|
try:
|
||||||
|
rDNSCheck = str(int(data['rDNSCheck']))
|
||||||
|
except:
|
||||||
|
rDNSCheck = 0
|
||||||
|
|
||||||
|
tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||||
|
|
||||||
|
WriteToFile = open(tempStatusPath, 'w')
|
||||||
|
WriteToFile.write('Starting')
|
||||||
|
WriteToFile.close()
|
||||||
|
|
||||||
|
command = f'/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/virtualHostUtilities.py OnBoardingHostName --virtualHostName {hostname} --path {tempStatusPath} --rdns {rDNSCheck}'
|
||||||
|
ProcessUtilities.popenExecutioner(command)
|
||||||
|
|
||||||
|
dic = {'status': 1, 'tempStatusPath': tempStatusPath}
|
||||||
|
json_data = json.dumps(dic)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
|
except BaseException as msg:
|
||||||
|
dic = {'status': 0, 'error_message': str(msg)}
|
||||||
|
json_data = json.dumps(dic)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
def RestartCyberPanel(request):
|
||||||
|
try:
|
||||||
|
userID = request.session['userID']
|
||||||
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
|
|
||||||
|
if currentACL['admin'] == 1:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return ACLManager.loadErrorJson()
|
||||||
|
|
||||||
|
|
||||||
|
command = 'systemctl restart lscpd'
|
||||||
|
ProcessUtilities.popenExecutioner(command)
|
||||||
|
|
||||||
|
dic = {'status': 1}
|
||||||
|
json_data = json.dumps(dic)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
|
except BaseException as msg:
|
||||||
|
dic = {'status': 0, 'error_message': str(msg)}
|
||||||
|
json_data = json.dumps(dic)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|||||||
@@ -3,79 +3,88 @@
|
|||||||
{% block title %}{% trans "Issue SSL For Hostname - CyberPanel" %}{% endblock %}
|
{% block title %}{% trans "Issue SSL For Hostname - CyberPanel" %}{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% get_current_language as LANGUAGE_CODE %}
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||||
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<div id="page-title">
|
|
||||||
<h2>{% trans "Issue SSL For Hostname" %} - <a target="_blank" href="http://go.cyberpanel.net/hostname-ssl" style="height: 23px;line-height: 21px;" class="btn btn-border btn-alt border-red btn-link font-red" title=""><span>{% trans "SSL Docs" %}</span></a></h2>
|
|
||||||
<p>{% trans "Let’s Encrypt SSL for hostname to access CyberPanel on verified SSL." %}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div ng-controller="sslIssueForHostNameCtrl" class="panel">
|
|
||||||
<div class="panel-body">
|
|
||||||
<h3 class="content-box-header">
|
|
||||||
{% trans "Issue SSL For Hostname" %} <img ng-hide="manageSSLLoading" src="{% static 'images/loading.gif' %}">
|
|
||||||
</h3>
|
|
||||||
<div class="example-box-wrapper">
|
|
||||||
|
|
||||||
|
|
||||||
<form action="/" class="form-horizontal bordered-row panel-body">
|
|
||||||
|
|
||||||
|
|
||||||
<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">{% trans "Issue SSL" %}</button>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="col-sm-3 control-label"></label>
|
|
||||||
<div class="col-sm-6">
|
|
||||||
<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. You can now access CyberPanel at:" %} <strong>https://{$ sslDomain $}:8090</strong></p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div ng-hide="couldNotConnect" class="alert alert-success">
|
|
||||||
<p>{% trans "SSL Issued. You can now access CyberPanel at:" %} <strong>https://"domain":8090</strong></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</form>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="container" xmlns="http://www.w3.org/1999/html">
|
||||||
|
<div id="page-title">
|
||||||
|
<h2>{% trans "Issue SSL For Hostname" %} - <a target="_blank" href="http://go.cyberpanel.net/hostname-ssl"
|
||||||
|
style="height: 23px;line-height: 21px;"
|
||||||
|
class="btn btn-border btn-alt border-red btn-link font-red"
|
||||||
|
title=""><span>{% trans "SSL Docs" %}</span></a></h2>
|
||||||
|
<p>{% trans "Let’s Encrypt SSL for hostname to access CyberPanel on verified SSL." %}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div ng-controller="sslIssueForHostNameCtrl" class="panel">
|
||||||
|
<div class="panel-body">
|
||||||
|
<h3 class="content-box-header">
|
||||||
|
{% trans "Issue SSL For Hostname" %} <img ng-hide="manageSSLLoading"
|
||||||
|
src="{% static 'images/loading.gif' %}">
|
||||||
|
</h3>
|
||||||
|
<div class="example-box-wrapper">
|
||||||
|
|
||||||
|
<div ng-hide="success" class="alert alert-info">
|
||||||
|
<p>Note: This feature is deprecated in favour of <a href="/base/onboarding">setup-wizard</a>.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<form action="/" class="form-horizontal bordered-row panel-body">
|
||||||
|
|
||||||
|
|
||||||
|
<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">{% trans "Issue SSL" %}</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label"></label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<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. You can now access CyberPanel at:" %}
|
||||||
|
<strong>https://{$ sslDomain $}:8090</strong></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-hide="couldNotConnect" class="alert alert-success">
|
||||||
|
<p>{% trans "SSL Issued. You can now access CyberPanel at:" %} <strong>https://"domain":8090</strong>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -3,77 +3,86 @@
|
|||||||
{% block title %}{% trans "Issue SSL For MailServer - CyberPanel" %}{% endblock %}
|
{% block title %}{% trans "Issue SSL For MailServer - CyberPanel" %}{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% get_current_language as LANGUAGE_CODE %}
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||||
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<div id="page-title">
|
|
||||||
<h2>{% trans "Issue SSL For MailServer" %} - <a target="_blank" href="http://go.cyberpanel.net/mailserver-ssl" style="height: 23px;line-height: 21px;" class="btn btn-border btn-alt border-red btn-link font-red" title=""><span>{% trans "SSL Docs" %}</span></a></h2>
|
|
||||||
<p>{% trans "Let’s Encrypt SSL for MailServer (Postfix/Dovecot)." %}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div ng-controller="sslIssueForMailServer" class="panel">
|
|
||||||
<div class="panel-body">
|
|
||||||
<h3 class="content-box-header">
|
|
||||||
{% 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 panel-body">
|
|
||||||
|
|
||||||
<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-6">
|
|
||||||
<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 class="container">
|
||||||
|
<div id="page-title">
|
||||||
|
<h2>{% trans "Issue SSL For MailServer" %} - <a target="_blank"
|
||||||
|
href="http://go.cyberpanel.net/mailserver-ssl"
|
||||||
|
style="height: 23px;line-height: 21px;"
|
||||||
|
class="btn btn-border btn-alt border-red btn-link font-red"
|
||||||
|
title=""><span>{% trans "SSL Docs" %}</span></a></h2>
|
||||||
|
<p>{% trans "Let’s Encrypt SSL for MailServer (Postfix/Dovecot)." %}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div ng-controller="sslIssueForMailServer" class="panel">
|
||||||
|
<div class="panel-body">
|
||||||
|
<h3 class="content-box-header">
|
||||||
|
{% trans "Issue SSL For MailServer" %} <img ng-hide="manageSSLLoading"
|
||||||
|
src="{% static 'images/loading.gif' %}">
|
||||||
|
</h3>
|
||||||
|
<div class="example-box-wrapper">
|
||||||
|
|
||||||
|
<div ng-hide="success" class="alert alert-info">
|
||||||
|
<p>Note: This feature is deprecated in favour of <a href="/base/onboarding">setup-wizard</a>.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form action="/" class="form-horizontal bordered-row panel-body">
|
||||||
|
|
||||||
|
<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-6">
|
||||||
|
<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>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -1479,6 +1479,25 @@ Automatic Backupv2 failed for %s on %s.
|
|||||||
print("Error: [v2Backups]: %s" % str(msg))
|
print("Error: [v2Backups]: %s" % str(msg))
|
||||||
logging.writeToFile('%s. [v2Backups]' % (str(msg)))
|
logging.writeToFile('%s. [v2Backups]' % (str(msg)))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def CheckHostName():
|
||||||
|
try:
|
||||||
|
from loginSystem.models import Administrator
|
||||||
|
admin = Administrator.objects.get(pk=1)
|
||||||
|
config = json.loads(admin.config)
|
||||||
|
|
||||||
|
### probably need to add temporary dns resolver nameserver here - pending
|
||||||
|
|
||||||
|
try:
|
||||||
|
CurrentHostName = config['hostname']
|
||||||
|
skipRDNSCheck = config['skipRDNSCheck']
|
||||||
|
except:
|
||||||
|
CurrentHostName = ''
|
||||||
|
skipRDNSCheck = 1
|
||||||
|
|
||||||
|
virtualHostUtilities.OnBoardingHostName(CurrentHostName, '/home/cyberpanel/onboarding_temp_path', skipRDNSCheck)
|
||||||
|
except BaseException as msg:
|
||||||
|
logging.writeToFile(f'{str(msg)}. [Cron.CheckHostName]')
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description='CyberPanel Installer')
|
parser = argparse.ArgumentParser(description='CyberPanel Installer')
|
||||||
@@ -1524,6 +1543,7 @@ def main():
|
|||||||
IncScheduler.checkDiskUsage()
|
IncScheduler.checkDiskUsage()
|
||||||
IncScheduler.startNormalBackups(args.function)
|
IncScheduler.startNormalBackups(args.function)
|
||||||
IncScheduler.runAWSBackups(args.function)
|
IncScheduler.runAWSBackups(args.function)
|
||||||
|
IncScheduler.CheckHostName()
|
||||||
|
|
||||||
ib.join()
|
ib.join()
|
||||||
|
|
||||||
|
|||||||
@@ -31,11 +31,31 @@ class httpProc:
|
|||||||
templateName = 'baseTemplate/error.html'
|
templateName = 'baseTemplate/error.html'
|
||||||
return render(self.request, templateName, {'error_message': 'You are not authorized to access %s' % (self.function)})
|
return render(self.request, templateName, {'error_message': 'You are not authorized to access %s' % (self.function)})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
if self.data == None:
|
if self.data == None:
|
||||||
self.data = {}
|
self.data = {}
|
||||||
|
|
||||||
|
### Onboarding checks
|
||||||
|
|
||||||
|
if currentACL['admin']:
|
||||||
|
try:
|
||||||
|
admin = Administrator.objects.get(userName='admin')
|
||||||
|
config = json.loads(admin.config)
|
||||||
|
self.data['onboarding'] = config['onboarding']
|
||||||
|
except:
|
||||||
|
self.data['onboarding'] = 0
|
||||||
|
self.data['onboardingError'] = """
|
||||||
|
Please launch the <a href="/base/onboarding">set-up wizard</a> to get maximum out of your CyberPanel installation.
|
||||||
|
"""
|
||||||
|
else:
|
||||||
|
|
||||||
|
self.data['onboarding'] = 2
|
||||||
|
|
||||||
ipFile = "/etc/cyberpanel/machineIP"
|
ipFile = "/etc/cyberpanel/machineIP"
|
||||||
f = open(ipFile)
|
f = open(ipFile)
|
||||||
ipData = f.read()
|
ipData = f.read()
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
import django
|
import django
|
||||||
|
|
||||||
# PACKAGE_PARENT = '..'
|
# PACKAGE_PARENT = '..'
|
||||||
@@ -56,7 +58,7 @@ class virtualHostUtilities:
|
|||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def OnBoardingHostName(Domain, tempStatusPath):
|
def OnBoardingHostName(Domain, tempStatusPath, skipRDNSCheck):
|
||||||
import json
|
import json
|
||||||
import OpenSSL
|
import OpenSSL
|
||||||
|
|
||||||
@@ -76,9 +78,18 @@ class virtualHostUtilities:
|
|||||||
|
|
||||||
PostFixHostname = mailUtilities.FetchPostfixHostname()
|
PostFixHostname = mailUtilities.FetchPostfixHostname()
|
||||||
serverIP = ACLManager.fetchIP()
|
serverIP = ACLManager.fetchIP()
|
||||||
rDNS = mailUtilities.reverse_dns_lookup(serverIP)
|
### if skipRDNSCheck == 1, it means we need to skip checking for rDNS
|
||||||
|
if skipRDNSCheck:
|
||||||
|
### so if skipRDNSCheck is 1 means we need to skip checking for rDNS so lets set current as rDNS because no checking is required
|
||||||
|
rDNS = CurrentHostName
|
||||||
|
else:
|
||||||
|
rDNS = mailUtilities.reverse_dns_lookup(serverIP)
|
||||||
|
|
||||||
print(f'Postfix Hostname: {PostFixHostname}. Server IP {serverIP}. rDNS: {rDNS}')
|
time.sleep(3)
|
||||||
|
|
||||||
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
|
print(f'Postfix Hostname: {PostFixHostname}. Server IP {serverIP}. rDNS: {rDNS}')
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile(f'Postfix Hostname: {PostFixHostname}. Server IP {serverIP}. rDNS: {rDNS}, rDNS check {skipRDNSCheck}')
|
||||||
|
|
||||||
### Case 1 if hostname already exists check if same hostname in postfix and rdns
|
### Case 1 if hostname already exists check if same hostname in postfix and rdns
|
||||||
filePath = '/etc/letsencrypt/live/%s/fullchain.pem' % (PostFixHostname)
|
filePath = '/etc/letsencrypt/live/%s/fullchain.pem' % (PostFixHostname)
|
||||||
@@ -122,10 +133,20 @@ class virtualHostUtilities:
|
|||||||
message = 'Hostname SSL was already issued, and same hostname was used in mail server SSL, rDNS was also configured but we found invalid SSL. However, we tried to issue SSL and it failed. [404]'
|
message = 'Hostname SSL was already issued, and same hostname was used in mail server SSL, rDNS was also configured but we found invalid SSL. However, we tried to issue SSL and it failed. [404]'
|
||||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, message)
|
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, message)
|
||||||
logging.CyberCPLogFileWriter.writeToFile(message)
|
logging.CyberCPLogFileWriter.writeToFile(message)
|
||||||
|
config['hostname'] = Domain
|
||||||
|
config['onboarding'] = 3
|
||||||
|
config['skipRDNSCheck'] = skipRDNSCheck
|
||||||
|
admin.config = json.dumps(config)
|
||||||
|
admin.save()
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
message = "It looks like your current hostname is already the mail server hostname and rDNS is also set and there is a valid SSL, nothing needed to do."
|
message = "It looks like your current hostname is already the mail server hostname and rDNS is also set and there is a valid SSL, nothing needed to do."
|
||||||
print(message)
|
print(message)
|
||||||
|
config['hostname'] = Domain
|
||||||
|
config['onboarding'] = 1
|
||||||
|
config['skipRDNSCheck'] = skipRDNSCheck
|
||||||
|
admin.config = json.dumps(config)
|
||||||
|
admin.save()
|
||||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, message)
|
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, message)
|
||||||
logging.CyberCPLogFileWriter.writeToFile(message)
|
logging.CyberCPLogFileWriter.writeToFile(message)
|
||||||
|
|
||||||
@@ -137,13 +158,28 @@ class virtualHostUtilities:
|
|||||||
### Case 2 where postfix hostname either does not exist or does not match with server hostname or
|
### Case 2 where postfix hostname either does not exist or does not match with server hostname or
|
||||||
### hostname does not exists at all
|
### hostname does not exists at all
|
||||||
|
|
||||||
|
### if skipRDNSCheck == 1, it means we need to skip checking for rDNS
|
||||||
|
if skipRDNSCheck:
|
||||||
|
### so if skipRDNSCheck is 1 means we need to skip checking for rDNS so lets set current domain as rDNS because no checking is required
|
||||||
|
rDNS = Domain
|
||||||
|
|
||||||
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile(
|
||||||
|
f'Second if: Postfix Hostname: {PostFixHostname}. Server IP {serverIP}. rDNS: {rDNS}, rDNS check {skipRDNSCheck}')
|
||||||
|
|
||||||
#first check if hostname is already configured as rDNS, if not return error
|
#first check if hostname is already configured as rDNS, if not return error
|
||||||
|
|
||||||
|
|
||||||
if Domain != rDNS:
|
if Domain != rDNS:
|
||||||
message = 'Domain that you have provided is not configured as rDNS for your server IP. [404]'
|
message = 'Domain that you have provided is not configured as rDNS for your server IP. [404]'
|
||||||
print(message)
|
print(message)
|
||||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, message)
|
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, message)
|
||||||
logging.CyberCPLogFileWriter.writeToFile(message)
|
logging.CyberCPLogFileWriter.writeToFile(message)
|
||||||
|
config['hostname'] = Domain
|
||||||
|
config['onboarding'] = 3
|
||||||
|
config['skipRDNSCheck'] = skipRDNSCheck
|
||||||
|
admin.config = json.dumps(config)
|
||||||
|
admin.save()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
### now issue hostname ssl
|
### now issue hostname ssl
|
||||||
@@ -157,7 +193,7 @@ class virtualHostUtilities:
|
|||||||
|
|
||||||
filePath = '/etc/letsencrypt/live/%s/fullchain.pem' % (Domain)
|
filePath = '/etc/letsencrypt/live/%s/fullchain.pem' % (Domain)
|
||||||
|
|
||||||
virtualHostUtilities.issueSSLForHostName(Domain, path)
|
virtualHostUtilities.issueSSLForHostName(Domain, path, 1)
|
||||||
|
|
||||||
x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, open(filePath, 'r').read())
|
x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, open(filePath, 'r').read())
|
||||||
SSLProvider = x509.get_issuer().get_components()[1][1].decode('utf-8')
|
SSLProvider = x509.get_issuer().get_components()[1][1].decode('utf-8')
|
||||||
@@ -166,6 +202,11 @@ class virtualHostUtilities:
|
|||||||
message = 'Failed to issue Hostname SSL, either its DNS record is not propagated or the domain ie behind Cloudflare. [404]'
|
message = 'Failed to issue Hostname SSL, either its DNS record is not propagated or the domain ie behind Cloudflare. [404]'
|
||||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, message)
|
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, message)
|
||||||
logging.CyberCPLogFileWriter.writeToFile(message)
|
logging.CyberCPLogFileWriter.writeToFile(message)
|
||||||
|
config['hostname'] = Domain
|
||||||
|
config['onboarding'] = 3
|
||||||
|
config['skipRDNSCheck'] = skipRDNSCheck
|
||||||
|
admin.config = json.dumps(config)
|
||||||
|
admin.save()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Hostname SSL issued,50')
|
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Hostname SSL issued,50')
|
||||||
@@ -180,13 +221,18 @@ class virtualHostUtilities:
|
|||||||
message = 'Failed to issue Mail server SSL, either its DNS record is not propagated or the domain ie behind Cloudflare. [404]'
|
message = 'Failed to issue Mail server SSL, either its DNS record is not propagated or the domain ie behind Cloudflare. [404]'
|
||||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, message)
|
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, message)
|
||||||
logging.CyberCPLogFileWriter.writeToFile(message)
|
logging.CyberCPLogFileWriter.writeToFile(message)
|
||||||
return 0
|
|
||||||
else:
|
|
||||||
|
|
||||||
config['hostname'] = Domain
|
config['hostname'] = Domain
|
||||||
|
config['onboarding'] = 3
|
||||||
|
config['skipRDNSCheck'] = skipRDNSCheck
|
||||||
|
admin.config = json.dumps(config)
|
||||||
|
admin.save()
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
config['hostname'] = Domain
|
||||||
|
config['onboarding'] = 1
|
||||||
|
config['skipRDNSCheck'] = skipRDNSCheck
|
||||||
admin.config = json.dumps(config)
|
admin.config = json.dumps(config)
|
||||||
admin.save()
|
admin.save()
|
||||||
|
|
||||||
command = 'systemctl restart postfix && systemctl restart dovecot && postmap -F hash:/etc/postfix/vmail_ssl.map'
|
command = 'systemctl restart postfix && systemctl restart dovecot && postmap -F hash:/etc/postfix/vmail_ssl.map'
|
||||||
ProcessUtilities.executioner(command, 'root', True)
|
ProcessUtilities.executioner(command, 'root', True)
|
||||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Completed. [200]')
|
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Completed. [200]')
|
||||||
@@ -641,7 +687,7 @@ class virtualHostUtilities:
|
|||||||
print("0," + str(msg))
|
print("0," + str(msg))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def issueSSLForHostName(virtualHost, path):
|
def issueSSLForHostName(virtualHost, path, skipLSCPDRestart=0):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
destPrivKey = "/usr/local/lscp/conf/key.pem"
|
destPrivKey = "/usr/local/lscp/conf/key.pem"
|
||||||
@@ -705,9 +751,13 @@ class virtualHostUtilities:
|
|||||||
command = 'ln -s %s %s' % (pathToStoreSSLPrivKey, destPrivKey)
|
command = 'ln -s %s %s' % (pathToStoreSSLPrivKey, destPrivKey)
|
||||||
ProcessUtilities.executioner(command)
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
command = 'systemctl restart lscpd'
|
|
||||||
cmd = shlex.split(command)
|
if skipLSCPDRestart:
|
||||||
subprocess.call(cmd)
|
pass
|
||||||
|
else:
|
||||||
|
command = 'systemctl restart lscpd'
|
||||||
|
cmd = shlex.split(command)
|
||||||
|
subprocess.call(cmd)
|
||||||
|
|
||||||
print("1,None")
|
print("1,None")
|
||||||
return 1, 'None'
|
return 1, 'None'
|
||||||
@@ -1687,6 +1737,10 @@ def main():
|
|||||||
|
|
||||||
parser.add_argument('--DeleteDocRoot', help='Doc root deletion for child domain.')
|
parser.add_argument('--DeleteDocRoot', help='Doc root deletion for child domain.')
|
||||||
|
|
||||||
|
### for onboarding
|
||||||
|
|
||||||
|
parser.add_argument('--rdns', help='Doc root deletion for child domain.')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.function == "createVirtualHost":
|
if args.function == "createVirtualHost":
|
||||||
@@ -1793,7 +1847,7 @@ def main():
|
|||||||
elif args.function == 'OnBoardingHostName':
|
elif args.function == 'OnBoardingHostName':
|
||||||
# in virtualHostName pass domain for which hostname should be set up
|
# in virtualHostName pass domain for which hostname should be set up
|
||||||
# in path pass temporary path where status of the function will be stored
|
# in path pass temporary path where status of the function will be stored
|
||||||
virtualHostUtilities.OnBoardingHostName(args.virtualHostName, args.path)
|
virtualHostUtilities.OnBoardingHostName(args.virtualHostName, args.path, int(args.rdns))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user