Improved Joomla Installation process.

This commit is contained in:
usmannasir
2018-07-13 21:45:40 +05:00
parent eb3bd4844f
commit 86702824cc
12 changed files with 880 additions and 388 deletions

View File

@@ -572,6 +572,36 @@
<!--- copy modal -->
<!-- rename modal -->
<div id="showRename" class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div id="htmlEditorLable" class="modal-header">
<h5 class="modal-title">{% trans "Renaming" %} {$ fileToRename $} <img ng-hide="renameLoading" src="{% static 'filemanager/images/loadingSmall.gif' %}"></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label>{% trans "New Name" %}</label>
<input ng-model="newFileName" type="text" class="form-control">
<small class="form-text text-muted">{% trans "Enter new name of file!" %}</small>
</div>
</form>
</div>
<div class="modal-footer">
<button ng-click="renameFile()" type="button" class="btn btn-primary">{% trans "Rename" %}</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">{% trans "Close" %}</button>
</div>
</div>
</div>
</div>
<!--- rename modal -->
<!-- Permissions modal -->
<div id="showPermissions" class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">

6
install/composer.sh Normal file
View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
cp composer.phar /usr/bin/composer

View File

@@ -2690,6 +2690,23 @@ milter_default_action = accept
logging.InstallLog.writeToFile(str(msg) + " [setupCLI]")
return 0
def setupPHPAndComposer(self):
try:
command = "cp /usr/local/lsws/lsphp71/bin/php /usr/bin/"
res = subprocess.call(shlex.split(command))
os.chdir(self.cwd)
command = "chmod +x composer.sh"
res = subprocess.call(shlex.split(command))
command = "./composer.sh"
res = subprocess.call(shlex.split(command))
except OSError, msg:
logging.InstallLog.writeToFile(str(msg) + " [setupPHPAndComposer]")
return 0
@staticmethod
def setupVirtualEnv():
try:
@@ -2884,6 +2901,7 @@ def main():
checks.modSecPreReqs()
checks.setupVirtualEnv()
checks.setupPHPAndComposer()
checks.installation_successfull()
logging.InstallLog.writeToFile("CyberPanel installation successfully completed!")

View File

@@ -396,7 +396,7 @@ def submitPasswordChange(request):
email = data['email']
password = data['password']
emailDB = EUsers(email=email)
emailDB = EUsers.objects.get(email=email)
if admin.type != 1:
if emailDB.emailOwner.domainOwner.admin != admin:

View File

@@ -29,6 +29,8 @@ class ApplicationInstaller(multi.Thread):
try:
if self.installApp == 'wordpress':
self.installWordPress()
elif self.installApp == 'joomla':
self.installJoomla()
except BaseException, msg:
logging.writeToFile( str(msg) + ' [ApplicationInstaller.run]')
@@ -49,7 +51,6 @@ class ApplicationInstaller(multi.Thread):
logging.writeToFile( str(msg) + ' [ApplicationInstaller.installWPCLI]')
def installWordPress(self):
try:
@@ -165,18 +166,30 @@ class ApplicationInstaller(multi.Thread):
if website.package.dataBases > website.databases_set.all().count():
pass
else:
raise BaseException("Maximum database limit reached for this website.")
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():
raise BaseException("This database or user is already taken.")
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:
raise BaseException("Not able to create database.")
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()
@@ -225,8 +238,6 @@ class ApplicationInstaller(multi.Thread):
command = "sudo wp plugin activate litespeed-cache --allow-root --path=" + finalPath
subprocess.call(shlex.split(command))
##
@@ -279,3 +290,191 @@ class ApplicationInstaller(multi.Thread):
statusFile.writelines(str(msg) + " [404]")
statusFile.close()
return 0
def installJoomla(self):
try:
domainName = self.extraArgs['domainName']
finalPath = self.extraArgs['finalPath']
virtualHostUser = self.extraArgs['virtualHostUser']
dbName = self.extraArgs['dbName']
dbUser = self.extraArgs['dbUser']
dbPassword = self.extraArgs['dbPassword']
username = self.extraArgs['username']
password = self.extraArgs['password']
prefix = self.extraArgs['prefix']
sitename = self.extraArgs['sitename']
tempStatusPath = self.extraArgs['tempStatusPath']
FNULL = open(os.devnull, 'w')
if not os.path.exists(finalPath):
os.makedirs(finalPath)
## 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
## Get Joomla
os.chdir(finalPath)
if not os.path.exists("staging.zip"):
command = 'wget --no-check-certificate https://github.com/joomla/joomla-cms/archive/staging.zip -P ' + finalPath
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
else:
statusFile = open(tempStatusPath, 'w')
statusFile.writelines("File already exists." + " [404]")
statusFile.close()
return 0
command = 'unzip ' + finalPath + 'staging.zip -d ' + finalPath
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
os.remove(finalPath + 'staging.zip')
command = 'cp -r ' + finalPath + 'joomla-cms-staging/. ' + finalPath
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
shutil.rmtree(finalPath + "joomla-cms-staging")
os.rename(finalPath + "installation/configuration.php-dist", finalPath + "configuration.php")
os.rename(finalPath + "robots.txt.dist", finalPath + "robots.txt")
os.rename(finalPath + "htaccess.txt", finalPath + ".htaccess")
## edit config file
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Creating configuration files.,40')
statusFile.close()
configfile = finalPath + "configuration.php"
data = open(configfile, "r").readlines()
writeDataToFile = open(configfile, "w")
secret = randomPassword.generate_pass()
defDBName = " public $user = '" + dbName + "';" + "\n"
defDBUser = " public $db = '" + dbUser + "';" + "\n"
defDBPassword = " public $password = '" + dbPassword + "';" + "\n"
secretKey = " public $secret = '" + secret + "';" + "\n"
logPath = " public $log_path = '" + finalPath + "administrator/logs';" + "\n"
tmpPath = " public $tmp_path = '" + finalPath + "administrator/tmp';" + "\n"
dbprefix = " public $dbprefix = '" + prefix + "';" + "\n"
sitename = " public $sitename = '" + sitename + "';" + "\n"
for items in data:
if items.find("public $user ") > -1:
writeDataToFile.writelines(defDBUser)
elif items.find("public $password ") > -1:
writeDataToFile.writelines(defDBPassword)
elif items.find("public $db ") > -1:
writeDataToFile.writelines(defDBName)
elif items.find("public $log_path ") > -1:
writeDataToFile.writelines(logPath)
elif items.find("public $tmp_path ") > -1:
writeDataToFile.writelines(tmpPath)
elif items.find("public $secret ") > -1:
writeDataToFile.writelines(secretKey)
elif items.find("public $dbprefix ") > -1:
writeDataToFile.writelines(dbprefix)
elif items.find("public $sitename ") > -1:
writeDataToFile.writelines(sitename)
elif items.find("/*") > -1:
pass
elif items.find(" *") > -1:
pass
else:
writeDataToFile.writelines(items)
writeDataToFile.close()
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Creating default user..,70')
statusFile.close()
# Rename SQL db prefix
f1 = open(finalPath + 'installation/sql/mysql/joomla.sql', 'r')
f2 = open('installation/sql/mysql/joomlaInstall.sql', 'w')
for line in f1:
f2.write(line.replace('#__', prefix))
f1.close()
f2.close()
# Restore SQL
proc = subprocess.Popen(["mysql", "--user=%s" % dbUser, "--password=%s" % dbPassword, dbName],
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
usercreation = """INSERT INTO `%susers`
(`name`, `username`, `password`, `params`)
VALUES ('Administrator', '%s',
'%s', '');
INSERT INTO `%suser_usergroup_map` (`user_id`,`group_id`)
VALUES (LAST_INSERT_ID(),'8');""" % (prefix, username, password, prefix)
out, err = proc.communicate(
file(finalPath + 'installation/sql/mysql/joomlaInstall.sql').read() + "\n" + usercreation)
shutil.rmtree(finalPath + "installation")
command = "chown -R " + virtualHostUser + ":" + virtualHostUser + " " + "/home/" + domainName + "/public_html/"
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:
shutil.rmtree(finalPath)
except:
logging.writeToFile("shutil.rmtree(finalPath)")
homeDir = "/home/" + domainName + "/public_html"
if not os.path.exists(homeDir):
FNULL = open(os.devnull, 'w')
os.mkdir(homeDir)
command = "chown -R " + virtualHostUser + ":" + virtualHostUser + " " + homeDir
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
statusFile = open(tempStatusPath, 'w')
statusFile.writelines(str(msg) + " [404]")
statusFile.close()
return 0

View File

@@ -24,6 +24,7 @@ from plogical.mailUtilities import mailUtilities
import CyberCPLogFileWriter as logging
from dnsUtilities import DNS
from vhost import vhost
from applicationInstaller import ApplicationInstaller
## If you want justice, you have come to the wrong place.
@@ -383,173 +384,28 @@ class virtualHostUtilities:
@staticmethod
def installJoomla(domainName, finalPath, virtualHostUser, dbName, dbUser, dbPassword, username, password, prefix,
sitename):
sitename, tempStatusPath):
try:
FNULL = open(os.devnull, 'w')
if not os.path.exists(finalPath):
os.makedirs(finalPath)
extraArgs = {}
extraArgs['domainName'] = domainName
extraArgs['finalPath'] = finalPath
extraArgs['virtualHostUser'] = virtualHostUser
extraArgs['dbName'] = dbName
extraArgs['dbUser'] = dbUser
extraArgs['dbPassword'] = dbPassword
extraArgs['username'] = username
extraArgs['password'] = password
extraArgs['prefix'] = prefix
extraArgs['sitename'] = sitename
extraArgs['tempStatusPath'] = tempStatusPath
## checking for directories/files
background = ApplicationInstaller('joomla', extraArgs)
background.start()
dirFiles = os.listdir(finalPath)
if len(dirFiles) == 1:
if dirFiles[0] == ".well-known":
pass
else:
print "0,Target directory should be empty before installation, otherwise data loss could occur."
return
elif len(dirFiles) == 0:
pass
else:
print "0,Target directory should be empty before installation, otherwise data loss could occur."
return
## Get Joomla
os.chdir(finalPath)
if not os.path.exists("staging.zip"):
command = 'wget --no-check-certificate https://github.com/joomla/joomla-cms/archive/staging.zip -P ' + finalPath
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
else:
print "0,File already exists"
return
command = 'unzip ' + finalPath + 'staging.zip -d ' + finalPath
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
os.remove(finalPath + 'staging.zip')
command = 'cp -r ' + finalPath + 'joomla-cms-staging/. ' + finalPath
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
shutil.rmtree(finalPath + "joomla-cms-staging")
os.rename(finalPath + "installation/configuration.php-dist", finalPath + "configuration.php")
os.rename(finalPath + "robots.txt.dist", finalPath + "robots.txt")
os.rename(finalPath + "htaccess.txt", finalPath + ".htaccess")
## edit config file
configfile = finalPath + "configuration.php"
data = open(configfile, "r").readlines()
writeDataToFile = open(configfile, "w")
secret = randomPassword.generate_pass()
defDBName = " public $user = '" + dbName + "';" + "\n"
defDBUser = " public $db = '" + dbUser + "';" + "\n"
defDBPassword = " public $password = '" + dbPassword + "';" + "\n"
secretKey = " public $secret = '" + secret + "';" + "\n"
logPath = " public $log_path = '" + finalPath + "administrator/logs';" + "\n"
tmpPath = " public $tmp_path = '" + finalPath + "administrator/tmp';" + "\n"
dbprefix = " public $dbprefix = '" + prefix + "';" + "\n"
sitename = " public $sitename = '" + sitename + "';" + "\n"
for items in data:
if items.find("public $user ") > -1:
writeDataToFile.writelines(defDBUser)
elif items.find("public $password ") > -1:
writeDataToFile.writelines(defDBPassword)
elif items.find("public $db ") > -1:
writeDataToFile.writelines(defDBName)
elif items.find("public $log_path ") > -1:
writeDataToFile.writelines(logPath)
elif items.find("public $tmp_path ") > -1:
writeDataToFile.writelines(tmpPath)
elif items.find("public $secret ") > -1:
writeDataToFile.writelines(secretKey)
elif items.find("public $dbprefix ") > -1:
writeDataToFile.writelines(dbprefix)
elif items.find("public $sitename ") > -1:
writeDataToFile.writelines(sitename)
elif items.find("/*") > -1:
pass
elif items.find(" *") > -1:
pass
else:
writeDataToFile.writelines(items)
writeDataToFile.close()
# Rename SQL db prefix
f1 = open(finalPath + 'installation/sql/mysql/joomla.sql', 'r')
f2 = open('installation/sql/mysql/joomlaInstall.sql', 'w')
for line in f1:
f2.write(line.replace('#__', prefix))
f1.close()
f2.close()
# Restore SQL
proc = subprocess.Popen(["mysql", "--user=%s" % dbUser, "--password=%s" % dbPassword, dbName],
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
usercreation = """INSERT INTO `%susers`
(`name`, `username`, `password`, `params`)
VALUES ('Administrator', '%s',
'%s', '');
INSERT INTO `%suser_usergroup_map` (`user_id`,`group_id`)
VALUES (LAST_INSERT_ID(),'8');""" % (prefix, username, password, prefix)
out, err = proc.communicate(
file(finalPath + 'installation/sql/mysql/joomlaInstall.sql').read() + "\n" + usercreation)
shutil.rmtree(finalPath + "installation")
htaccessCache = """
<IfModule LiteSpeed>
RewriteEngine on
CacheLookup on
CacheDisable public /
RewriteCond %{REQUEST_METHOD} ^HEAD|GET$
RewriteCond %{ORG_REQ_URI} !/administrator
RewriteRule .* - [E=cache-control:max-age=120]
</IfModule>
"""
f = open(finalPath + '.htaccess', "a+")
f.write(htaccessCache)
f.close()
command = "chown -R " + virtualHostUser + ":" + virtualHostUser + " " + "/home/" + domainName + "/public_html/"
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
vhost.addRewriteRules(domainName)
installUtilities.installUtilities.reStartLiteSpeed()
print "1,None"
return
except BaseException, msg:
# remove the downloaded files
try:
shutil.rmtree(finalPath)
except:
logging.CyberCPLogFileWriter.writeToFile("shutil.rmtree(finalPath)")
homeDir = "/home/" + domainName + "/public_html"
if not os.path.exists(homeDir):
FNULL = open(os.devnull, 'w')
os.mkdir(homeDir)
command = "chown -R " + virtualHostUser + ":" + virtualHostUser + " " + homeDir
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
return
logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [installJoomla]')
@staticmethod
def issueSSLForHostName(virtualHost, path):
@@ -1139,6 +995,8 @@ def main():
parser.add_argument('--openBasedirValue', help='open_base dir protection value!')
parser.add_argument('--tempStatusPath', help='Temporary Status file path.')
args = parser.parse_args()
@@ -1186,7 +1044,7 @@ def main():
elif args.function == "installWordPress":
virtualHostUtilities.installWordPress(args.virtualHostName,args.path,args.virtualHostUser,args.dbName,args.dbUser,args.dbPassword)
elif args.function == "installJoomla":
virtualHostUtilities.installJoomla(args.virtualHostName,args.path,args.virtualHostUser,args.dbName,args.dbUser,args.dbPassword,args.username,args.password,args.prefix,args.sitename)
virtualHostUtilities.installJoomla(args.virtualHostName,args.path,args.virtualHostUser,args.dbName,args.dbUser,args.dbPassword,args.username,args.password,args.prefix,args.sitename, args.tempStatusPath)
elif args.function == "issueSSLForHostName":
virtualHostUtilities.issueSSLForHostName(args.virtualHostName,args.path)
elif args.function == "issueSSLForMailServer":

View File

@@ -457,6 +457,7 @@ app.controller('websitePages', function($scope,$http) {
$scope.fileManagerURL = "/filemanager/"+$("#domainNamePage").text();
$scope.wordPressInstallURL = $("#domainNamePage").text() + "/wordpressInstall";
$scope.joomlaInstallURL = $("#domainNamePage").text() + "/joomlaInstall";
$scope.domainAliasURL = "/websites/"+$("#domainNamePage").text()+"/domainAlias";
$scope.previewUrl = "/preview/"+$("#domainNamePage").text()+"/";
@@ -3870,9 +3871,6 @@ app.controller('installWordPressCTRL', function($scope, $http, $timeout) {
$("#installProgress").css("width", "0%");
};
$scope.installWordPress = function(){
$scope.installationDetailsForm = true;
@@ -4036,28 +4034,148 @@ app.controller('installWordPressCTRL', function($scope, $http, $timeout) {
}
});
app.controller('installJoomlaCTRL', 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 = 'jm_'
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.installJoomla = function(){
$scope.installationDetailsFormJoomla = false;
$scope.applicationInstallerLoading = false;
$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..";
var domain = $("#domainNamePage").text();
var path = $scope.installPath;
var sitename = $scope.sitename
var username = $scope.username
var password = $scope.password
var prefix = $scope.prefix
path = $scope.installPath;
url = "/websites/installJoomla";
var home = "1";
if (typeof path != 'undefined'){
if (typeof path !== 'undefined'){
home = "0";
}
@@ -4066,10 +4184,10 @@ app.controller('installWordPressCTRL', function($scope, $http, $timeout) {
domain: domain,
home:home,
path:path,
sitename:sitename,
username:username,
password:password,
prefix:prefix,
sitename: $scope.blogTitle,
username: $scope.adminUser,
password: $scope.adminPassword,
prefix: $scope.databasePrefix
};
var config = {
@@ -4083,29 +4201,20 @@ app.controller('installWordPressCTRL', function($scope, $http, $timeout) {
function ListInitialDatas(response) {
if (response.data.installStatus == 1)
if (response.data.installStatus === 1)
{
if (typeof path != 'undefined'){
$scope.installationURL = "http://"+domain+"/"+path;
}
else{
$scope.installationURL = domain;
}
$scope.installationDetailsFormJoomla = false;
$scope.applicationInstallerLoading = true;
$scope.installationFailed = true;
$scope.installationSuccessfull = false;
$scope.couldNotConnect = true;
statusFile = response.data.tempStatusPath;
getInstallStatus();
}
else{
$scope.installationDetailsFormJoomla = false;
$scope.applicationInstallerLoading = true;
$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;
@@ -4115,11 +4224,7 @@ app.controller('installWordPressCTRL', function($scope, $http, $timeout) {
}
function cantLoadInitialDatas(response) {
$scope.installationDetailsFormJoomla = false;
$scope.applicationInstallerLoading = true;
$scope.installationFailed = true;
$scope.installationSuccessfull = true;
$scope.couldNotConnect = false;
}

View File

@@ -457,6 +457,7 @@ app.controller('websitePages', function($scope,$http) {
$scope.fileManagerURL = "/filemanager/"+$("#domainNamePage").text();
$scope.wordPressInstallURL = $("#domainNamePage").text() + "/wordpressInstall";
$scope.joomlaInstallURL = $("#domainNamePage").text() + "/joomlaInstall";
$scope.domainAliasURL = "/websites/"+$("#domainNamePage").text()+"/domainAlias";
$scope.previewUrl = "/preview/"+$("#domainNamePage").text()+"/";
@@ -3870,9 +3871,6 @@ app.controller('installWordPressCTRL', function($scope, $http, $timeout) {
$("#installProgress").css("width", "0%");
};
$scope.installWordPress = function(){
$scope.installationDetailsForm = true;
@@ -4036,28 +4034,148 @@ app.controller('installWordPressCTRL', function($scope, $http, $timeout) {
}
});
app.controller('installJoomlaCTRL', 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 = 'jm_'
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.installJoomla = function(){
$scope.installationDetailsFormJoomla = false;
$scope.applicationInstallerLoading = false;
$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..";
var domain = $("#domainNamePage").text();
var path = $scope.installPath;
var sitename = $scope.sitename
var username = $scope.username
var password = $scope.password
var prefix = $scope.prefix
path = $scope.installPath;
url = "/websites/installJoomla";
var home = "1";
if (typeof path != 'undefined'){
if (typeof path !== 'undefined'){
home = "0";
}
@@ -4066,10 +4184,10 @@ app.controller('installWordPressCTRL', function($scope, $http, $timeout) {
domain: domain,
home:home,
path:path,
sitename:sitename,
username:username,
password:password,
prefix:prefix,
sitename: $scope.blogTitle,
username: $scope.adminUser,
password: $scope.adminPassword,
prefix: $scope.databasePrefix
};
var config = {
@@ -4083,29 +4201,20 @@ app.controller('installWordPressCTRL', function($scope, $http, $timeout) {
function ListInitialDatas(response) {
if (response.data.installStatus == 1)
if (response.data.installStatus === 1)
{
if (typeof path != 'undefined'){
$scope.installationURL = "http://"+domain+"/"+path;
}
else{
$scope.installationURL = domain;
}
$scope.installationDetailsFormJoomla = false;
$scope.applicationInstallerLoading = true;
$scope.installationFailed = true;
$scope.installationSuccessfull = false;
$scope.couldNotConnect = true;
statusFile = response.data.tempStatusPath;
getInstallStatus();
}
else{
$scope.installationDetailsFormJoomla = false;
$scope.applicationInstallerLoading = true;
$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;
@@ -4115,11 +4224,7 @@ app.controller('installWordPressCTRL', function($scope, $http, $timeout) {
}
function cantLoadInitialDatas(response) {
$scope.installationDetailsFormJoomla = false;
$scope.applicationInstallerLoading = true;
$scope.installationFailed = true;
$scope.installationSuccessfull = true;
$scope.couldNotConnect = false;
}

View File

@@ -0,0 +1,127 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "Install Joomla - 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 Joomla" %}</h2>
<p>{% trans "One-click Joomla Install!" %}</p>
</div>
<div ng-controller="installJoomlaCTRL" 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 "Site Name" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="blogTitle" required>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Login User" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="adminUser" required>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Login Password" %}</label>
<div class="col-sm-6">
<input type="password" class="form-control" ng-model="adminPassword" required>
</div>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "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="installJoomla()" class="btn btn-primary btn-lg btn-block">{% trans "Install Now" %}</button>
</div>
</div>
<div ng-hide="installationProgress" class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-7">
<div class="alert alert-success text-center">
<h2>{$ currentStatus $}</h2>
</div>
<div class="progress">
<div id="installProgress" class="progress-bar" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:0%">
<span class="sr-only">70% Complete</span>
</div>
</div>
<div ng-hide="installationFailed" class="alert alert-danger">
<p>{% trans "Installation failed. Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="installationSuccessfull" class="alert alert-success">
<p>{% trans "Installation successful. Visit:" %} {$ installationURL $}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
</div>
</div>
<div ng-hide="installationProgress" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-disabled="goBackDisable" ng-click="goBack()" class="btn btn-primary btn-lg btn-block">{% trans "Go Back" %}</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -952,10 +952,10 @@
<div class="col-md-4" style="margin-bottom: 2%;">
<a ng-click="installationDetailsJoomla()" href="" 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' %}">
</a>
<a ng-click="installationDetailsJoomla()" href="" 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>
</a>

View File

@@ -28,10 +28,6 @@ urlpatterns = [
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)$', views.domain, name='domain'),
url(r'^getDataFromLogFile', views.getDataFromLogFile, name='getDataFromLogFile'),
url(r'^fetchErrorLogs', views.fetchErrorLogs, name='fetchErrorLogs'),
url(r'^installWordpress$', views.installWordpress, name='installWordpress'),
url(r'^installJoomla', views.installJoomla, name='installJoomla'),
url(r'^getDataFromConfigFile', views.getDataFromConfigFile, name='getDataFromConfigFile'),
@@ -79,7 +75,18 @@ urlpatterns = [
## Application Installer
url(r'^applicationInstaller$',views.applicationInstaller,name="applicationInstaller"),
## WP Install
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/wordpressInstall$', views.wordpressInstall, name='wordpressInstall'),
url(r'^installWordpressStatus$',views.installWordpressStatus,name="installWordpressStatus"),
url(r'^installWordpress$', views.installWordpress, name='installWordpress'),
## Joomla Install
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'),
]

View File

@@ -18,14 +18,12 @@ import plogical.randomPassword as randomPassword
import subprocess
import shlex
from databases.models import Databases
from dns.models import Domains,Records
import requests
import re
from random import randint
import hashlib
from xml.etree import ElementTree
from plogical.mailUtilities import mailUtilities
from plogical.applicationInstaller import ApplicationInstaller
import time
# Create your views here.
@@ -1062,139 +1060,6 @@ def fetchErrorLogs(request):
final_json = json.dumps({'logstatus': 0, 'error_message': str(msg)})
return HttpResponse(final_json)
def installJoomla(request):
try:
val = request.session['userID']
if request.method == 'POST':
try:
data = json.loads(request.body)
domainName = data['domain']
home = data['home']
sitename = data['sitename']
username = data['username']
password = data['password']
prefix = data['prefix']
mailUtilities.checkHome()
finalPath = ""
if home == '0':
path = data['path']
finalPath = "/home/" + domainName + "/public_html/" + path + "/"
else:
finalPath = "/home/" + domainName + "/public_html/"
if finalPath.find("..") > -1:
data_ret = {'installStatus': 0,
'error_message': "Specified path must be inside virtual host home!"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
admin = Administrator.objects.get(pk=val)
try:
website = ChildDomains.objects.get(domain=domainName)
externalApp = website.master.externalApp
if admin.type != 1:
if website.master.admin != admin:
data_ret = {'installStatus': 0,
'error_message': "You do not own this website!"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except:
website = Websites.objects.get(domain=domainName)
externalApp = website.externalApp
if admin.type != 1:
if website.admin != admin:
data_ret = {'installStatus': 0,
'error_message': "You do not own this website!"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
## DB Creation
dbName = randomPassword.generate_pass()
dbUser = dbName
dbPassword = randomPassword.generate_pass()
## DB Creation
if website.package.dataBases > website.databases_set.all().count():
pass
else:
data_ret = {'installStatus': 0, 'error_message': "0,Maximum database limit reached for this website."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
if Databases.objects.filter(dbName=dbName).exists() or Databases.objects.filter(
dbUser=dbUser).exists():
data_ret = {'installStatus': 0,
'error_message': "0,This database or user is already taken."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
result = mysqlUtilities.createDatabase(dbName, dbUser, dbPassword)
if result == 1:
pass
else:
data_ret = {'installStatus': 0,
'error_message': "0,Not able to create database."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
db = Databases(website=website, dbName=dbName, dbUser=dbUser)
db.save()
## Installation
salt = randomPassword.generate_pass(32)
#return salt
password_hash = hashlib.md5(password + salt).hexdigest()
password = password_hash + ":" + salt
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
execPath = execPath + " installJoomla --virtualHostName " + domainName + " --virtualHostUser " + externalApp + " --path " + finalPath + " --dbName " + dbName + " --dbUser " + dbUser + " --dbPassword " + dbPassword + " --username " + username + " --password " + password +" --prefix " + prefix +" --sitename '" + sitename + "'"
#return execPath
output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {"installStatus": 1}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
mysqlUtilities.deleteDatabase(dbName,dbUser)
db = Databases.objects.get(dbName=dbName)
db.delete()
data_ret = {'installStatus': 0, 'error_message': output}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
## Installation ends
except BaseException, msg:
data_ret = {'installStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except KeyError, msg:
status = {"installStatus":0,"error":str(msg)}
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installJoomla]")
return HttpResponse("Not Logged in as admin")
def getDataFromConfigFile(request):
try:
val = request.session['userID']
@@ -2400,6 +2265,8 @@ def installWordpress(request):
background = ApplicationInstaller('wordpress', 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)
@@ -2464,4 +2331,174 @@ def installWordpressStatus(request):
except KeyError, msg:
data_ret = {'abort': 1, 'installStatus': 0, 'installationProgress': "0", 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
return HttpResponse(json_data)
def joomlaInstall(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/installJoomla.html', {'domainName' : domain})
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
return HttpResponse(str(msg))
except KeyError:
return redirect(loadLoginPage)
def installJoomla(request):
try:
val = request.session['userID']
if request.method == 'POST':
try:
data = json.loads(request.body)
domainName = data['domain']
home = data['home']
sitename = data['sitename']
username = data['username']
password = data['password']
prefix = data['prefix']
mailUtilities.checkHome()
tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999))
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Setting up paths,0')
statusFile.close()
finalPath = ""
if home == '0':
path = data['path']
finalPath = "/home/" + domainName + "/public_html/" + path + "/"
else:
finalPath = "/home/" + domainName + "/public_html/"
if finalPath.find("..") > -1:
data_ret = {'installStatus': 0,
'error_message': "Specified path must be inside virtual host home!"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
##
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Creating database..,10')
statusFile.close()
admin = Administrator.objects.get(pk=val)
try:
website = ChildDomains.objects.get(domain=domainName)
externalApp = website.master.externalApp
if admin.type != 1:
if website.master.admin != admin:
data_ret = {'installStatus': 0,
'error_message': "You do not own this website!"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except:
website = Websites.objects.get(domain=domainName)
externalApp = website.externalApp
if admin.type != 1:
if website.admin != admin:
data_ret = {'installStatus': 0,
'error_message': "You do not own this website!"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
## DB Creation
dbName = randomPassword.generate_pass()
dbUser = dbName
dbPassword = randomPassword.generate_pass()
## DB Creation
if website.package.dataBases > website.databases_set.all().count():
pass
else:
data_ret = {'installStatus': 0, 'error_message': "0,Maximum database limit reached for this website."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
if Databases.objects.filter(dbName=dbName).exists() or Databases.objects.filter(
dbUser=dbUser).exists():
data_ret = {'installStatus': 0,
'error_message': "0,This database or user is already taken."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
result = mysqlUtilities.createDatabase(dbName, dbUser, dbPassword)
if result == 1:
pass
else:
data_ret = {'installStatus': 0,
'error_message': "0,Not able to create database."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
db = Databases(website=website, dbName=dbName, dbUser=dbUser)
db.save()
## Installation
salt = randomPassword.generate_pass(32)
#return salt
password_hash = hashlib.md5(password + salt).hexdigest()
password = password_hash + ":" + salt
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Downloading Joomla Core..,20')
statusFile.close()
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
execPath = execPath + " installJoomla --virtualHostName " + domainName + \
" --virtualHostUser " + externalApp + " --path " + finalPath + " --dbName " + dbName + \
" --dbUser " + dbUser + " --dbPassword " + dbPassword + " --username " + username + \
" --password " + password +" --prefix " + prefix + " --sitename '" + sitename + "'" \
+ " --tempStatusPath " + tempStatusPath
#return execPath
output = subprocess.Popen(shlex.split(execPath))
data_ret = {"installStatus": 1, 'tempStatusPath': 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")