mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-03-04 19:30:45 +01:00
Improved WordPress installation process.
This commit is contained in:
@@ -9,4 +9,6 @@
|
||||
.website-content-box{
|
||||
border-radius: 25px;
|
||||
border-color:#3498db
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -456,6 +456,7 @@ app.controller('websitePages', function($scope,$http) {
|
||||
};
|
||||
|
||||
$scope.fileManagerURL = "/filemanager/"+$("#domainNamePage").text();
|
||||
$scope.wordPressInstallURL = $("#domainNamePage").text() + "/wordpressInstall";
|
||||
$scope.domainAliasURL = "/websites/"+$("#domainNamePage").text()+"/domainAlias";
|
||||
$scope.previewUrl = "/preview/"+$("#domainNamePage").text()+"/";
|
||||
|
||||
@@ -3835,7 +3836,294 @@ app.controller('launchChild', function($scope,$http) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
/* Application Installer */
|
||||
|
||||
|
||||
app.controller('installWordPressCTRL', 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;
|
||||
|
||||
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%");
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
$scope.installWordPress = 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/installWordpress";
|
||||
|
||||
var home = "1";
|
||||
|
||||
if (typeof path !== 'undefined'){
|
||||
home = "0";
|
||||
}
|
||||
|
||||
|
||||
var data = {
|
||||
domain: domain,
|
||||
home:home,
|
||||
path:path,
|
||||
blogTitle: $scope.blogTitle,
|
||||
adminUser: $scope.adminUser,
|
||||
adminPassword: $scope.adminPassword,
|
||||
adminEmail: $scope.adminEmail
|
||||
};
|
||||
|
||||
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) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
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.installJoomla = function(){
|
||||
|
||||
|
||||
$scope.installationDetailsFormJoomla = false;
|
||||
$scope.applicationInstallerLoading = false;
|
||||
$scope.installationFailed = true;
|
||||
$scope.installationSuccessfull = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
var domain = $("#domainNamePage").text();
|
||||
var path = $scope.installPath;
|
||||
var sitename = $scope.sitename
|
||||
var username = $scope.username
|
||||
var password = $scope.password
|
||||
var prefix = $scope.prefix
|
||||
|
||||
|
||||
url = "/websites/installJoomla";
|
||||
|
||||
var home = "1";
|
||||
|
||||
if (typeof path != 'undefined'){
|
||||
home = "0";
|
||||
}
|
||||
|
||||
|
||||
var data = {
|
||||
domain: domain,
|
||||
home:home,
|
||||
path:path,
|
||||
sitename:sitename,
|
||||
username:username,
|
||||
password:password,
|
||||
prefix:prefix,
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
if (response.data.installStatus == 1)
|
||||
{
|
||||
if (typeof path != 'undefined'){
|
||||
$scope.installationURL = "http://"+domain+"/"+path;
|
||||
}
|
||||
else{
|
||||
$scope.installationURL = domain;
|
||||
}
|
||||
|
||||
$scope.installationDetailsFormJoomla = false;
|
||||
$scope.applicationInstallerLoading = true;
|
||||
$scope.installationFailed = true;
|
||||
$scope.installationSuccessfull = false;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
$scope.installationDetailsFormJoomla = false;
|
||||
$scope.applicationInstallerLoading = true;
|
||||
$scope.installationFailed = false;
|
||||
$scope.installationSuccessfull = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.installationDetailsFormJoomla = false;
|
||||
$scope.applicationInstallerLoading = true;
|
||||
$scope.installationFailed = true;
|
||||
$scope.installationSuccessfull = true;
|
||||
$scope.couldNotConnect = false;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
@@ -0,0 +1,62 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Application Installer - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div id="page-title">
|
||||
<h2 id="domainNamePage">{% trans "Application Installer" %}</h2>
|
||||
<p>{% trans "One-click application install." %}</p>
|
||||
</div>
|
||||
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<div style="border-radius: 25px;border-color:#3498db" class="content-box">
|
||||
<h3 class="content-box-header bg-blue">
|
||||
{% trans "Application Installer" %} <img ng-hide="applicationInstallerLoading" src="/static/images/loading.gif">
|
||||
</h3>
|
||||
|
||||
<div class="content-box-wrapper">
|
||||
<div class="row">
|
||||
|
||||
<a ng-click="installationDetails()" href="" title="{% trans 'Install wordpress with LSCache' %}">
|
||||
<div class="col-md-4" style="margin-bottom: 2%;">
|
||||
|
||||
<a ng-click="installationDetails()" href="" title="{% trans 'Install wordpress with LSCache' %}">
|
||||
<img src="{% static 'images/icons/wordpress.png' %}">
|
||||
</a>
|
||||
<a ng-click="installationDetails()" href="" title="{% trans 'Install wordpress with LSCache' %}">
|
||||
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "Wordpress with LSCache" %}</span>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<a ng-click="installationDetailsJoomla()" href="" title="{% trans 'Install Joomla with(?) LSCache' %}">
|
||||
<div class="col-md-4" style="margin-bottom: 2%;">
|
||||
|
||||
<a ng-click="installationDetailsJoomla()" href="" title="{% trans 'Install Joomla with LSCache' %}">
|
||||
<img src="{% static 'images/icons/joomla-logo.png' %}">
|
||||
</a>
|
||||
<a ng-click="installationDetailsJoomla()" href="" title="{% trans 'Install Joomla with LSCache' %}">
|
||||
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "Joomla" %}</span>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
@@ -51,7 +51,7 @@
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Domain Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input ng-pattern="/*/i" name="dom" type="text" class="form-control" ng-model="domainNameCreate" placeholder="{% trans "Do not enter WWW, it will be auto created!" %}" required>
|
||||
<input name="dom" type="text" class="form-control" ng-model="domainNameCreate" placeholder="{% trans "Do not enter WWW, it will be auto created!" %}" required>
|
||||
</div>
|
||||
<div ng-show="websiteCreationForm.dom.$error.pattern" class="current-pack">{% trans "Invalid Domain (Note: You don't need to add 'http' or 'https')" %}</div>
|
||||
</div>
|
||||
@@ -115,7 +115,7 @@
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button ng-disabled="websiteCreationForm.dom.$error.required || websiteCreationForm.dom.$error.pattern || websiteCreationForm.email.$invalid" type="button" ng-click="createWebsite()" class="btn btn-primary btn-lg btn-block">{% trans "Create Website" %}</button>
|
||||
<button ng-disabled="websiteCreationForm.dom.$error.required || websiteCreationForm.email.$invalid" type="button" ng-click="createWebsite()" class="btn btn-primary btn-lg btn-block">{% trans "Create Website" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Install WordPress - 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 WordPress" %}</h2>
|
||||
<p>{% trans "Install WordPress with LSCache." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-controller="installWordPressCTRL" 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 "Blog Title" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="blogTitle" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Login User" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="adminUser" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Login Password" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="password" class="form-control" ng-model="adminPassword" 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="text" class="form-control" ng-model="adminEmail" required>
|
||||
</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="installWordPress()" 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 %}
|
||||
@@ -940,10 +940,10 @@
|
||||
|
||||
<div class="col-md-4" style="margin-bottom: 2%;">
|
||||
|
||||
<a ng-click="installationDetails()" href="" title="{% trans 'Install wordpress with LSCache' %}">
|
||||
<a href="{$ wordPressInstallURL $}" target="_blank" title="{% trans 'Install wordpress with LSCache' %}">
|
||||
<img src="{% static 'images/icons/wordpress.png' %}">
|
||||
</a>
|
||||
<a ng-click="installationDetails()" href="" title="{% trans 'Install wordpress with LSCache' %}">
|
||||
<a href="{$ wordPressInstallURL $}" target="_blank" title="{% trans 'Install wordpress with LSCache' %}">
|
||||
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "Wordpress with LSCache" %}</span>
|
||||
</a>
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ urlpatterns = [
|
||||
url(r'^fetchErrorLogs', views.fetchErrorLogs, name='fetchErrorLogs'),
|
||||
|
||||
|
||||
url(r'^installWordpress', views.installWordpress, name='installWordpress'),
|
||||
url(r'^installWordpress$', views.installWordpress, name='installWordpress'),
|
||||
url(r'^installJoomla', views.installJoomla, name='installJoomla'),
|
||||
|
||||
url(r'^getDataFromConfigFile', views.getDataFromConfigFile, name='getDataFromConfigFile'),
|
||||
@@ -76,4 +76,10 @@ urlpatterns = [
|
||||
url(r'^changeOpenBasedir$',views.changeOpenBasedir,name="changeOpenBasedir"),
|
||||
|
||||
|
||||
## Application Installer
|
||||
|
||||
url(r'^applicationInstaller$',views.applicationInstaller,name="applicationInstaller"),
|
||||
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/wordpressInstall$', views.wordpressInstall, name='wordpressInstall'),
|
||||
url(r'^installWordpressStatus$',views.installWordpressStatus,name="installWordpressStatus"),
|
||||
|
||||
]
|
||||
@@ -25,6 +25,7 @@ from random import randint
|
||||
import hashlib
|
||||
from xml.etree import ElementTree
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
from plogical.applicationInstaller import ApplicationInstaller
|
||||
# Create your views here.
|
||||
|
||||
|
||||
@@ -1061,127 +1062,6 @@ def fetchErrorLogs(request):
|
||||
final_json = json.dumps({'logstatus': 0, 'error_message': str(msg)})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def installWordpress(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
data = json.loads(request.body)
|
||||
domainName = data['domain']
|
||||
home = data['home']
|
||||
|
||||
finalPath = ""
|
||||
|
||||
if home == '0':
|
||||
path = data['path']
|
||||
finalPath = "/home/" + domainName + "/public_html/" + path + "/"
|
||||
else:
|
||||
finalPath = "/home/" + domainName + "/public_html/"
|
||||
|
||||
## Security Check
|
||||
|
||||
if finalPath.find("..") > -1:
|
||||
data_ret = {'installStatus': 0,
|
||||
'error_message': "Specified path must be inside virtual host home!"}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
|
||||
try:
|
||||
website = ChildDomains.objects.get(domain=domainName)
|
||||
externalApp = website.master.externalApp
|
||||
|
||||
if admin.type != 1:
|
||||
if website.master.admin != admin:
|
||||
data_ret = {'installStatus': 0,
|
||||
'error_message': "You do not own this website!"}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except:
|
||||
website = Websites.objects.get(domain=domainName)
|
||||
externalApp = website.externalApp
|
||||
|
||||
if admin.type != 1:
|
||||
if website.admin != admin:
|
||||
data_ret = {'installStatus': 0,
|
||||
'error_message': "You do not own this website!"}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
## DB Creation
|
||||
|
||||
dbName = randomPassword.generate_pass()
|
||||
dbUser = dbName
|
||||
dbPassword = randomPassword.generate_pass()
|
||||
|
||||
## DB Creation
|
||||
|
||||
if website.package.dataBases > website.databases_set.all().count():
|
||||
pass
|
||||
else:
|
||||
data_ret = {'installStatus': 0, 'error_message': "0,Maximum database limit reached for this website."}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
if Databases.objects.filter(dbName=dbName).exists() or Databases.objects.filter(
|
||||
dbUser=dbUser).exists():
|
||||
|
||||
data_ret = {'installStatus': 0,
|
||||
'error_message': "0,This database or user is already taken."}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
result = mysqlUtilities.createDatabase(dbName, dbUser, dbPassword)
|
||||
|
||||
if result == 1:
|
||||
pass
|
||||
else:
|
||||
data_ret = {'installStatus': 0,
|
||||
'error_message': "0,Not able to create database."}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
db = Databases(website=website, dbName=dbName, dbUser=dbUser)
|
||||
db.save()
|
||||
|
||||
## Installation
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
execPath = execPath + " installWordPress --virtualHostName " + domainName + " --virtualHostUser " + externalApp + " --path " + finalPath + " --dbName " + dbName + " --dbUser " + dbUser + " --dbPassword " + dbPassword
|
||||
|
||||
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {"installStatus": 1}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
mysqlUtilities.deleteDatabase(dbName, dbUser)
|
||||
db = Databases.objects.get(dbName=dbName)
|
||||
db.delete()
|
||||
data_ret = {'installStatus': 0, 'error_message': output}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
## Installation ends
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'installStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except KeyError, msg:
|
||||
status = {"installStatus":0,"error":str(msg)}
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installWordpress]")
|
||||
return HttpResponse("Not Logged in as admin")
|
||||
|
||||
def installJoomla(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
@@ -2450,4 +2330,138 @@ def changeOpenBasedir(request):
|
||||
except KeyError,msg:
|
||||
data_ret = {'changeOpenBasedir': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def applicationInstaller(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
try:
|
||||
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
|
||||
if admin.type != 1:
|
||||
website = Websites.objects.get(domain=domain)
|
||||
if website.admin != admin:
|
||||
raise BaseException('You do not own this website.')
|
||||
|
||||
|
||||
return render(request, 'websiteFunctions/applicationInstaller.html')
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return HttpResponse(str(msg))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def wordpressInstall(request, domain):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
try:
|
||||
if admin.type != 1:
|
||||
website = Websites.objects.get(domain=domain)
|
||||
if website.admin != admin:
|
||||
raise BaseException('You do not own this website.')
|
||||
|
||||
|
||||
return render(request, 'websiteFunctions/installWordPress.html', {'domainName' : domain})
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return HttpResponse(str(msg))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def installWordpress(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
data = json.loads(request.body)
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
extraArgs = {}
|
||||
extraArgs['admin'] = admin
|
||||
extraArgs['domainName'] = data['domain']
|
||||
extraArgs['home'] = data['home']
|
||||
extraArgs['blogTitle'] = data['blogTitle']
|
||||
extraArgs['adminUser'] = data['adminUser']
|
||||
extraArgs['adminPassword'] = data['adminPassword']
|
||||
extraArgs['adminEmail'] = data['adminEmail']
|
||||
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
if data['home'] == '0':
|
||||
extraArgs['path'] = data['path']
|
||||
|
||||
|
||||
background = ApplicationInstaller('wordpress', extraArgs)
|
||||
background.start()
|
||||
|
||||
data_ret = {'installStatus': 1, 'error_message': 'None', 'tempStatusPath': extraArgs['tempStatusPath']}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'installStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except KeyError, msg:
|
||||
status = {"installStatus":0,"error":str(msg)}
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installWordpress]")
|
||||
return HttpResponse("Not Logged in as admin")
|
||||
|
||||
|
||||
def installWordpressStatus(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
data = json.loads(request.body)
|
||||
|
||||
|
||||
domainName = data['domainName']
|
||||
statusFile = data['statusFile']
|
||||
|
||||
if admin.type != 1:
|
||||
website = Websites.objects.get(domain=domainName)
|
||||
if website.admin != admin:
|
||||
raise BaseException('You do not own this website.')
|
||||
|
||||
statusData = open(statusFile, 'r').readlines()
|
||||
|
||||
lastLine = statusData[-1]
|
||||
|
||||
if lastLine.find('[200]') > -1:
|
||||
data_ret = { 'abort':1, 'installStatus': 1, 'installationProgress': "100", 'currentStatus': 'Successfully Installed.' }
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
elif lastLine.find('[404]') > -1:
|
||||
data_ret = {'abort': 1, 'installStatus': 0, 'installationProgress': "0", 'error_message': lastLine}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
progress = lastLine.split(',')
|
||||
currentStatus = progress[0]
|
||||
installationProgress = progress[1]
|
||||
data_ret = {'abort': 0, 'installStatus': 0, 'installationProgress': installationProgress, 'currentStatus': currentStatus}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'abort': 1, 'installStatus': 0, 'installationProgress': "0", 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except KeyError, msg:
|
||||
data_ret = {'abort': 1, 'installStatus': 0, 'installationProgress': "0", 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
Reference in New Issue
Block a user