magento installer

This commit is contained in:
Usman Nasir
2019-11-07 09:37:06 +05:00
parent c3e3fa047b
commit 40ee12615c
10 changed files with 679 additions and 28 deletions

View File

@@ -96,9 +96,14 @@ class secMiddleware:
response = self.get_response(request) response = self.get_response(request)
#response['Strict-Transport-Security'] = "max-age=31536000; includeSubDomains; preload"
response['X-XSS-Protection'] = "1; mode=block" response['X-XSS-Protection'] = "1; mode=block"
#response['Strict-Transport-Security'] = "max-age=31536000; includeSubDomains; preload"
response['X-Frame-Options'] = "sameorigin" response['X-Frame-Options'] = "sameorigin"
response['Content-Security-Policy'] = "frame-ancestors jsdelivr.com" response['Content-Security-Policy'] = "script-src 'self' https://www.jsdelivr.com"
response['Content-Security-Policy'] = "connect-src *;"
response['Content-Security-Policy'] = "font-src 'self' 'unsafe-inline' https://www.jsdelivr.com https://fonts.googleapis.com"
response['Content-Security-Policy'] = "style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://www.jsdelivr.com https://cdnjs.cloudflare.com https://maxcdn.bootstrapcdn.com https://cdn.jsdelivr.net"
response['X-Content-Type-Options'] = "nosniff"
response['Referrer-Policy'] = "same-origin"
return response return response

View File

@@ -1,7 +1,9 @@
#!/usr/local/CyberCP/bin/python2 #!/usr/local/CyberCP/bin/python2
import os, sys import os, sys
sys.path.append('/usr/local/CyberCP') sys.path.append('/usr/local/CyberCP')
import django import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
django.setup() django.setup()
import threading as multi import threading as multi
@@ -17,6 +19,7 @@ import shutil
from plogical.mailUtilities import mailUtilities from plogical.mailUtilities import mailUtilities
from plogical.processUtilities import ProcessUtilities from plogical.processUtilities import ProcessUtilities
class ApplicationInstaller(multi.Thread): class ApplicationInstaller(multi.Thread):
def __init__(self, installApp, extraArgs): def __init__(self, installApp, extraArgs):
@@ -40,6 +43,8 @@ class ApplicationInstaller(multi.Thread):
self.changeBranch() self.changeBranch()
elif self.installApp == 'prestashop': elif self.installApp == 'prestashop':
self.installPrestaShop() self.installPrestaShop()
elif self.installApp == 'magento':
self.installMagento()
except BaseException, msg: except BaseException, msg:
logging.writeToFile(str(msg) + ' [ApplicationInstaller.run]') logging.writeToFile(str(msg) + ' [ApplicationInstaller.run]')
@@ -182,7 +187,6 @@ class ApplicationInstaller(multi.Thread):
else: else:
finalPath = website.path finalPath = website.path
if website.master.package.dataBases > website.master.databases_set.all().count(): if website.master.package.dataBases > website.master.databases_set.all().count():
pass pass
else: else:
@@ -208,7 +212,6 @@ class ApplicationInstaller(multi.Thread):
else: else:
finalPath = "/home/" + domainName + "/public_html/" finalPath = "/home/" + domainName + "/public_html/"
if website.package.dataBases > website.databases_set.all().count(): if website.package.dataBases > website.databases_set.all().count():
pass pass
else: else:
@@ -286,7 +289,6 @@ class ApplicationInstaller(multi.Thread):
## ##
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath
ProcessUtilities.executioner(command, externalApp) ProcessUtilities.executioner(command, externalApp)
@@ -303,7 +305,6 @@ class ApplicationInstaller(multi.Thread):
homeDir = "/home/" + domainName + "/public_html" homeDir = "/home/" + domainName + "/public_html"
if not os.path.exists(homeDir): if not os.path.exists(homeDir):
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + homeDir command = "sudo chown -R " + externalApp + ":" + externalApp + " " + homeDir
ProcessUtilities.executioner(command, externalApp) ProcessUtilities.executioner(command, externalApp)
@@ -416,7 +417,8 @@ class ApplicationInstaller(multi.Thread):
statusFile.writelines('Downloading and extracting PrestaShop Core..,30') statusFile.writelines('Downloading and extracting PrestaShop Core..,30')
statusFile.close() statusFile.close()
command = "sudo wget https://download.prestashop.com/download/releases/prestashop_1.7.4.2.zip -P %s" % (finalPath) command = "sudo wget https://download.prestashop.com/download/releases/prestashop_1.7.4.2.zip -P %s" % (
finalPath)
ProcessUtilities.executioner(command, externalApp) ProcessUtilities.executioner(command, externalApp)
command = "sudo unzip -o %sprestashop_1.7.4.2.zip -d " % (finalPath) + finalPath command = "sudo unzip -o %sprestashop_1.7.4.2.zip -d " % (finalPath) + finalPath
@@ -541,8 +543,6 @@ class ApplicationInstaller(multi.Thread):
externalApp = website.externalApp externalApp = website.externalApp
finalPath = "/home/" + domainName + "/public_html/" finalPath = "/home/" + domainName + "/public_html/"
## Security Check ## Security Check
if finalPath.find("..") > -1: if finalPath.find("..") > -1:
@@ -551,7 +551,6 @@ class ApplicationInstaller(multi.Thread):
statusFile.close() statusFile.close()
return 0 return 0
command = 'sudo mkdir -p ' + finalPath command = 'sudo mkdir -p ' + finalPath
ProcessUtilities.executioner(command, externalApp) ProcessUtilities.executioner(command, externalApp)
@@ -571,7 +570,8 @@ class ApplicationInstaller(multi.Thread):
ProcessUtilities.executioner(command, externalApp) ProcessUtilities.executioner(command, externalApp)
except subprocess.CalledProcessError, msg: except subprocess.CalledProcessError, msg:
statusFile = open(tempStatusPath, 'w') statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Failed to clone repository, make sure you deployed your key to repository. [404]') statusFile.writelines(
'Failed to clone repository, make sure you deployed your key to repository. [404]')
statusFile.close() statusFile.close()
return 0 return 0
@@ -661,7 +661,6 @@ class ApplicationInstaller(multi.Thread):
childDomain = ChildDomains.objects.get(domain=domain) childDomain = ChildDomains.objects.get(domain=domain)
finalPath = childDomain.path finalPath = childDomain.path
command = 'sudo rm -rf ' + finalPath command = 'sudo rm -rf ' + finalPath
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
@@ -877,3 +876,179 @@ class ApplicationInstaller(multi.Thread):
except BaseException, msg: except BaseException, msg:
logging.writeToFile('Failed to change branch: ' + str(msg)) logging.writeToFile('Failed to change branch: ' + str(msg))
return 0 return 0
def installMagento(self):
try:
username = self.extraArgs['username']
domainName = self.extraArgs['domainName']
home = self.extraArgs['home']
firstName = self.extraArgs['firstName']
lastName = self.extraArgs['lastName']
email = self.extraArgs['email']
password = self.extraArgs['password']
tempStatusPath = self.extraArgs['tempStatusPath']
sampleData = self.extraArgs['sampleData']
FNULL = open(os.devnull, 'w')
## Open Status File
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Setting up paths,0')
statusFile.close()
finalPath = ''
try:
website = ChildDomains.objects.get(domain=domainName)
externalApp = website.master.externalApp
if home == '0':
path = self.extraArgs['path']
finalPath = website.path.rstrip('/') + "/" + path + "/"
else:
finalPath = website.path + "/"
if website.master.package.dataBases > website.master.databases_set.all().count():
pass
else:
statusFile = open(tempStatusPath, 'w')
statusFile.writelines(
"Maximum database limit reached for this website." + " [404]")
statusFile.close()
return 0
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Setting up Database,20')
statusFile.close()
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website.master)
except:
website = Websites.objects.get(domain=domainName)
externalApp = website.externalApp
if home == '0':
path = self.extraArgs['path']
finalPath = "/home/" + domainName + "/public_html/" + path + "/"
else:
finalPath = "/home/" + domainName + "/public_html/"
if website.package.dataBases > website.databases_set.all().count():
pass
else:
statusFile = open(tempStatusPath, 'w')
statusFile.writelines(
"Maximum database limit reached for this website." + " [404]")
statusFile.close()
return 0
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Setting up Database,20')
statusFile.close()
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website)
## Security Check
if finalPath.find("..") > -1:
statusFile = open(tempStatusPath, 'w')
statusFile.writelines("Specified path must be inside virtual host home." + " [404]")
statusFile.close()
return 0
if not os.path.exists(finalPath):
command = 'sudo mkdir -p ' + finalPath
ProcessUtilities.executioner(command, externalApp)
## checking for directories/files
if self.dataLossCheck(finalPath, tempStatusPath) == 0:
return 0
####
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Downloading and extracting Magento Core..,30')
statusFile.close()
if sampleData:
command = "sudo wget http://cyberpanelsh.b-cdn.net/latest-sample.tar.gz -P %s" % (finalPath)
else:
command = "sudo wget http://cyberpanelsh.b-cdn.net/latest.tar.gz -P %s" % (finalPath)
ProcessUtilities.executioner(command, externalApp)
if sampleData:
command = 'tar -xf %slatest-sample.tar.gz --directory %s' % (finalPath, finalPath)
else:
command = 'tar -xf %slatest.tar.gz --directory %s' % (finalPath, finalPath)
ProcessUtilities.executioner(command, externalApp)
##
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Configuring the installation,40')
statusFile.close()
if home == '0':
path = self.extraArgs['path']
# finalURL = domainName + '/' + path
finalURL = domainName
else:
finalURL = domainName
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Installing and configuring Magento..,60')
statusFile.close()
command = '/usr/local/lsws/lsphp72/bin/php -d memory_limit=512M %sbin/magento setup:install --backend-frontname="admin" ' \
'--db-host="localhost" --db-name="%s" --db-user="%s" --db-password="%s" ' \
'--base-url="http://%s" --base-url-secure="https://%s/" --admin-user="%s" ' \
'--admin-password="%s" --admin-email="%s" --admin-firstname="%s" --admin-lastname="%s"' \
% (finalPath, dbName, dbUser, dbPassword, finalURL, finalURL, username, password, email, firstName, lastName)
result = ProcessUtilities.outputExecutioner(command, externalApp)
logging.writeToFile(result)
##
if sampleData:
command = 'rm -rf %slatest-sample.tar.gz' % (finalPath)
else:
command = 'rm -rf %slatest.tar.gz' % (finalPath)
ProcessUtilities.executioner(command, externalApp)
##
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath
ProcessUtilities.executioner(command, externalApp)
statusFile = open(tempStatusPath, 'w')
statusFile.writelines("Successfully Installed. [200]")
statusFile.close()
return 0
except BaseException, msg:
# remove the downloaded files
homeDir = "/home/" + domainName + "/public_html"
if not os.path.exists(homeDir):
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + homeDir
ProcessUtilities.executioner(command, externalApp)
try:
mysqlUtilities.deleteDatabase(dbName, dbUser)
db = Databases.objects.get(dbName=dbName)
db.delete()
except:
pass
statusFile = open(tempStatusPath, 'w')
statusFile.writelines(str(msg) + " [404]")
statusFile.close()
return 0

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -634,6 +634,7 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
$scope.joomlaInstallURL = $("#domainNamePage").text() + "/joomlaInstall"; $scope.joomlaInstallURL = $("#domainNamePage").text() + "/joomlaInstall";
$scope.setupGit = $("#domainNamePage").text() + "/setupGit"; $scope.setupGit = $("#domainNamePage").text() + "/setupGit";
$scope.installPrestaURL = $("#domainNamePage").text() + "/installPrestaShop"; $scope.installPrestaURL = $("#domainNamePage").text() + "/installPrestaShop";
$scope.installMagentoURL = $("#domainNamePage").text() + "/installMagento";
$scope.domainAliasURL = "/websites/" + $("#domainNamePage").text() + "/domainAlias"; $scope.domainAliasURL = "/websites/" + $("#domainNamePage").text() + "/domainAlias";
$scope.previewUrl = "/preview/" + $("#domainNamePage").text() + "/"; $scope.previewUrl = "/preview/" + $("#domainNamePage").text() + "/";
@@ -3099,6 +3100,7 @@ app.controller('launchChild', function ($scope, $http) {
$scope.joomlaInstallURL = "/websites/" + $("#childDomain").text() + "/joomlaInstall"; $scope.joomlaInstallURL = "/websites/" + $("#childDomain").text() + "/joomlaInstall";
$scope.setupGit = "/websites/" + $("#childDomain").text() + "/setupGit"; $scope.setupGit = "/websites/" + $("#childDomain").text() + "/setupGit";
$scope.installPrestaURL = "/websites/" + $("#childDomain").text() + "/installPrestaShop"; $scope.installPrestaURL = "/websites/" + $("#childDomain").text() + "/installPrestaShop";
$scope.installMagentoURL = "/websites/" + $("#childDomain").text() + "/installMagento";
var logType = 0; var logType = 0;
$scope.pageNumber = 1; $scope.pageNumber = 1;
@@ -5239,3 +5241,198 @@ app.controller('syncWebsite', function ($scope, $http, $timeout, $window) {
}); });
/* Java script code to syncWebsite ends here */ /* Java script code to syncWebsite ends here */
app.controller('installMagentoCTRL', 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.installMagento = 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/magentoInstall";
var home = "1";
if (typeof path !== 'undefined') {
home = "0";
}
var sampleData;
if ($scope.sampleData === true) {
sampleData = 1;
} else {
sampleData = 0
}
var data = {
domain: domain,
home: home,
path: path,
firstName: $scope.firstName,
lastName: $scope.lastName,
username: $scope.username,
email: $scope.email,
passwordByPass: $scope.password,
sampleData: sampleData
};
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) {
}
};
});

View File

@@ -0,0 +1,160 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "Install Magento - 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 Magento" %}</h2>
<p>{% trans "One-click Magento Install!" %}</p>
</div>
<div ng-controller="installMagentoCTRL" 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 "First Name" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="firstName" required>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Last Name" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="lastName" 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 "Admin Username" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="username" 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 placeholder="Min Length:8, must contain mix of numbers and characters."
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">{% trans "Additional Features" %}</label>
<div class="col-sm-9">
<div class="checkbox">
<label>
<input ng-model="sampleData" type="checkbox" value="">
Install with Sample Data
</label>
</div>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-9">
<div class="alert alert-warning">
<p>
<a href="https://www.litespeedtech.com/products/cache-plugins/magento-acceleration">LiteMage
Cache
Plugin</a> {% trans "does not work on OpenLiteSpeed. It is highly recommended to use this installer with LiteSpeed Enterprise only." %}
</p>
</div>
</div>
</div>
<!--<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Path" %}</label>
<div class="col-sm-6">
<input placeholder="Leave emtpy to install in website home directory. (Without preceding slash)" type="text" class="form-control" ng-model="installPath">
</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="installMagento()"
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

@@ -26,7 +26,10 @@
<h3 class="content-box-header"> <h3 class="content-box-header">
{% trans "Resource Usage" %} {% trans "Resource Usage" %}
<a style="float: right; margin-left: 2%" class="btn btn-border btn-alt border-azure btn-link font-azure" href="/websites/{{ domain }}/{{ childDomain }}/syncToMaster" title=""><span>{% trans "Copy/Sync to Master" %}</span></a> <a style="float: right; margin-left: 2%"
class="btn btn-border btn-alt border-azure btn-link font-azure"
href="/websites/{{ domain }}/{{ childDomain }}/syncToMaster"
title=""><span>{% trans "Copy/Sync to Master" %}</span></a>
</h3> </h3>
<div class=""> <div class="">
@@ -716,6 +719,18 @@
</div> </div>
<div class="col-md-3 panel-body">
<a href="{$ installMagentoURL $}" target="_blank"
title="{% trans 'Install Magento' %}">
<img src="{% static 'images/icons/magento.png' %}" width="65" class="mr-10">
</a>
<a href="{$ installMagentoURL $}" target="_blank"
title="{% trans 'Install Magento' %}">
<span class="h4">{% trans "Magento" %}</span>
</a>
</div>
</div> </div>
</div> </div>

View File

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

View File

@@ -88,6 +88,11 @@ urlpatterns = [
url(r'^prestaShopInstall$', views.prestaShopInstall, name='prestaShopInstall'), url(r'^prestaShopInstall$', views.prestaShopInstall, name='prestaShopInstall'),
url(r'^(?P<domain>(.*))/installPrestaShop$', views.installPrestaShop, name='installPrestaShop'), url(r'^(?P<domain>(.*))/installPrestaShop$', views.installPrestaShop, name='installPrestaShop'),
## magento
url(r'^(?P<domain>(.*))/installMagento$', views.installMagento, name='installMagento'),
url(r'^magentoInstall$', views.magentoInstall, name='magentoInstall'),
## Git ## Git
url(r'^(?P<domain>(.*))/setupGit$', views.setupGit, name='setupGit'), url(r'^(?P<domain>(.*))/setupGit$', views.setupGit, name='setupGit'),

View File

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

View File

@@ -2020,6 +2020,68 @@ StrictHostKeyChecking no
except BaseException, msg: except BaseException, msg:
return HttpResponse(str(msg)) return HttpResponse(str(msg))
def installMagento(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/installMagento.html', {'domainName': self.domain})
except BaseException, msg:
return HttpResponse(str(msg))
def magentoInstall(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['firstName'] = data['firstName']
extraArgs['lastName'] = data['lastName']
extraArgs['username'] = data['username']
extraArgs['email'] = data['email']
extraArgs['password'] = data['passwordByPass']
extraArgs['sampleData'] = data['sampleData']
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
if data['home'] == '0':
extraArgs['path'] = data['path']
background = ApplicationInstaller('magento', 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, 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): def prestaShopInstall(self, userID=None, data=None):
try: try:
@@ -2086,6 +2148,11 @@ StrictHostKeyChecking no
except: except:
websitesLimit = 1 websitesLimit = 1
try:
apiACL = data['acl']
except:
apiACL = 'user'
admin = Administrator.objects.get(userName=adminUser) admin = Administrator.objects.get(userName=adminUser)
if hashPassword.check_password(admin.password, adminPass): if hashPassword.check_password(admin.password, adminPass):
@@ -2094,7 +2161,7 @@ StrictHostKeyChecking no
data['adminEmail'] = "usman@cyberpersons.com" data['adminEmail'] = "usman@cyberpersons.com"
try: try:
acl = ACL.objects.get(name='user') acl = ACL.objects.get(name=apiACL)
websiteOwn = Administrator(userName=websiteOwner, websiteOwn = Administrator(userName=websiteOwner,
password=hashPassword.hash_password(ownerPassword), password=hashPassword.hash_password(ownerPassword),
email=adminEmail, type=3, owner=admin.pk, email=adminEmail, type=3, owner=admin.pk,