complete mautic auto installer

This commit is contained in:
Usman Nasir
2020-08-25 15:49:52 +05:00
parent 3f12943db0
commit cb67f6dc42
9 changed files with 780 additions and 8 deletions

View File

@@ -961,6 +961,7 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
$scope.setupGit = $("#domainNamePage").text() + "/setupGit";
$scope.installPrestaURL = $("#domainNamePage").text() + "/installPrestaShop";
$scope.installMagentoURL = $("#domainNamePage").text() + "/installMagento";
$scope.installMauticURL = $("#domainNamePage").text() + "/installMautic";
$scope.domainAliasURL = "/websites/" + $("#domainNamePage").text() + "/domainAlias";
$scope.previewUrl = "/preview/" + $("#domainNamePage").text() + "/";
@@ -5218,6 +5219,191 @@ app.controller('installPrestaShopCTRL', function ($scope, $http, $timeout) {
};
});
app.controller('installMauticCTRL', function ($scope, $http, $timeout) {
$scope.installationDetailsForm = false;
$scope.installationProgress = true;
$scope.installationFailed = true;
$scope.installationSuccessfull = true;
$scope.couldNotConnect = true;
$scope.wpInstallLoading = true;
$scope.goBackDisable = true;
$scope.databasePrefix = 'ps_';
var statusFile;
var domain = $("#domainNamePage").text();
var path;
$scope.goBack = function () {
$scope.installationDetailsForm = false;
$scope.installationProgress = true;
$scope.installationFailed = true;
$scope.installationSuccessfull = true;
$scope.couldNotConnect = true;
$scope.wpInstallLoading = true;
$scope.goBackDisable = true;
$("#installProgress").css("width", "0%");
};
function getInstallStatus() {
url = "/websites/installWordpressStatus";
var data = {
statusFile: statusFile,
domainName: domain
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.abort === 1) {
if (response.data.installStatus === 1) {
$scope.installationDetailsForm = true;
$scope.installationProgress = false;
$scope.installationFailed = true;
$scope.installationSuccessfull = false;
$scope.couldNotConnect = true;
$scope.wpInstallLoading = true;
$scope.goBackDisable = false;
if (typeof path !== 'undefined') {
$scope.installationURL = "http://" + domain + "/" + path;
} else {
$scope.installationURL = domain;
}
$("#installProgress").css("width", "100%");
$scope.installPercentage = "100";
$scope.currentStatus = response.data.currentStatus;
$timeout.cancel();
} else {
$scope.installationDetailsForm = true;
$scope.installationProgress = false;
$scope.installationFailed = false;
$scope.installationSuccessfull = true;
$scope.couldNotConnect = true;
$scope.wpInstallLoading = true;
$scope.goBackDisable = false;
$scope.errorMessage = response.data.error_message;
$("#installProgress").css("width", "0%");
$scope.installPercentage = "0";
}
} else {
$("#installProgress").css("width", response.data.installationProgress + "%");
$scope.installPercentage = response.data.installationProgress;
$scope.currentStatus = response.data.currentStatus;
$timeout(getInstallStatus, 1000);
}
}
function cantLoadInitialDatas(response) {
$scope.canNotFetch = true;
$scope.couldNotConnect = false;
}
}
$scope.installMautic = function () {
$scope.installationDetailsForm = true;
$scope.installationProgress = false;
$scope.installationFailed = true;
$scope.installationSuccessfull = true;
$scope.couldNotConnect = true;
$scope.wpInstallLoading = false;
$scope.goBackDisable = true;
$scope.currentStatus = "Starting installation..";
path = $scope.installPath;
url = "/websites/mauticInstall";
var home = "1";
if (typeof path !== 'undefined') {
home = "0";
}
var data = {
domain: domain,
home: home,
path: path,
username: $scope.adminUserName,
email: $scope.email,
passwordByPass: $scope.password
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.installStatus === 1) {
statusFile = response.data.tempStatusPath;
getInstallStatus();
} else {
$scope.installationDetailsForm = true;
$scope.installationProgress = false;
$scope.installationFailed = false;
$scope.installationSuccessfull = true;
$scope.couldNotConnect = true;
$scope.wpInstallLoading = true;
$scope.goBackDisable = false;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
}
};
});
app.controller('sshAccess', function ($scope, $http, $timeout) {

View File

@@ -0,0 +1,112 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "Install Mautic - 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 "Install Mautic" %}</h2>
<p>{% trans "One-click Mautic Install!" %}</p>
</div>
<div ng-controller="installMauticCTRL" class="panel">
<div class="panel-body">
<h3 class="title-hero">
<span id="domainNamePage">{{ domainName }}</span> - {% trans "Installation Details" %} <img ng-hide="wpInstallLoading" src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
<form name="websiteCreationForm" action="/" id="createPackages" class="form-horizontal bordered-row">
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Administrator Username" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="adminUserName" required>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Email" %}</label>
<div class="col-sm-6">
<input type="email" class="form-control" ng-model="email" required>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
<div class="col-sm-6">
<input type="password" class="form-control" ng-model="password" required>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="installMautic()" class="btn btn-primary btn-lg btn-block">{% trans "Install Now" %}</button>
</div>
</div>
<div ng-hide="installationProgress" class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-7">
<div class="alert alert-success text-center">
<h2>{$ currentStatus $}</h2>
</div>
<div class="progress">
<div id="installProgress" class="progress-bar" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:0%">
<span class="sr-only">70% Complete</span>
</div>
</div>
<div ng-hide="installationFailed" class="alert alert-danger">
<p>{% trans "Installation failed. Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="installationSuccessfull" class="alert alert-success">
<p>{% trans "Installation successful. Visit:" %} {$ installationURL $}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
</div>
</div>
<div ng-hide="installationProgress" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-disabled="goBackDisable" ng-click="goBack()" class="btn btn-primary btn-lg btn-block">{% trans "Go Back" %}</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -1048,6 +1048,17 @@
</a>
</div>
<div class="col-md-3 panel-body">
<a href="{$ installMagentoURL $}" target="_blank"
title="{% trans 'Install Magento' %}">
<img src="{% static 'images/icons/mautic.png' %}" width="65" class="mr-10">
</a>
<a href="{$ installMauticURL $}" target="_blank"
title="{% trans 'Install Mautic' %}">
<span class="h4">{% trans "Mautic" %}</span>
</a>
</div>
</div>
</div>

View File

@@ -96,6 +96,11 @@ urlpatterns = [
url(r'^(?P<domain>(.*))/installMagento$', views.installMagento, name='installMagento'),
url(r'^magentoInstall$', views.magentoInstall, name='magentoInstall'),
## mautic
url(r'^(?P<domain>(.*))/installMautic$', views.installMautic, name='installMautic'),
url(r'^mauticInstall$', views.mauticInstall, name='mauticInstall'),
## Git
url(r'^(?P<domain>(.*))/setupGit$', views.setupGit, name='setupGit'),

View File

@@ -656,6 +656,22 @@ def magentoInstall(request):
except KeyError:
return redirect(loadLoginPage)
def installMautic(request, domain):
try:
userID = request.session['userID']
wm = WebsiteManager(domain)
return wm.installMautic(request, userID)
except KeyError:
return redirect(loadLoginPage)
def mauticInstall(request):
try:
userID = request.session['userID']
wm = WebsiteManager()
return wm.mauticInstall(userID, json.loads(request.body))
except KeyError:
return redirect(loadLoginPage)
def prestaShopInstall(request):
try:
userID = request.session['userID']

View File

@@ -2310,6 +2310,64 @@ StrictHostKeyChecking no
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def installMautic(self, request=None, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
return render(request, 'websiteFunctions/installMautic.html', {'domainName': self.domain})
except BaseException as msg:
return HttpResponse(str(msg))
def mauticInstall(self, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
self.domain = data['domain']
if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadErrorJson('installStatus', 0)
mailUtilities.checkHome()
extraArgs = {}
extraArgs['admin'] = admin
extraArgs['domainName'] = data['domain']
extraArgs['home'] = data['home']
extraArgs['username'] = data['username']
extraArgs['email'] = data['email']
extraArgs['password'] = data['passwordByPass']
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
if data['home'] == '0':
extraArgs['path'] = data['path']
background = ApplicationInstaller('mautic', extraArgs)
background.start()
time.sleep(2)
data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None',
'tempStatusPath': extraArgs['tempStatusPath']}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
## Installation ends
except BaseException as msg:
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def prestaShopInstall(self, userID=None, data=None):
try: