mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 05:45:59 +01:00
bug fix to wp staging
This commit is contained in:
@@ -13,7 +13,7 @@ from websiteFunctions.models import Websites
|
||||
import os
|
||||
from baseTemplate.models import version
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
from plogical.website import WebsiteManager
|
||||
from websiteFunctions.website import WebsiteManager
|
||||
from s3Backups.s3Backups import S3Backups
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
import json
|
||||
import os
|
||||
from random import randint
|
||||
|
||||
from django.shortcuts import HttpResponse
|
||||
|
||||
import userManagment.views as um
|
||||
from backup.backupManager import BackupManager
|
||||
from databases.databaseManager import DatabaseManager
|
||||
@@ -15,22 +9,17 @@ from loginSystem.models import Administrator
|
||||
from mailServer.mailserverManager import MailServerManager
|
||||
from manageSSL.views import issueSSL, obtainHostNameSSL, obtainMailServerSSL
|
||||
from packages.packagesManager import PackagesManager
|
||||
from plogical.acl import ACLManager
|
||||
from plogical.httpProc import httpProc
|
||||
from plogical.mysqlUtilities import mysqlUtilities
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
from plogical.website import WebsiteManager
|
||||
from websiteFunctions.website import WebsiteManager
|
||||
from s3Backups.s3Backups import S3Backups
|
||||
from serverLogs.views import getLogsFromFile
|
||||
from serverStatus.views import topProcessesStatus, killProcess, switchTOLSWSStatus
|
||||
from websiteFunctions.models import Websites
|
||||
from plogical import hashPassword
|
||||
from loginSystem.models import ACL
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
from managePHP.phpManager import PHPManager
|
||||
from managePHP.views import submitExtensionRequest, getRequestStatusApache
|
||||
from containerization.containerManager import ContainerManager
|
||||
from containerization.views import *
|
||||
|
||||
|
||||
|
||||
@@ -952,7 +952,7 @@ class preFlightsChecks:
|
||||
|
||||
os.chdir(self.path)
|
||||
|
||||
command = "wget http://cyberpanel.sh/CyberPanel.1.8.7.tar.gz"
|
||||
command = "wget http://cyberpanel.sh/CyberPanel.1.8.8.tar.gz"
|
||||
#command = "wget http://cyberpanel.sh/CyberPanelTemp.tar.gz"
|
||||
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
|
||||
'CyberPanel Download',
|
||||
@@ -961,7 +961,7 @@ class preFlightsChecks:
|
||||
##
|
||||
|
||||
count = 0
|
||||
command = "tar zxf CyberPanel.1.8.7.tar.gz"
|
||||
command = "tar zxf CyberPanel.1.8.8.tar.gz"
|
||||
#command = "tar zxf CyberPanelTemp.tar.gz"
|
||||
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
|
||||
'Extract CyberPanel',1, 1, os.EX_OSERR)
|
||||
|
||||
@@ -218,7 +218,7 @@ def loadLoginPage(request):
|
||||
firstName="Cyber",lastName="Panel", acl=acl, token=token)
|
||||
admin.save()
|
||||
|
||||
vers = version(currentVersion="1.8", build=7)
|
||||
vers = version(currentVersion="1.8", build=8)
|
||||
vers.save()
|
||||
|
||||
package = Package(admin=admin, packageName="Default", diskSpace=1000,
|
||||
|
||||
@@ -15,3 +15,4 @@ class Package(models.Model):
|
||||
dataBases = models.IntegerField(default=0)
|
||||
ftpAccounts = models.IntegerField(default=0)
|
||||
allowedDomains = models.IntegerField(default=0)
|
||||
allowFullDomain = models.IntegerField(default=1)
|
||||
|
||||
@@ -74,6 +74,12 @@ class PackagesManager:
|
||||
except:
|
||||
api = '0'
|
||||
|
||||
try:
|
||||
allowFullDomain = int(data['allowFullDomain'])
|
||||
except:
|
||||
allowFullDomain = 1
|
||||
|
||||
|
||||
if packageSpace < 0 or packageBandwidth < 0 or packageDatabases < 0 or ftpAccounts < 0 or emails < 0 or allowedDomains < 0:
|
||||
data_ret = {'saveStatus': 0, 'error_message': "All values should be positive or 0."}
|
||||
json_data = json.dumps(data_ret)
|
||||
@@ -86,7 +92,7 @@ class PackagesManager:
|
||||
|
||||
package = Package(admin=admin, packageName=packageName, diskSpace=packageSpace,
|
||||
bandwidth=packageBandwidth, ftpAccounts=ftpAccounts, dataBases=packageDatabases,
|
||||
emailAccounts=emails, allowedDomains=allowedDomains)
|
||||
emailAccounts=emails, allowedDomains=allowedDomains, allowFullDomain=allowFullDomain)
|
||||
|
||||
package.save()
|
||||
|
||||
@@ -156,9 +162,10 @@ class PackagesManager:
|
||||
dataBases = modifyPack.dataBases
|
||||
emails = modifyPack.emailAccounts
|
||||
|
||||
|
||||
data_ret = {'emails': emails, 'modifyStatus': 1, 'error_message': "None",
|
||||
"diskSpace": diskSpace, "bandwidth": bandwidth, "ftpAccounts": ftpAccounts,
|
||||
"dataBases": dataBases, "allowedDomains": modifyPack.allowedDomains}
|
||||
"dataBases": dataBases, "allowedDomains": modifyPack.allowedDomains, 'allowFullDomain': modifyPack.allowFullDomain}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
@@ -194,6 +201,13 @@ class PackagesManager:
|
||||
modifyPack.dataBases = data['dataBases']
|
||||
modifyPack.emailAccounts = data['emails']
|
||||
modifyPack.allowedDomains = data['allowedDomains']
|
||||
|
||||
try:
|
||||
modifyPack.allowFullDomain = int(data['allowFullDomain'])
|
||||
except:
|
||||
modifyPack.allowFullDomain = 1
|
||||
|
||||
|
||||
modifyPack.save()
|
||||
|
||||
data_ret = {'status': 1, 'saveStatus': 1, 'error_message': "None"}
|
||||
|
||||
@@ -3,13 +3,11 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Created by usman on 7/25/17.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Utilities */
|
||||
|
||||
function getCookie(name) {
|
||||
@@ -31,20 +29,18 @@ function getCookie(name) {
|
||||
/* Utilities ends here */
|
||||
|
||||
|
||||
|
||||
|
||||
/* Java script code to create Pacakge */
|
||||
|
||||
$("#packageCreationFailed").hide();
|
||||
$("#packageCreated").hide();
|
||||
|
||||
|
||||
|
||||
app.controller('createPackage', function($scope,$http) {
|
||||
app.controller('createPackage', function ($scope, $http) {
|
||||
|
||||
//$scope.pname = /([A-Z]){3,10}/gi;
|
||||
|
||||
$scope.insertPackInDB = function(){
|
||||
$scope.insertPackInDB = function () {
|
||||
|
||||
|
||||
var packageName = $scope.packageName;
|
||||
var diskSpace = $scope.diskSpace;
|
||||
@@ -53,6 +49,10 @@ app.controller('createPackage', function($scope,$http) {
|
||||
var dataBases = $scope.dataBases;
|
||||
var emails = $scope.emails;
|
||||
|
||||
if($scope.allowFullDomain === undefined){
|
||||
$scope.allowFullDomain = 0;
|
||||
}
|
||||
|
||||
|
||||
url = "/packages/submitPackage";
|
||||
|
||||
@@ -62,30 +62,29 @@ app.controller('createPackage', function($scope,$http) {
|
||||
bandwidth: bandwidth,
|
||||
ftpAccounts: ftpAccounts,
|
||||
dataBases: dataBases,
|
||||
emails:emails,
|
||||
allowedDomains:$scope.allowedDomains
|
||||
emails: emails,
|
||||
allowedDomains: $scope.allowedDomains,
|
||||
allowFullDomain: $scope.allowFullDomain
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
console.log(response.data)
|
||||
|
||||
if (response.data.saveStatus == 0)
|
||||
{
|
||||
if (response.data.saveStatus == 0) {
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
$("#packageCreationFailed").fadeIn();
|
||||
$("#packageCreated").hide();
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$("#packageCreationFailed").hide();
|
||||
$("#packageCreated").fadeIn();
|
||||
$scope.createdPackage = $scope.packageName;
|
||||
@@ -94,6 +93,7 @@ app.controller('createPackage', function($scope,$http) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
console.log("not good");
|
||||
}
|
||||
@@ -107,7 +107,6 @@ app.controller('createPackage', function($scope,$http) {
|
||||
/* Java script code to to create Pacakge ends here */
|
||||
|
||||
|
||||
|
||||
/* Java script code to delete Pacakge */
|
||||
|
||||
|
||||
@@ -117,23 +116,22 @@ $("#deleteSuccess").hide();
|
||||
$("#deletePackageButton").hide();
|
||||
|
||||
|
||||
app.controller('deletePackage', function($scope,$http) {
|
||||
app.controller('deletePackage', function ($scope, $http) {
|
||||
|
||||
|
||||
$scope.deletePackage = function(){
|
||||
$scope.deletePackage = function () {
|
||||
|
||||
$("#deletePackageButton").fadeIn();
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.deletePackageFinal = function(){
|
||||
$scope.deletePackageFinal = function () {
|
||||
|
||||
|
||||
var packageName = $scope.packageToBeDeleted;
|
||||
|
||||
|
||||
|
||||
url = "/packages/submitDelete";
|
||||
|
||||
var data = {
|
||||
@@ -141,26 +139,24 @@ app.controller('deletePackage', function($scope,$http) {
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
console.log(response.data)
|
||||
|
||||
if (response.data.deleteStatus == 0)
|
||||
{
|
||||
if (response.data.deleteStatus == 0) {
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
$("#deleteFailure").fadeIn();
|
||||
$("#deleteSuccess").hide();
|
||||
$("#deletePackageButton").hide();
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$("#deleteFailure").hide();
|
||||
$("#deleteSuccess").fadeIn();
|
||||
$("#deletePackageButton").hide();
|
||||
@@ -170,6 +166,7 @@ app.controller('deletePackage', function($scope,$http) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
console.log("not good");
|
||||
}
|
||||
@@ -180,11 +177,9 @@ app.controller('deletePackage', function($scope,$http) {
|
||||
});
|
||||
|
||||
|
||||
|
||||
/* Java script code to delete package ends here */
|
||||
|
||||
|
||||
|
||||
/* Java script code modify package */
|
||||
|
||||
$("#packageDetailsToBeModified").hide();
|
||||
@@ -194,9 +189,9 @@ $("#modifyButton").hide();
|
||||
$("#packageLoading").hide();
|
||||
$("#successfullyModified").hide();
|
||||
|
||||
app.controller('modifyPackages', function($scope,$http) {
|
||||
app.controller('modifyPackages', function ($scope, $http) {
|
||||
|
||||
$scope.fetchDetails = function(){
|
||||
$scope.fetchDetails = function () {
|
||||
|
||||
$("#packageLoading").show();
|
||||
$("#successfullyModified").hide();
|
||||
@@ -212,18 +207,17 @@ app.controller('modifyPackages', function($scope,$http) {
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
if (response.data.modifyStatus == 0)
|
||||
{
|
||||
if (response.data.modifyStatus === 0) {
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
$("#modifyFailure").fadeIn();
|
||||
$("#modifySuccess").hide();
|
||||
@@ -231,8 +225,7 @@ app.controller('modifyPackages', function($scope,$http) {
|
||||
$("#packageLoading").hide();
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$("#modifyButton").show();
|
||||
$scope.diskSpace = response.data.diskSpace;
|
||||
$scope.bandwidth = response.data.bandwidth;
|
||||
@@ -241,6 +234,12 @@ app.controller('modifyPackages', function($scope,$http) {
|
||||
$scope.emails = response.data.emails;
|
||||
$scope.allowedDomains = response.data.allowedDomains;
|
||||
|
||||
if (response.data.allowFullDomain === 1) {
|
||||
$scope.allowFullDomain = true;
|
||||
} else {
|
||||
$scope.allowFullDomain = false;
|
||||
}
|
||||
|
||||
$scope.modifyButton = "Save Details"
|
||||
|
||||
$("#packageDetailsToBeModified").fadeIn();
|
||||
@@ -250,12 +249,11 @@ app.controller('modifyPackages', function($scope,$http) {
|
||||
$("#packageLoading").hide();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
console.log("not good");
|
||||
}
|
||||
@@ -263,7 +261,6 @@ app.controller('modifyPackages', function($scope,$http) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
$scope.modifyPackageFunc = function () {
|
||||
|
||||
var packageName = $scope.packageToBeModified;
|
||||
@@ -283,27 +280,27 @@ app.controller('modifyPackages', function($scope,$http) {
|
||||
|
||||
var data = {
|
||||
packageName: packageName,
|
||||
diskSpace:diskSpace,
|
||||
bandwidth:bandwidth,
|
||||
ftpAccounts:ftpAccounts,
|
||||
dataBases:dataBases,
|
||||
emails:emails,
|
||||
allowedDomains:$scope.allowedDomains,
|
||||
diskSpace: diskSpace,
|
||||
bandwidth: bandwidth,
|
||||
ftpAccounts: ftpAccounts,
|
||||
dataBases: dataBases,
|
||||
emails: emails,
|
||||
allowedDomains: $scope.allowedDomains,
|
||||
allowFullDomain: $scope.allowFullDomain
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
if (response.data.saveStatus == 0)
|
||||
{
|
||||
if (response.data.saveStatus === 0) {
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
$("#modifyFailure").fadeIn();
|
||||
$("#modifySuccess").hide();
|
||||
@@ -311,8 +308,7 @@ app.controller('modifyPackages', function($scope,$http) {
|
||||
$("#packageLoading").hide();
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$("#modifyButton").hide();
|
||||
|
||||
$("#successfullyModified").fadeIn();
|
||||
@@ -321,22 +317,19 @@ app.controller('modifyPackages', function($scope,$http) {
|
||||
$scope.packageModified = packageName;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
console.log("not good");
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
/* Java script code to Modify Pacakge ends here */
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
{% block title %}{% trans "Create Package - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Create Package" %}</h2>
|
||||
<p>{% trans "Packages define resources for your websites, you need to add package before creating a website." %}</p>
|
||||
</div>
|
||||
<div class="panel">
|
||||
</div>
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Package Details" %}
|
||||
@@ -21,7 +21,8 @@
|
||||
<div ng-controller="createPackage" class="example-box-wrapper">
|
||||
|
||||
|
||||
<form name="createPackageFrm" action="/" id="createPackages" class="form-horizontal bordered-row panel-body">
|
||||
<form name="createPackageFrm" action="/" id="createPackages"
|
||||
class="form-horizontal bordered-row panel-body">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Package Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
@@ -34,7 +35,8 @@
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Domains" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="dspace" type="number" class="form-control" ng-model="allowedDomains" required>
|
||||
<input name="dspace" type="number" class="form-control" ng-model="allowedDomains"
|
||||
required>
|
||||
</div>
|
||||
<div class="current-pack"> {% trans "(0 = Unlimited)" %} </div>
|
||||
</div>
|
||||
@@ -78,10 +80,24 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Additional Features" %}</label>
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-9">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input ng-model="allowFullDomain" type="checkbox" value="">
|
||||
Allow Creation of Fully Qualified Domain as Child-Domains
|
||||
</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="insertPackInDB()" class="btn btn-primary btn-lg">{% trans "Create Package" %}</button>
|
||||
<button type="button" ng-click="insertPackInDB()"
|
||||
class="btn btn-primary btn-lg">{% trans "Create Package" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -93,7 +109,8 @@
|
||||
</div>
|
||||
|
||||
<div id="packageCreated" class="alert alert-success">
|
||||
<p>{% trans "Package" %} <strong>{$ createdPackage $}</strong> {% trans "Successfully Created" %}</p>
|
||||
<p>{% trans "Package" %} <strong>{$ createdPackage
|
||||
$}</strong> {% trans "Successfully Created" %}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -103,12 +120,10 @@
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -83,6 +83,19 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Additional Features" %}</label>
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-9">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input ng-model="allowFullDomain" type="checkbox" value="">
|
||||
Allow Creation of Fully Qualified Domain as Child-Domains
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -108,6 +108,18 @@ class ACLManager:
|
||||
|
||||
return finalResponse
|
||||
|
||||
@staticmethod
|
||||
def checkUserOwnerShip(currentACL, owner, user):
|
||||
if currentACL['admin'] == 1:
|
||||
return 1
|
||||
elif owner == user:
|
||||
return 1
|
||||
elif owner.pk == user.owner:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
@staticmethod
|
||||
def currentContextPermission(currentACL, context):
|
||||
try:
|
||||
|
||||
@@ -31,7 +31,7 @@ def main():
|
||||
firstName="Cyber", lastName="Panel", acl=acl, token=token)
|
||||
admin.save()
|
||||
|
||||
vers = version(currentVersion="1.8", build=7)
|
||||
vers = version(currentVersion="1.8", build=8)
|
||||
vers.save()
|
||||
|
||||
package = Package(admin=admin, packageName="Default", diskSpace=1000,
|
||||
|
||||
@@ -51,6 +51,9 @@ class cPanelImporter:
|
||||
self.mailFormat = 1
|
||||
|
||||
def PHPDecider(self):
|
||||
|
||||
if self.PHPVersion == 'inherit':
|
||||
self.PHPVersion = 'PHP 7.2'
|
||||
if self.PHPVersion.find('53') > -1:
|
||||
self.PHPVersion = 'PHP 5.3'
|
||||
elif self.PHPVersion.find('54') > -1:
|
||||
|
||||
@@ -145,7 +145,7 @@ class mysqlUtilities:
|
||||
return str(msg)
|
||||
|
||||
@staticmethod
|
||||
def createDatabaseBackup(databaseName,tempStoragePath):
|
||||
def createDatabaseBackup(databaseName, tempStoragePath):
|
||||
try:
|
||||
passFile = "/etc/cyberpanel/mysqlPassword"
|
||||
f = open(passFile)
|
||||
@@ -191,7 +191,7 @@ password=%s
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def restoreDatabaseBackup(databaseName, tempStoragePath,dbPassword):
|
||||
def restoreDatabaseBackup(databaseName, tempStoragePath, dbPassword, passwordCheck = None, additionalName = None):
|
||||
try:
|
||||
passFile = "/etc/cyberpanel/mysqlPassword"
|
||||
|
||||
@@ -217,16 +217,24 @@ password=%s
|
||||
command = 'chown cyberpanel:cyberpanel %s' % (cnfPath)
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = 'sudo mysql --defaults-extra-file=/home/cyberpanel/.my.cnf --host=localhost ' + databaseName
|
||||
command = 'mysql --defaults-extra-file=/home/cyberpanel/.my.cnf --host=localhost ' + databaseName
|
||||
cmd = shlex.split(command)
|
||||
|
||||
if additionalName == None:
|
||||
with open(tempStoragePath + "/" + databaseName + '.sql', 'r') as f:
|
||||
res = subprocess.call(cmd, stdin=f)
|
||||
if res != 0:
|
||||
logging.CyberCPLogFileWriter.writeToFile("Could not restore MYSQL database: " + databaseName +"! [restoreDatabaseBackup]")
|
||||
return 0
|
||||
else:
|
||||
with open(tempStoragePath + "/" + additionalName + '.sql', 'r') as f:
|
||||
res = subprocess.call(cmd, stdin=f)
|
||||
|
||||
if res == 1:
|
||||
logging.CyberCPLogFileWriter.writeToFile("Could not restore MYSQL database: " +databaseName +"! [restoreDatabaseBackup]")
|
||||
if res != 0:
|
||||
logging.CyberCPLogFileWriter.writeToFile("Could not restore MYSQL database: " + additionalName + "! [restoreDatabaseBackup]")
|
||||
return 0
|
||||
|
||||
if passwordCheck == None:
|
||||
connection, cursor = mysqlUtilities.setupConnection()
|
||||
|
||||
if connection == 0:
|
||||
|
||||
@@ -270,4 +270,13 @@ class ProcessUtilities(multi.Thread):
|
||||
logging.writeToFile(str(msg) + " [popenExecutioner]")
|
||||
|
||||
|
||||
@staticmethod
|
||||
def BuildCommand(path, functionName, parameters):
|
||||
execPath = "python %s %s " % (path, functionName)
|
||||
for key, value in parameters.iteritems():
|
||||
execPath = execPath + ' --%s %s' % (key, value)
|
||||
|
||||
return execPath
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1443,7 +1443,8 @@ class Upgrade:
|
||||
|
||||
impFile = ['/etc/pure-ftpd/pure-ftpd.conf', '/etc/pure-ftpd/pureftpd-pgsql.conf',
|
||||
'/etc/pure-ftpd/pureftpd-mysql.conf', '/etc/pure-ftpd/pureftpd-ldap.conf',
|
||||
'/etc/dovecot/dovecot.conf', '/etc/pdns/pdns.conf', '/etc/pure-ftpd/db/mysql.conf', '/etc/powerdns/pdns.conf']
|
||||
'/etc/dovecot/dovecot.conf', '/etc/pdns/pdns.conf', '/etc/pure-ftpd/db/mysql.conf',
|
||||
'/etc/powerdns/pdns.conf']
|
||||
|
||||
for items in impFile:
|
||||
command = 'chmod 600 %s' % (items)
|
||||
@@ -1477,7 +1478,6 @@ class Upgrade:
|
||||
command = 'chmod 644 /etc/postfix/main.cf'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
|
||||
Upgrade.stdOut("Permissions updated.")
|
||||
|
||||
except BaseException, msg:
|
||||
@@ -1498,6 +1498,14 @@ class Upgrade:
|
||||
'lsphp7?-sqlite3 lsphp7?-tidy'
|
||||
Upgrade.executioner(command, 'Install PHP 73, 0')
|
||||
|
||||
CentOSPath = '/etc/redhat-release'
|
||||
|
||||
if not os.path.exists(CentOSPath):
|
||||
command = 'cp /usr/local/lsws/lsphp71/bin/php /usr/bin/'
|
||||
Upgrade.executioner(command, 'Set default PHP 7.0, 0')
|
||||
|
||||
|
||||
|
||||
@staticmethod
|
||||
def someDirectories():
|
||||
command = "mkdir -p /usr/local/lscpd/admin/"
|
||||
@@ -1520,11 +1528,11 @@ class Upgrade:
|
||||
if os.path.exists(CentOSPath):
|
||||
path = '/etc/yum.repos.d/dovecot.repo'
|
||||
content = """[dovecot-2.3-latest]
|
||||
name=Dovecot 2.3 CentOS $releasever - $basearch
|
||||
baseurl=http://repo.dovecot.org/ce-2.3-latest/centos/$releasever/RPMS/$basearch
|
||||
gpgkey=https://repo.dovecot.org/DOVECOT-REPO-GPG
|
||||
gpgcheck=1
|
||||
enabled=1"""
|
||||
name=Dovecot 2.3 CentOS $releasever - $basearch
|
||||
baseurl=http://repo.dovecot.org/ce-2.3-latest/centos/$releasever/RPMS/$basearch
|
||||
gpgkey=https://repo.dovecot.org/DOVECOT-REPO-GPG
|
||||
gpgcheck=1
|
||||
enabled=1"""
|
||||
writeToFile = open(path, 'w')
|
||||
writeToFile.write(content)
|
||||
writeToFile.close()
|
||||
@@ -1580,8 +1588,17 @@ class Upgrade:
|
||||
pass
|
||||
|
||||
try:
|
||||
command = 'apt upgrade -y'
|
||||
command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'dpkg --configure -a'
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
command = 'apt --fix-broken install -y'
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
|
||||
subprocess.call(command, shell=True)
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -1591,12 +1608,12 @@ class Upgrade:
|
||||
|
||||
data = open(path, 'r').readlines()
|
||||
|
||||
updatePasswords = 1
|
||||
updatePasswords = 0
|
||||
|
||||
writeToFile = open(path, 'w')
|
||||
for items in data:
|
||||
if items.find('default_pass_scheme') > -1:
|
||||
updatePasswords = 0
|
||||
updatePasswords = 1
|
||||
continue
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
|
||||
@@ -103,7 +103,12 @@ class vhost:
|
||||
try:
|
||||
os.makedirs(pathLogs)
|
||||
|
||||
command = "chown %s:%s %s" % ('root', 'nobody', pathLogs)
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
groupName = 'nobody'
|
||||
else:
|
||||
groupName = 'nogroup'
|
||||
|
||||
command = "chown %s:%s %s" % ('root', groupName, pathLogs)
|
||||
cmd = shlex.split(command)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
|
||||
@@ -1019,6 +1019,15 @@ class virtualHostUtilities:
|
||||
master = Websites.objects.get(domain=masterDomain)
|
||||
domainsInPackage = master.package.allowedDomains
|
||||
|
||||
if master.package.allowFullDomain == 0:
|
||||
if virtualHostName.find(masterDomain) > -1:
|
||||
pass
|
||||
else:
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath,
|
||||
'Fully qualified domain is not allowed in the package. [404]')
|
||||
return 0, "Fully qualified domain is not allowed in the package."
|
||||
|
||||
|
||||
if domainsInPackage == 0:
|
||||
pass
|
||||
elif domainsInPackage > master.childdomains_set.all().count():
|
||||
|
||||
@@ -35,7 +35,6 @@ MarkupSafe==0.11
|
||||
mock==2.0.0
|
||||
parsedatetime==2.4
|
||||
pbr==4.0.4
|
||||
perf==0.1
|
||||
pexpect==4.4.0
|
||||
prettytable==0.7.2
|
||||
psutil==5.4.3
|
||||
|
||||
@@ -65,7 +65,6 @@ def litespeedStatus(request):
|
||||
return render(request, "serverStatus/litespeedStatus.html", {"processList": processList,
|
||||
"liteSpeedVersionStatus": "For some reaons not able to load version details, see CyberCP main log file.",
|
||||
'OLS': OLS})
|
||||
|
||||
if (processList != 0):
|
||||
dataForHtml = {"processList": processList, "lsversion": lsversion, "modules": modules,
|
||||
"loadedModules": loadedModules, 'OLS': OLS}
|
||||
|
||||
@@ -447,9 +447,8 @@ app.controller('deleteWebsiteControl', function ($scope, $http) {
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
console.log(response.data)
|
||||
|
||||
if (response.data.websiteDeleteStatus == 0) {
|
||||
if (response.data.websiteDeleteStatus === 0) {
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
$("#websiteDeleteFailure").fadeIn();
|
||||
$("#websiteDeleteSuccess").hide();
|
||||
@@ -471,7 +470,6 @@ app.controller('deleteWebsiteControl', function ($scope, $http) {
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
console.log("not good");
|
||||
}
|
||||
|
||||
|
||||
@@ -4943,7 +4941,6 @@ app.controller('sshAccess', function ($scope, $http, $timeout) {
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
@@ -4970,3 +4967,299 @@ app.controller('sshAccess', function ($scope, $http, $timeout) {
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
/* Java script code to cloneWebsite */
|
||||
app.controller('cloneWebsite', function ($scope, $http, $timeout, $window) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
$scope.goBackDisable = true;
|
||||
|
||||
var statusFile;
|
||||
|
||||
$scope.startCloning = function () {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = true;
|
||||
|
||||
$scope.currentStatus = "Cloning started..";
|
||||
|
||||
url = "/websites/startCloning";
|
||||
|
||||
|
||||
var data = {
|
||||
masterDomain: $("#domainName").text(),
|
||||
domainName: $scope.domain
|
||||
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
if (response.data.status === 1) {
|
||||
statusFile = response.data.tempStatusPath;
|
||||
getCreationStatus();
|
||||
} else {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$scope.currentStatus = response.data.error_message;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
$scope.goBack = function () {
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
$scope.goBackDisable = true;
|
||||
$("#installProgress").css("width", "0%");
|
||||
};
|
||||
|
||||
function getCreationStatus() {
|
||||
|
||||
url = "/websites/installWordpressStatus";
|
||||
|
||||
var data = {
|
||||
statusFile: statusFile
|
||||
};
|
||||
|
||||
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.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$("#installProgress").css("width", "100%");
|
||||
$scope.installPercentage = "100";
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout.cancel();
|
||||
|
||||
} else {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$scope.currentStatus = response.data.error_message;
|
||||
|
||||
$("#installProgress").css("width", "0%");
|
||||
$scope.installPercentage = "0";
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
$("#installProgress").css("width", response.data.installationProgress + "%");
|
||||
$scope.installPercentage = response.data.installationProgress;
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout(getCreationStatus, 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
/* Java script code to cloneWebsite ends here */
|
||||
|
||||
|
||||
/* Java script code to syncWebsite */
|
||||
app.controller('syncWebsite', function ($scope, $http, $timeout, $window) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
$scope.goBackDisable = true;
|
||||
|
||||
var statusFile;
|
||||
|
||||
$scope.startSyncing = function () {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = true;
|
||||
|
||||
$scope.currentStatus = "Cloning started..";
|
||||
|
||||
url = "/websites/startSync";
|
||||
|
||||
|
||||
var data = {
|
||||
childDomain: $("#childDomain").text(),
|
||||
eraseCheck: $scope.eraseCheck,
|
||||
dbCheck: $scope.dbCheck,
|
||||
copyChanged: $scope.copyChanged
|
||||
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
if (response.data.status === 1) {
|
||||
statusFile = response.data.tempStatusPath;
|
||||
getCreationStatus();
|
||||
} else {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$scope.currentStatus = response.data.error_message;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
$scope.goBack = function () {
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
$scope.goBackDisable = true;
|
||||
$("#installProgress").css("width", "0%");
|
||||
};
|
||||
|
||||
function getCreationStatus() {
|
||||
|
||||
url = "/websites/installWordpressStatus";
|
||||
|
||||
var data = {
|
||||
statusFile: statusFile
|
||||
};
|
||||
|
||||
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.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$("#installProgress").css("width", "100%");
|
||||
$scope.installPercentage = "100";
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout.cancel();
|
||||
|
||||
} else {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$scope.currentStatus = response.data.error_message;
|
||||
|
||||
$("#installProgress").css("width", "0%");
|
||||
$scope.installPercentage = "0";
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
$("#installProgress").css("width", response.data.installationProgress + "%");
|
||||
$scope.installPercentage = response.data.installationProgress;
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout(getCreationStatus, 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
/* Java script code to syncWebsite ends here */
|
||||
@@ -365,12 +365,10 @@ def submitUserDeletion(request):
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if accountUsername == 'admin':
|
||||
data_ret = {'status': 0, 'deleteStatus': 0, 'error_message': 'You can not delete the super user.'}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
currentUser = Administrator.objects.get(pk=userID)
|
||||
userInQuestion = Administrator.objects.get(userName=accountUsername)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
if ACLManager.checkUserOwnerShip(currentACL, currentUser, userInQuestion):
|
||||
user = Administrator.objects.get(userName=accountUsername)
|
||||
user.delete()
|
||||
|
||||
@@ -378,7 +376,7 @@ def submitUserDeletion(request):
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
data_ret = {'status': 0, 'deleteStatus': 1, 'error_message': 'Not enough privileges.'}
|
||||
data_ret = {'status': 0, 'deleteStatus': 0, 'error_message': 'Not enough privileges.'}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
227
websiteFunctions/StagingSetup.py
Normal file
227
websiteFunctions/StagingSetup.py
Normal file
@@ -0,0 +1,227 @@
|
||||
#!/usr/local/CyberCP/bin/python2
|
||||
import threading as multi
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from .models import Websites, ChildDomains
|
||||
from plogical.applicationInstaller import ApplicationInstaller
|
||||
from plogical.mysqlUtilities import mysqlUtilities
|
||||
from random import randint
|
||||
import os
|
||||
|
||||
class StagingSetup(multi.Thread):
|
||||
|
||||
def __init__(self, function, extraArgs):
|
||||
multi.Thread.__init__(self)
|
||||
self.function = function
|
||||
self.extraArgs = extraArgs
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
if self.function == 'startCloning':
|
||||
self.startCloning()
|
||||
elif self.function == 'startSyncing':
|
||||
self.startSyncing()
|
||||
except BaseException, msg:
|
||||
logging.writeToFile( str(msg) + ' [StagingSetup.run]')
|
||||
|
||||
def startCloning(self):
|
||||
try:
|
||||
tempStatusPath = self.extraArgs['tempStatusPath']
|
||||
masterDomain = self.extraArgs['masterDomain']
|
||||
domain = self.extraArgs['domain']
|
||||
admin = self.extraArgs['admin']
|
||||
|
||||
website = Websites.objects.get(domain=masterDomain)
|
||||
|
||||
## Creating Child Domain
|
||||
|
||||
path = "/home/" + masterDomain + "/public_html/" + domain
|
||||
|
||||
logging.statusWriter(tempStatusPath, 'Creating domain for staging environment..,5')
|
||||
phpSelection = 'PHP 7.1'
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
execPath = execPath + " createDomain --masterDomain " + masterDomain + " --virtualHostName " + domain + \
|
||||
" --phpVersion '" + phpSelection + "' --ssl 0 --dkimCheck 0 --openBasedir 0 --path " + path + ' --websiteOwner ' \
|
||||
+ admin.userName + ' --tempStatusPath %s' % (tempStatusPath + '1') + " --apache 0"
|
||||
|
||||
ProcessUtilities.executioner(execPath)
|
||||
|
||||
domainCreationStatusPath = tempStatusPath + '1'
|
||||
|
||||
data = open(domainCreationStatusPath, 'r').read()
|
||||
|
||||
if data.find('[200]') > -1:
|
||||
pass
|
||||
else:
|
||||
logging.statusWriter(tempStatusPath, 'Failed to create child-domain for staging enviroment. [404]')
|
||||
return 0
|
||||
|
||||
logging.statusWriter(tempStatusPath, 'Domain successfully created..,15')
|
||||
|
||||
## Copying Data
|
||||
|
||||
masterPath = '/home/%s/public_html' % (masterDomain)
|
||||
|
||||
command = 'rsync -avzh --exclude "%s" --exclude "wp-content/plugins/litespeed-cache" %s/ %s' % (domain, masterPath, path)
|
||||
ProcessUtilities.executioner(command, website.externalApp)
|
||||
|
||||
logging.statusWriter(tempStatusPath, 'Data copied..,50')
|
||||
|
||||
## Creating Database
|
||||
|
||||
logging.statusWriter(tempStatusPath, 'Creating and copying database..,50')
|
||||
|
||||
dbNameRestore, dbUser, dbPassword = ApplicationInstaller(None, None).dbCreation(tempStatusPath, website)
|
||||
|
||||
# Create dump of existing database
|
||||
|
||||
configPath = '%s/wp-config.php' % (masterPath)
|
||||
|
||||
if not os.path.exists(configPath):
|
||||
logging.statusWriter(tempStatusPath, 'WordPress is not detected. [404]')
|
||||
return 0
|
||||
|
||||
data = open(configPath, 'r').readlines()
|
||||
|
||||
for items in data:
|
||||
if items.find('DB_NAME') > -1:
|
||||
dbName = items.split("'")[3]
|
||||
if mysqlUtilities.createDatabaseBackup(dbName, '/home/cyberpanel'):
|
||||
break
|
||||
else:
|
||||
raise BaseException('Failed to create database backup.')
|
||||
|
||||
databasePath = '%s/%s.sql' % ('/home/cyberpanel', dbName)
|
||||
|
||||
command = "sed -i 's/%s/%s/g' %s" % (masterDomain, domain, databasePath)
|
||||
ProcessUtilities.executioner(command, 'cyberpanel')
|
||||
|
||||
if not mysqlUtilities.restoreDatabaseBackup(dbNameRestore, '/home/cyberpanel', None, 1, dbName):
|
||||
try:
|
||||
os.remove(databasePath)
|
||||
except:
|
||||
pass
|
||||
raise BaseException('Failed to restore database backup.')
|
||||
|
||||
try:
|
||||
os.remove(databasePath)
|
||||
except:
|
||||
pass
|
||||
|
||||
## Update final config file
|
||||
|
||||
pathFinalConfig = '%s/wp-config.php' % (path)
|
||||
data = open(pathFinalConfig, 'r').readlines()
|
||||
|
||||
tmp = "/tmp/" + str(randint(1000, 9999))
|
||||
writeToFile = open(tmp, 'w')
|
||||
|
||||
for items in data:
|
||||
if items.find('DB_NAME') > -1:
|
||||
writeToFile.write("define( 'DB_NAME', '%s' );\n" % (dbNameRestore))
|
||||
elif items.find('DB_USER') > -1:
|
||||
writeToFile.write("define( 'DB_USER', '%s' );\n" % (dbUser))
|
||||
elif items.find('DB_PASSWORD') > -1:
|
||||
writeToFile.write("define( 'DB_PASSWORD', '%s' );\n" % (dbPassword))
|
||||
else:
|
||||
writeToFile.write(items)
|
||||
|
||||
writeToFile.close()
|
||||
|
||||
command = 'mv %s %s' % (tmp, pathFinalConfig)
|
||||
ProcessUtilities.executioner(command, website.externalApp)
|
||||
|
||||
logging.statusWriter(tempStatusPath, 'Database synced..,100')
|
||||
|
||||
try:
|
||||
os.path.remove(databasePath)
|
||||
except:
|
||||
pass
|
||||
|
||||
logging.statusWriter(tempStatusPath, 'Data copied..,[200]')
|
||||
|
||||
return 0
|
||||
except BaseException, msg:
|
||||
mesg = '%s. [404]' % (str(msg))
|
||||
logging.statusWriter(tempStatusPath, mesg)
|
||||
|
||||
def startSyncing(self):
|
||||
try:
|
||||
tempStatusPath = self.extraArgs['tempStatusPath']
|
||||
childDomain = self.extraArgs['childDomain']
|
||||
eraseCheck = self.extraArgs['eraseCheck']
|
||||
dbCheck = self.extraArgs['dbCheck']
|
||||
copyChanged = self.extraArgs['copyChanged']
|
||||
|
||||
child = ChildDomains.objects.get(domain=childDomain)
|
||||
|
||||
configPath = '%s/wp-config.php' % (child.path)
|
||||
if not os.path.exists(configPath):
|
||||
logging.statusWriter(tempStatusPath, 'WordPress is not detected. [404]')
|
||||
return 0
|
||||
|
||||
if dbCheck:
|
||||
logging.statusWriter(tempStatusPath, 'Syncing databases..,10')
|
||||
|
||||
## Create backup of child-domain database
|
||||
|
||||
configPath = '%s/wp-config.php' % (child.path)
|
||||
|
||||
data = open(configPath, 'r').readlines()
|
||||
|
||||
for items in data:
|
||||
if items.find('DB_NAME') > -1:
|
||||
dbName = items.split("'")[3]
|
||||
if mysqlUtilities.createDatabaseBackup(dbName, '/home/cyberpanel'):
|
||||
break
|
||||
else:
|
||||
raise BaseException('Failed to create database backup.')
|
||||
|
||||
databasePath = '%s/%s.sql' % ('/home/cyberpanel', dbName)
|
||||
command = "sed -i 's/%s/%s/g' %s" % (child.domain, child.master.domain, databasePath)
|
||||
ProcessUtilities.executioner(command, 'cyberpanel')
|
||||
|
||||
## Restore to master domain
|
||||
|
||||
masterPath = '/home/%s/public_html' % (child.master.domain)
|
||||
|
||||
configPath = '%s/wp-config.php' % (masterPath)
|
||||
|
||||
data = open(configPath, 'r').readlines()
|
||||
|
||||
for items in data:
|
||||
if items.find('DB_NAME') > -1:
|
||||
dbNameRestore = items.split("'")[3]
|
||||
if not mysqlUtilities.restoreDatabaseBackup(dbNameRestore, '/home/cyberpanel', None, 1, dbName):
|
||||
try:
|
||||
os.remove(databasePath)
|
||||
except:
|
||||
pass
|
||||
raise BaseException('Failed to restore database backup.')
|
||||
|
||||
try:
|
||||
os.remove(databasePath)
|
||||
except:
|
||||
pass
|
||||
|
||||
if eraseCheck:
|
||||
sourcePath = child.path
|
||||
destinationPath = '/home/%s/public_html' % (child.master.domain)
|
||||
|
||||
command = 'rsync -avzh --exclude "wp-config.php" %s/ %s' % (sourcePath, destinationPath)
|
||||
ProcessUtilities.executioner(command, child.master.externalApp)
|
||||
elif copyChanged:
|
||||
sourcePath = child.path
|
||||
destinationPath = '/home/%s/public_html' % (child.master.domain)
|
||||
|
||||
command = 'rsync -avzh --exclude "wp-config.php" %s/ %s' % (sourcePath, destinationPath)
|
||||
ProcessUtilities.executioner(command, child.master.externalApp)
|
||||
|
||||
logging.statusWriter(tempStatusPath, 'Data copied..,[200]')
|
||||
|
||||
return 0
|
||||
except BaseException, msg:
|
||||
mesg = '%s. [404]' % (str(msg))
|
||||
logging.statusWriter(tempStatusPath, mesg)
|
||||
@@ -286,7 +286,6 @@ app.controller('listWebsites', function ($scope, $http) {
|
||||
} else {
|
||||
$("#listFail").fadeIn();
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
console.log(response.data);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -447,9 +446,8 @@ app.controller('deleteWebsiteControl', function ($scope, $http) {
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
console.log(response.data)
|
||||
|
||||
if (response.data.websiteDeleteStatus == 0) {
|
||||
if (response.data.websiteDeleteStatus === 0) {
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
$("#websiteDeleteFailure").fadeIn();
|
||||
$("#websiteDeleteSuccess").hide();
|
||||
@@ -471,7 +469,6 @@ app.controller('deleteWebsiteControl', function ($scope, $http) {
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
console.log("not good");
|
||||
}
|
||||
|
||||
|
||||
@@ -4943,7 +4940,6 @@ app.controller('sshAccess', function ($scope, $http, $timeout) {
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
@@ -4970,3 +4966,299 @@ app.controller('sshAccess', function ($scope, $http, $timeout) {
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
/* Java script code to cloneWebsite */
|
||||
app.controller('cloneWebsite', function ($scope, $http, $timeout, $window) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
$scope.goBackDisable = true;
|
||||
|
||||
var statusFile;
|
||||
|
||||
$scope.startCloning = function () {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = true;
|
||||
|
||||
$scope.currentStatus = "Cloning started..";
|
||||
|
||||
url = "/websites/startCloning";
|
||||
|
||||
|
||||
var data = {
|
||||
masterDomain: $("#domainName").text(),
|
||||
domainName: $scope.domain
|
||||
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
if (response.data.status === 1) {
|
||||
statusFile = response.data.tempStatusPath;
|
||||
getCreationStatus();
|
||||
} else {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$scope.currentStatus = response.data.error_message;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
$scope.goBack = function () {
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
$scope.goBackDisable = true;
|
||||
$("#installProgress").css("width", "0%");
|
||||
};
|
||||
|
||||
function getCreationStatus() {
|
||||
|
||||
url = "/websites/installWordpressStatus";
|
||||
|
||||
var data = {
|
||||
statusFile: statusFile
|
||||
};
|
||||
|
||||
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.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$("#installProgress").css("width", "100%");
|
||||
$scope.installPercentage = "100";
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout.cancel();
|
||||
|
||||
} else {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$scope.currentStatus = response.data.error_message;
|
||||
|
||||
$("#installProgress").css("width", "0%");
|
||||
$scope.installPercentage = "0";
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
$("#installProgress").css("width", response.data.installationProgress + "%");
|
||||
$scope.installPercentage = response.data.installationProgress;
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout(getCreationStatus, 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
/* Java script code to cloneWebsite ends here */
|
||||
|
||||
|
||||
/* Java script code to syncWebsite */
|
||||
app.controller('syncWebsite', function ($scope, $http, $timeout, $window) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
$scope.goBackDisable = true;
|
||||
|
||||
var statusFile;
|
||||
|
||||
$scope.startSyncing = function () {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = true;
|
||||
|
||||
$scope.currentStatus = "Cloning started..";
|
||||
|
||||
url = "/websites/startSync";
|
||||
|
||||
|
||||
var data = {
|
||||
childDomain: $("#childDomain").text(),
|
||||
eraseCheck: $scope.eraseCheck,
|
||||
dbCheck: $scope.dbCheck,
|
||||
copyChanged: $scope.copyChanged
|
||||
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
if (response.data.status === 1) {
|
||||
statusFile = response.data.tempStatusPath;
|
||||
getCreationStatus();
|
||||
} else {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$scope.currentStatus = response.data.error_message;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
$scope.goBack = function () {
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
$scope.goBackDisable = true;
|
||||
$("#installProgress").css("width", "0%");
|
||||
};
|
||||
|
||||
function getCreationStatus() {
|
||||
|
||||
url = "/websites/installWordpressStatus";
|
||||
|
||||
var data = {
|
||||
statusFile: statusFile
|
||||
};
|
||||
|
||||
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.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$("#installProgress").css("width", "100%");
|
||||
$scope.installPercentage = "100";
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout.cancel();
|
||||
|
||||
} else {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$scope.currentStatus = response.data.error_message;
|
||||
|
||||
$("#installProgress").css("width", "0%");
|
||||
$scope.installPercentage = "0";
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
$("#installProgress").css("width", response.data.installationProgress + "%");
|
||||
$scope.installPercentage = response.data.installationProgress;
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout(getCreationStatus, 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
/* Java script code to syncWebsite ends here */
|
||||
@@ -47,7 +47,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Domain Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
@@ -78,7 +77,6 @@
|
||||
</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">
|
||||
@@ -109,7 +107,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
@@ -120,7 +117,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="installationProgress" class="form-group">
|
||||
<label class="col-sm-2 control-label"></label>
|
||||
<div class="col-sm-7">
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
<h3 class="content-box-header">
|
||||
{% 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>
|
||||
</h3>
|
||||
|
||||
<div class="">
|
||||
|
||||
88
websiteFunctions/templates/websiteFunctions/setupStaging.html
Executable file
88
websiteFunctions/templates/websiteFunctions/setupStaging.html
Executable file
@@ -0,0 +1,88 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Set up Staging Enviroment - 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 "Set up Staging Enviroment" %}</h2>
|
||||
<p>{% trans "Set up staging enviroment for " %} {{ domainName }}. {% trans ". Any domain that you will choose here will be created as child-domain for this master site." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-controller="cloneWebsite" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
{% trans "Set up staging enviroment for " %}<span id="domainName">{{ domainName }}</span> <img
|
||||
ng-hide="cyberpanelLoading" 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"></label>
|
||||
<label class="col-sm-4 control-label">{% trans "Domain that you will enter below will be created as child-domain to " %}
|
||||
<spam id="domainName">{{ domainName }}</spam>
|
||||
{% trans '.' %}</label>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Domain" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="domain" 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="startCloning()"
|
||||
class="btn btn-primary btn-lg btn-block">{% trans "Start Cloning" %}</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>
|
||||
</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">{% trans "Go Back" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
104
websiteFunctions/templates/websiteFunctions/syncMaster.html
Executable file
104
websiteFunctions/templates/websiteFunctions/syncMaster.html
Executable file
@@ -0,0 +1,104 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Sync to Master - 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 "Sync your site to Master" %}</h2>
|
||||
<p>{% trans "Right now you can only sync your child domains to master domains."%} {{ childDomain }} {% trans " will be synced to " %} {{ domainName }}.</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-controller="syncWebsite" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
{% trans "Sync " %}<span id="childDomain">{{ childDomain }}</span> {% trans "to " %} <span id="domainName">{{ domainName }}</span><img
|
||||
ng-hide="cyberpanelLoading" 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 "What to Sync" %}</label>
|
||||
<div class="col-sm-9">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input ng-model="eraseCheck" type="checkbox" value="">
|
||||
Copy Complete Data
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-9">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input ng-model="dbCheck" type="checkbox" value="">
|
||||
Sync Database
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-9">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input ng-model="copyChanged" type="checkbox" value="">
|
||||
Copy Changed Files
|
||||
</label>
|
||||
</div>
|
||||
</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="startSyncing()"
|
||||
class="btn btn-primary btn-lg btn-block">{% trans "Start Syncing" %}</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>
|
||||
</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">{% trans "Go Back" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Resource Usage" %} <img ng-hide="domainLoading" src="/static/images/loading.gif">
|
||||
<a style="float: right; margin-left: 2%" class="btn btn-border btn-alt border-azure btn-link font-azure" href="/websites/{{ domain }}/setupStaging" title=""><span>{% trans "Clone/Staging" %}</span></a>
|
||||
<a style="float: right" class="btn btn-border btn-alt border-blue-alt btn-link font-blue-alt" href="/websites/{{ domain }}/sshAccess" title=""><span>{% trans "Set up SSH Access" %}</span></a>
|
||||
</h3>
|
||||
|
||||
|
||||
@@ -96,6 +96,13 @@ urlpatterns = [
|
||||
url(r'^(?P<domain>(.*))/sshAccess$', views.sshAccess, name='sshAccess'),
|
||||
url(r'^saveSSHAccessChanges$', views.saveSSHAccessChanges, name='saveSSHAccessChanges'),
|
||||
|
||||
## Staging Enviroment
|
||||
|
||||
url(r'^(?P<domain>(.*))/setupStaging$', views.setupStaging, name='setupStaging'),
|
||||
url(r'^startCloning$', views.startCloning, name='startCloning'),
|
||||
url(r'^(?P<domain>(.*))/(?P<childDomain>(.*))/syncToMaster$', views.syncToMaster, name='syncToMaster'),
|
||||
url(r'^startSync$', views.startSync, name='startSync'),
|
||||
|
||||
|
||||
url(r'^(?P<domain>(.*))/gitNotify$', views.gitNotify, name='gitNotify'),
|
||||
url(r'^detachRepo$', views.detachRepo, name='detachRepo'),
|
||||
|
||||
@@ -6,7 +6,7 @@ from django.http import HttpResponse
|
||||
from loginSystem.models import Administrator
|
||||
from loginSystem.views import loadLoginPage
|
||||
import json
|
||||
from plogical.website import WebsiteManager
|
||||
from websiteFunctions.website import WebsiteManager
|
||||
from websiteFunctions.pluginManager import pluginManager
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
@@ -622,3 +622,38 @@ def saveSSHAccessChanges(request):
|
||||
return wm.saveSSHAccessChanges(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def setupStaging(request, domain):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
wm = WebsiteManager(domain)
|
||||
return wm.setupStaging(request, userID)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def startCloning(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
wm = WebsiteManager()
|
||||
return wm.startCloning(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def syncToMaster(request, domain, childDomain):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
wm = WebsiteManager(domain)
|
||||
return wm.syncToMaster(request, userID, None, childDomain)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def startSync(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
wm = WebsiteManager()
|
||||
return wm.startSync(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
2482
websiteFunctions/website.py
Executable file
2482
websiteFunctions/website.py
Executable file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user