mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-02 11:26:28 +01:00
Prestashop Installer
This commit is contained in:
@@ -39,6 +39,8 @@ class ApplicationInstaller(multi.Thread):
|
|||||||
self.detachRepo()
|
self.detachRepo()
|
||||||
elif self.installApp == 'changeBranch':
|
elif self.installApp == 'changeBranch':
|
||||||
self.changeBranch()
|
self.changeBranch()
|
||||||
|
elif self.installApp == 'prestashop':
|
||||||
|
self.installPrestaShop()
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
logging.writeToFile( str(msg) + ' [ApplicationInstaller.run]')
|
logging.writeToFile( str(msg) + ' [ApplicationInstaller.run]')
|
||||||
@@ -309,6 +311,242 @@ class ApplicationInstaller(multi.Thread):
|
|||||||
statusFile.close()
|
statusFile.close()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def installPrestaShop(self):
|
||||||
|
try:
|
||||||
|
|
||||||
|
admin = self.extraArgs['admin']
|
||||||
|
domainName = self.extraArgs['domainName']
|
||||||
|
home = self.extraArgs['home']
|
||||||
|
shopName = self.extraArgs['shopName']
|
||||||
|
firstName = self.extraArgs['firstName']
|
||||||
|
lastName = self.extraArgs['lastName']
|
||||||
|
databasePrefix = self.extraArgs['databasePrefix']
|
||||||
|
email = self.extraArgs['email']
|
||||||
|
password = self.extraArgs['password']
|
||||||
|
tempStatusPath = self.extraArgs['tempStatusPath']
|
||||||
|
|
||||||
|
|
||||||
|
### Check WP CLI
|
||||||
|
|
||||||
|
|
||||||
|
## Open Status File
|
||||||
|
|
||||||
|
statusFile = open(tempStatusPath, 'w')
|
||||||
|
statusFile.writelines('Setting up paths,0')
|
||||||
|
statusFile.close()
|
||||||
|
|
||||||
|
try:
|
||||||
|
website = ChildDomains.objects.get(domain=domainName)
|
||||||
|
externalApp = website.master.externalApp
|
||||||
|
|
||||||
|
if admin.type != 1:
|
||||||
|
if website.master.admin != admin:
|
||||||
|
statusFile = open(tempStatusPath, 'w')
|
||||||
|
statusFile.writelines("You do not own this website." + " [404]")
|
||||||
|
statusFile.close()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
except:
|
||||||
|
website = Websites.objects.get(domain=domainName)
|
||||||
|
externalApp = website.externalApp
|
||||||
|
|
||||||
|
if admin.type != 1:
|
||||||
|
if website.admin != admin:
|
||||||
|
statusFile = open(tempStatusPath, 'w')
|
||||||
|
statusFile.writelines("You do not own this website." + " [404]")
|
||||||
|
statusFile.close()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
finalPath = ""
|
||||||
|
|
||||||
|
|
||||||
|
if home == '0':
|
||||||
|
path = self.extraArgs['path']
|
||||||
|
finalPath = "/home/" + domainName + "/public_html/" + path + "/"
|
||||||
|
else:
|
||||||
|
finalPath = "/home/" + domainName + "/public_html/"
|
||||||
|
|
||||||
|
|
||||||
|
## Security Check
|
||||||
|
|
||||||
|
if finalPath.find("..") > -1:
|
||||||
|
statusFile = open(tempStatusPath, 'w')
|
||||||
|
statusFile.writelines("Specified path must be inside virtual host home." + " [404]")
|
||||||
|
statusFile.close()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
FNULL = open(os.devnull, 'w')
|
||||||
|
|
||||||
|
if not os.path.exists(finalPath):
|
||||||
|
command = 'sudo mkdir -p ' + finalPath
|
||||||
|
subprocess.call(shlex.split(command))
|
||||||
|
|
||||||
|
## checking for directories/files
|
||||||
|
|
||||||
|
dirFiles = os.listdir(finalPath)
|
||||||
|
|
||||||
|
if len(dirFiles) == 1:
|
||||||
|
if dirFiles[0] == ".well-known":
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
statusFile = open(tempStatusPath, 'w')
|
||||||
|
statusFile.writelines("Target directory should be empty before installation, otherwise data loss could occur." + " [404]")
|
||||||
|
statusFile.close()
|
||||||
|
return 0
|
||||||
|
elif len(dirFiles) == 0:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
statusFile = open(tempStatusPath, 'w')
|
||||||
|
statusFile.writelines(
|
||||||
|
"Target directory should be empty before installation, otherwise data loss could occur." + " [404]")
|
||||||
|
statusFile.close()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## DB Creation
|
||||||
|
|
||||||
|
statusFile = open(tempStatusPath, 'w')
|
||||||
|
statusFile.writelines('Setting up Database,20')
|
||||||
|
statusFile.close()
|
||||||
|
|
||||||
|
dbName = randomPassword.generate_pass()
|
||||||
|
dbUser = dbName
|
||||||
|
dbPassword = randomPassword.generate_pass()
|
||||||
|
|
||||||
|
## DB Creation
|
||||||
|
|
||||||
|
if website.package.dataBases > website.databases_set.all().count():
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
statusFile = open(tempStatusPath, 'w')
|
||||||
|
statusFile.writelines(
|
||||||
|
"Maximum database limit reached for this website." + " [404]")
|
||||||
|
statusFile.close()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if Databases.objects.filter(dbName=dbName).exists() or Databases.objects.filter(
|
||||||
|
dbUser=dbUser).exists():
|
||||||
|
statusFile = open(tempStatusPath, 'w')
|
||||||
|
statusFile.writelines(
|
||||||
|
"This database or user is already taken." + " [404]")
|
||||||
|
statusFile.close()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
result = mysqlUtilities.createDatabase(dbName, dbUser, dbPassword)
|
||||||
|
|
||||||
|
if result == 1:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
statusFile = open(tempStatusPath, 'w')
|
||||||
|
statusFile.writelines(
|
||||||
|
"Not able to create database." + " [404]")
|
||||||
|
statusFile.close()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
db = Databases(website=website, dbName=dbName, dbUser=dbUser)
|
||||||
|
db.save()
|
||||||
|
|
||||||
|
|
||||||
|
####
|
||||||
|
|
||||||
|
statusFile = open(tempStatusPath, 'w')
|
||||||
|
statusFile.writelines('Downloading and extracting PrestaShop Core..,30')
|
||||||
|
statusFile.close()
|
||||||
|
|
||||||
|
command = "sudo wget https://download.prestashop.com/download/releases/prestashop_1.7.4.2.zip"
|
||||||
|
subprocess.call(shlex.split(command))
|
||||||
|
|
||||||
|
command = "sudo unzip -o prestashop_1.7.4.2.zip -d " + finalPath
|
||||||
|
subprocess.call(shlex.split(command))
|
||||||
|
|
||||||
|
command = "sudo unzip -o " + finalPath + "prestashop.zip -d " + finalPath
|
||||||
|
subprocess.call(shlex.split(command))
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
statusFile = open(tempStatusPath, 'w')
|
||||||
|
statusFile.writelines('Configuring the installation,40')
|
||||||
|
statusFile.close()
|
||||||
|
|
||||||
|
if home == '0':
|
||||||
|
path = self.extraArgs['path']
|
||||||
|
finalURL = domainName + '/' + path
|
||||||
|
else:
|
||||||
|
finalURL = domainName
|
||||||
|
|
||||||
|
statusFile = open(tempStatusPath, 'w')
|
||||||
|
statusFile.writelines('Installing and configuring PrestaShop..,60')
|
||||||
|
statusFile.close()
|
||||||
|
|
||||||
|
command = "sudo php " + finalPath + "install/index_cli.php --domain=" + finalURL + \
|
||||||
|
" --db_server=localhost --db_name=" + dbName + " --db_user=" + dbUser + " --db_password=" + dbPassword \
|
||||||
|
+ " --name='" + shopName + "' --firstname=" + firstName + " --lastname=" + lastName + \
|
||||||
|
" --email=" + email + " --password=" + password
|
||||||
|
subprocess.call(shlex.split(command))
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
command = "sudo rm -rf" + finalPath + "install"
|
||||||
|
subprocess.call(shlex.split(command))
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + "/home/" + domainName + "/public_html/"
|
||||||
|
cmd = shlex.split(command)
|
||||||
|
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
|
command = "sudo rm -f prestashop_1.7.4.2.zip"
|
||||||
|
cmd = shlex.split(command)
|
||||||
|
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
|
vhost.addRewriteRules(domainName)
|
||||||
|
installUtilities.reStartLiteSpeed()
|
||||||
|
|
||||||
|
|
||||||
|
statusFile = open(tempStatusPath, 'w')
|
||||||
|
statusFile.writelines("Successfully Installed. [200]")
|
||||||
|
statusFile.close()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
# remove the downloaded files
|
||||||
|
try:
|
||||||
|
|
||||||
|
command = "sudo rm -rf " + finalPath
|
||||||
|
cmd = shlex.split(command)
|
||||||
|
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
logging.writeToFile(str(msg) + " [installWordPress]")
|
||||||
|
|
||||||
|
homeDir = "/home/" + domainName + "/public_html"
|
||||||
|
|
||||||
|
if not os.path.exists(homeDir):
|
||||||
|
FNULL = open(os.devnull, 'w')
|
||||||
|
|
||||||
|
command = 'sudo mkdir ' + homeDir
|
||||||
|
subprocess.call(shlex.split(command))
|
||||||
|
|
||||||
|
|
||||||
|
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + homeDir
|
||||||
|
cmd = shlex.split(command)
|
||||||
|
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
|
try:
|
||||||
|
mysqlUtilities.deleteDatabase(dbName, dbUser)
|
||||||
|
db = Databases.objects.get(dbName=dbName)
|
||||||
|
db.delete()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
statusFile = open(tempStatusPath, 'w')
|
||||||
|
statusFile.writelines(str(msg) + " [404]")
|
||||||
|
statusFile.close()
|
||||||
|
return 0
|
||||||
|
|
||||||
def setupGit(self):
|
def setupGit(self):
|
||||||
try:
|
try:
|
||||||
admin = self.extraArgs['admin']
|
admin = self.extraArgs['admin']
|
||||||
|
|||||||
BIN
static/images/icons/prestashop.png
Normal file
BIN
static/images/icons/prestashop.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
@@ -566,6 +566,7 @@ app.controller('websitePages', function($scope, $http, $timeout, $window) {
|
|||||||
$scope.wordPressInstallURL = $("#domainNamePage").text() + "/wordpressInstall";
|
$scope.wordPressInstallURL = $("#domainNamePage").text() + "/wordpressInstall";
|
||||||
$scope.joomlaInstallURL = $("#domainNamePage").text() + "/joomlaInstall";
|
$scope.joomlaInstallURL = $("#domainNamePage").text() + "/joomlaInstall";
|
||||||
$scope.setupGit = $("#domainNamePage").text() + "/setupGit";
|
$scope.setupGit = $("#domainNamePage").text() + "/setupGit";
|
||||||
|
$scope.installPrestaURL = $("#domainNamePage").text() + "/installPrestaShop";
|
||||||
$scope.domainAliasURL = "/websites/"+$("#domainNamePage").text()+"/domainAlias";
|
$scope.domainAliasURL = "/websites/"+$("#domainNamePage").text()+"/domainAlias";
|
||||||
$scope.previewUrl = "/preview/"+$("#domainNamePage").text()+"/";
|
$scope.previewUrl = "/preview/"+$("#domainNamePage").text()+"/";
|
||||||
|
|
||||||
@@ -1443,6 +1444,7 @@ app.controller('websitePages', function($scope, $http, $timeout, $window) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//////// SSL Part
|
//////// SSL Part
|
||||||
|
|
||||||
$scope.sslSaved = true;
|
$scope.sslSaved = true;
|
||||||
@@ -4721,3 +4723,196 @@ app.controller('setupGit', function($scope, $http, $timeout, $window) {
|
|||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.controller('installPrestaShopCTRL', function($scope, $http, $timeout) {
|
||||||
|
|
||||||
|
$scope.installationDetailsForm = false;
|
||||||
|
$scope.installationProgress = true;
|
||||||
|
$scope.installationFailed = true;
|
||||||
|
$scope.installationSuccessfull = true;
|
||||||
|
$scope.couldNotConnect = true;
|
||||||
|
$scope.wpInstallLoading = true;
|
||||||
|
$scope.goBackDisable = true;
|
||||||
|
|
||||||
|
$scope.databasePrefix = 'ps_';
|
||||||
|
|
||||||
|
var statusFile;
|
||||||
|
var domain = $("#domainNamePage").text();
|
||||||
|
var path;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$scope.goBack = function () {
|
||||||
|
$scope.installationDetailsForm = false;
|
||||||
|
$scope.installationProgress = true;
|
||||||
|
$scope.installationFailed = true;
|
||||||
|
$scope.installationSuccessfull = true;
|
||||||
|
$scope.couldNotConnect = true;
|
||||||
|
$scope.wpInstallLoading = true;
|
||||||
|
$scope.goBackDisable = true;
|
||||||
|
$("#installProgress").css("width", "0%");
|
||||||
|
};
|
||||||
|
|
||||||
|
function getInstallStatus(){
|
||||||
|
|
||||||
|
url = "/websites/installWordpressStatus";
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
statusFile: statusFile,
|
||||||
|
domainName: domain
|
||||||
|
};
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
headers : {
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||||
|
|
||||||
|
|
||||||
|
function ListInitialDatas(response) {
|
||||||
|
|
||||||
|
|
||||||
|
if(response.data.abort === 1){
|
||||||
|
|
||||||
|
if(response.data.installStatus === 1){
|
||||||
|
|
||||||
|
$scope.installationDetailsForm = true;
|
||||||
|
$scope.installationProgress = false;
|
||||||
|
$scope.installationFailed = true;
|
||||||
|
$scope.installationSuccessfull = false;
|
||||||
|
$scope.couldNotConnect = true;
|
||||||
|
$scope.wpInstallLoading = true;
|
||||||
|
$scope.goBackDisable = false;
|
||||||
|
|
||||||
|
if (typeof path !== 'undefined'){
|
||||||
|
$scope.installationURL = "http://"+domain+"/"+path;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$scope.installationURL = domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$("#installProgress").css("width", "100%");
|
||||||
|
$scope.installPercentage = "100";
|
||||||
|
$scope.currentStatus = response.data.currentStatus;
|
||||||
|
$timeout.cancel();
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
$scope.installationDetailsForm = true;
|
||||||
|
$scope.installationProgress = false;
|
||||||
|
$scope.installationFailed = false;
|
||||||
|
$scope.installationSuccessfull = true;
|
||||||
|
$scope.couldNotConnect = true;
|
||||||
|
$scope.wpInstallLoading = true;
|
||||||
|
$scope.goBackDisable = false;
|
||||||
|
|
||||||
|
$scope.errorMessage = response.data.error_message;
|
||||||
|
|
||||||
|
$("#installProgress").css("width", "0%");
|
||||||
|
$scope.installPercentage = "0";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$("#installProgress").css("width", response.data.installationProgress + "%");
|
||||||
|
$scope.installPercentage = response.data.installationProgress;
|
||||||
|
$scope.currentStatus = response.data.currentStatus;
|
||||||
|
|
||||||
|
$timeout(getInstallStatus,1000);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
function cantLoadInitialDatas(response) {
|
||||||
|
|
||||||
|
$scope.canNotFetch = true;
|
||||||
|
$scope.couldNotConnect = false;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.installPrestShop = 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/prestaShopInstall";
|
||||||
|
|
||||||
|
var home = "1";
|
||||||
|
|
||||||
|
if (typeof path !== 'undefined'){
|
||||||
|
home = "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
domain: domain,
|
||||||
|
home:home,
|
||||||
|
path:path,
|
||||||
|
shopName: $scope.shopName,
|
||||||
|
firstName: $scope.firstName,
|
||||||
|
lastName: $scope.lastName,
|
||||||
|
databasePrefix: $scope.databasePrefix,
|
||||||
|
email: $scope.email,
|
||||||
|
password: $scope.password
|
||||||
|
};
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
headers : {
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||||
|
|
||||||
|
|
||||||
|
function ListInitialDatas(response) {
|
||||||
|
|
||||||
|
if (response.data.installStatus === 1)
|
||||||
|
{
|
||||||
|
statusFile = response.data.tempStatusPath;
|
||||||
|
getInstallStatus();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
$scope.installationDetailsForm = true;
|
||||||
|
$scope.installationProgress = false;
|
||||||
|
$scope.installationFailed = false;
|
||||||
|
$scope.installationSuccessfull = true;
|
||||||
|
$scope.couldNotConnect = true;
|
||||||
|
$scope.wpInstallLoading = true;
|
||||||
|
$scope.goBackDisable = false;
|
||||||
|
|
||||||
|
$scope.errorMessage = response.data.error_message;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
function cantLoadInitialDatas(response) {}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
BIN
websiteFunctions/static/images/icons/prestashop.png
Normal file
BIN
websiteFunctions/static/images/icons/prestashop.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
@@ -566,6 +566,7 @@ app.controller('websitePages', function($scope, $http, $timeout, $window) {
|
|||||||
$scope.wordPressInstallURL = $("#domainNamePage").text() + "/wordpressInstall";
|
$scope.wordPressInstallURL = $("#domainNamePage").text() + "/wordpressInstall";
|
||||||
$scope.joomlaInstallURL = $("#domainNamePage").text() + "/joomlaInstall";
|
$scope.joomlaInstallURL = $("#domainNamePage").text() + "/joomlaInstall";
|
||||||
$scope.setupGit = $("#domainNamePage").text() + "/setupGit";
|
$scope.setupGit = $("#domainNamePage").text() + "/setupGit";
|
||||||
|
$scope.installPrestaURL = $("#domainNamePage").text() + "/installPrestaShop";
|
||||||
$scope.domainAliasURL = "/websites/"+$("#domainNamePage").text()+"/domainAlias";
|
$scope.domainAliasURL = "/websites/"+$("#domainNamePage").text()+"/domainAlias";
|
||||||
$scope.previewUrl = "/preview/"+$("#domainNamePage").text()+"/";
|
$scope.previewUrl = "/preview/"+$("#domainNamePage").text()+"/";
|
||||||
|
|
||||||
@@ -1443,6 +1444,7 @@ app.controller('websitePages', function($scope, $http, $timeout, $window) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//////// SSL Part
|
//////// SSL Part
|
||||||
|
|
||||||
$scope.sslSaved = true;
|
$scope.sslSaved = true;
|
||||||
@@ -4721,3 +4723,196 @@ app.controller('setupGit', function($scope, $http, $timeout, $window) {
|
|||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.controller('installPrestaShopCTRL', function($scope, $http, $timeout) {
|
||||||
|
|
||||||
|
$scope.installationDetailsForm = false;
|
||||||
|
$scope.installationProgress = true;
|
||||||
|
$scope.installationFailed = true;
|
||||||
|
$scope.installationSuccessfull = true;
|
||||||
|
$scope.couldNotConnect = true;
|
||||||
|
$scope.wpInstallLoading = true;
|
||||||
|
$scope.goBackDisable = true;
|
||||||
|
|
||||||
|
$scope.databasePrefix = 'ps_';
|
||||||
|
|
||||||
|
var statusFile;
|
||||||
|
var domain = $("#domainNamePage").text();
|
||||||
|
var path;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$scope.goBack = function () {
|
||||||
|
$scope.installationDetailsForm = false;
|
||||||
|
$scope.installationProgress = true;
|
||||||
|
$scope.installationFailed = true;
|
||||||
|
$scope.installationSuccessfull = true;
|
||||||
|
$scope.couldNotConnect = true;
|
||||||
|
$scope.wpInstallLoading = true;
|
||||||
|
$scope.goBackDisable = true;
|
||||||
|
$("#installProgress").css("width", "0%");
|
||||||
|
};
|
||||||
|
|
||||||
|
function getInstallStatus(){
|
||||||
|
|
||||||
|
url = "/websites/installWordpressStatus";
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
statusFile: statusFile,
|
||||||
|
domainName: domain
|
||||||
|
};
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
headers : {
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||||
|
|
||||||
|
|
||||||
|
function ListInitialDatas(response) {
|
||||||
|
|
||||||
|
|
||||||
|
if(response.data.abort === 1){
|
||||||
|
|
||||||
|
if(response.data.installStatus === 1){
|
||||||
|
|
||||||
|
$scope.installationDetailsForm = true;
|
||||||
|
$scope.installationProgress = false;
|
||||||
|
$scope.installationFailed = true;
|
||||||
|
$scope.installationSuccessfull = false;
|
||||||
|
$scope.couldNotConnect = true;
|
||||||
|
$scope.wpInstallLoading = true;
|
||||||
|
$scope.goBackDisable = false;
|
||||||
|
|
||||||
|
if (typeof path !== 'undefined'){
|
||||||
|
$scope.installationURL = "http://"+domain+"/"+path;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$scope.installationURL = domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$("#installProgress").css("width", "100%");
|
||||||
|
$scope.installPercentage = "100";
|
||||||
|
$scope.currentStatus = response.data.currentStatus;
|
||||||
|
$timeout.cancel();
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
$scope.installationDetailsForm = true;
|
||||||
|
$scope.installationProgress = false;
|
||||||
|
$scope.installationFailed = false;
|
||||||
|
$scope.installationSuccessfull = true;
|
||||||
|
$scope.couldNotConnect = true;
|
||||||
|
$scope.wpInstallLoading = true;
|
||||||
|
$scope.goBackDisable = false;
|
||||||
|
|
||||||
|
$scope.errorMessage = response.data.error_message;
|
||||||
|
|
||||||
|
$("#installProgress").css("width", "0%");
|
||||||
|
$scope.installPercentage = "0";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$("#installProgress").css("width", response.data.installationProgress + "%");
|
||||||
|
$scope.installPercentage = response.data.installationProgress;
|
||||||
|
$scope.currentStatus = response.data.currentStatus;
|
||||||
|
|
||||||
|
$timeout(getInstallStatus,1000);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
function cantLoadInitialDatas(response) {
|
||||||
|
|
||||||
|
$scope.canNotFetch = true;
|
||||||
|
$scope.couldNotConnect = false;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.installPrestShop = 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/prestaShopInstall";
|
||||||
|
|
||||||
|
var home = "1";
|
||||||
|
|
||||||
|
if (typeof path !== 'undefined'){
|
||||||
|
home = "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
domain: domain,
|
||||||
|
home:home,
|
||||||
|
path:path,
|
||||||
|
shopName: $scope.shopName,
|
||||||
|
firstName: $scope.firstName,
|
||||||
|
lastName: $scope.lastName,
|
||||||
|
databasePrefix: $scope.databasePrefix,
|
||||||
|
email: $scope.email,
|
||||||
|
password: $scope.password
|
||||||
|
};
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
headers : {
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||||
|
|
||||||
|
|
||||||
|
function ListInitialDatas(response) {
|
||||||
|
|
||||||
|
if (response.data.installStatus === 1)
|
||||||
|
{
|
||||||
|
statusFile = response.data.tempStatusPath;
|
||||||
|
getInstallStatus();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
$scope.installationDetailsForm = true;
|
||||||
|
$scope.installationProgress = false;
|
||||||
|
$scope.installationFailed = false;
|
||||||
|
$scope.installationSuccessfull = true;
|
||||||
|
$scope.couldNotConnect = true;
|
||||||
|
$scope.wpInstallLoading = true;
|
||||||
|
$scope.goBackDisable = false;
|
||||||
|
|
||||||
|
$scope.errorMessage = response.data.error_message;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
function cantLoadInitialDatas(response) {}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
{% extends "baseTemplate/index.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% block title %}{% trans "Install PrestaShop - 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 PrestaShop" %}</h2>
|
||||||
|
<p>{% trans "One-click PrestaShop Install!" %}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div ng-controller="installPrestaShopCTRL" 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 "Shop Name" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="text" class="form-control" ng-model="shopName" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-hide="installationDetailsForm" class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "First Name" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="text" class="form-control" ng-model="firstName" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-hide="installationDetailsForm" class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Last Name" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="text" class="form-control" ng-model="lastName" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-hide="installationDetailsForm" class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Email" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="email" class="form-control" ng-model="email" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-hide="installationDetailsForm" class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="password" class="form-control" ng-model="password" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-hide="installationDetailsForm" class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Database Prefix" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="text" class="form-control" ng-model="databasePrefix" 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="installPrestShop()" 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 %}
|
||||||
@@ -966,10 +966,10 @@
|
|||||||
|
|
||||||
<div class="col-md-4" style="margin-bottom: 2%;">
|
<div class="col-md-4" style="margin-bottom: 2%;">
|
||||||
|
|
||||||
<a href="{$ joomlaInstallURL $}" target="_blank" title="{% trans 'Install Joomla with(?) LSCache' %}">
|
<a href="{$ joomlaInstallURL $}" target="_blank" title="{% trans 'Install Joomla with LSCache' %}">
|
||||||
<img src="{% static 'images/icons/joomla-logo.png' %}">
|
<img src="{% static 'images/icons/joomla-logo.png' %}">
|
||||||
</a>
|
</a>
|
||||||
<a href="{$ joomlaInstallURL $}" target="_blank" title="{% trans 'Install Joomla with(?) LSCache' %}">
|
<a href="{$ joomlaInstallURL $}" target="_blank" title="{% trans 'Install Joomla with LSCache' %}">
|
||||||
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "Joomla" %}</span>
|
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "Joomla" %}</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
@@ -988,6 +988,19 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="col-md-4" style="margin-bottom: 2%;">
|
||||||
|
|
||||||
|
<a href="{$ installPrestaURL $}" target="_blank" title="{% trans 'Install Prestashop' %}">
|
||||||
|
<img src="{% static 'images/icons/prestashop.png' %}">
|
||||||
|
</a>
|
||||||
|
<a href="{$ installPrestaURL $}" target="_blank" title="{% trans 'Install Prestashop' %}">
|
||||||
|
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "Prestashop" %}</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,11 @@ urlpatterns = [
|
|||||||
url(r'^installJoomla$', views.installJoomla, name='installJoomla'),
|
url(r'^installJoomla$', views.installJoomla, name='installJoomla'),
|
||||||
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/joomlaInstall$', views.joomlaInstall, name='joomlaInstall'),
|
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/joomlaInstall$', views.joomlaInstall, name='joomlaInstall'),
|
||||||
|
|
||||||
|
## PrestaShop Install
|
||||||
|
|
||||||
|
url(r'^prestaShopInstall$', views.prestaShopInstall, name='prestaShopInstall'),
|
||||||
|
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/installPrestaShop$', views.installPrestaShop, name='installPrestaShop'),
|
||||||
|
|
||||||
|
|
||||||
## Git
|
## Git
|
||||||
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/setupGit$', views.setupGit, name='setupGit'),
|
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/setupGit$', views.setupGit, name='setupGit'),
|
||||||
|
|||||||
@@ -2345,7 +2345,6 @@ def joomlaInstall(request, domain):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def installJoomla(request):
|
def installJoomla(request):
|
||||||
try:
|
try:
|
||||||
val = request.session['userID']
|
val = request.session['userID']
|
||||||
@@ -2673,3 +2672,69 @@ def changeBranch(request):
|
|||||||
status = {"status":0,"error":str(msg)}
|
status = {"status":0,"error":str(msg)}
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installWordpress]")
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installWordpress]")
|
||||||
return HttpResponse("Not Logged in as admin")
|
return HttpResponse("Not Logged in as admin")
|
||||||
|
|
||||||
|
def installPrestaShop(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/installPrestaShop.html', {'domainName' : domain})
|
||||||
|
except BaseException, msg:
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||||
|
return HttpResponse(str(msg))
|
||||||
|
except KeyError:
|
||||||
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
def prestaShopInstall(request):
|
||||||
|
try:
|
||||||
|
val = request.session['userID']
|
||||||
|
admin = Administrator.objects.get(id=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['shopName'] = data['shopName']
|
||||||
|
extraArgs['firstName'] = data['firstName']
|
||||||
|
extraArgs['lastName'] = data['lastName']
|
||||||
|
extraArgs['databasePrefix'] = data['databasePrefix']
|
||||||
|
extraArgs['email'] = data['email']
|
||||||
|
extraArgs['password'] = data['password']
|
||||||
|
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||||
|
|
||||||
|
if data['home'] == '0':
|
||||||
|
extraArgs['path'] = data['path']
|
||||||
|
|
||||||
|
background = ApplicationInstaller('prestashop', extraArgs)
|
||||||
|
background.start()
|
||||||
|
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
data_ret = {'installStatus': 1, 'error_message': 'None', 'tempStatusPath': extraArgs['tempStatusPath']}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Installation ends
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
data_ret = {'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) + "[installJoomla]")
|
||||||
|
return HttpResponse("Not Logged in as admin")
|
||||||
Reference in New Issue
Block a user