2019-12-10 23:04:24 +05:00
|
|
|
#!/usr/local/CyberCP/bin/python
|
2020-12-22 12:12:41 +05:00
|
|
|
import argparse
|
2019-11-07 09:37:06 +05:00
|
|
|
import os, sys
|
|
|
|
|
|
2018-07-13 04:26:40 +05:00
|
|
|
sys.path.append('/usr/local/CyberCP')
|
|
|
|
|
import django
|
2019-11-07 09:37:06 +05:00
|
|
|
|
2018-07-13 04:26:40 +05:00
|
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
|
|
|
|
django.setup()
|
|
|
|
|
import threading as multi
|
|
|
|
|
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
|
|
|
|
import subprocess
|
|
|
|
|
from websiteFunctions.models import ChildDomains, Websites
|
2019-12-15 13:30:40 +05:00
|
|
|
from plogical import randomPassword
|
|
|
|
|
from plogical.mysqlUtilities import mysqlUtilities
|
2018-07-13 04:26:40 +05:00
|
|
|
from databases.models import Databases
|
2019-12-15 13:30:40 +05:00
|
|
|
from plogical.installUtilities import installUtilities
|
2019-03-26 16:19:03 +05:00
|
|
|
from plogical.processUtilities import ProcessUtilities
|
2020-08-25 15:49:52 +05:00
|
|
|
from random import randint
|
2020-10-08 12:18:51 +05:00
|
|
|
import hashlib
|
2018-07-13 04:26:40 +05:00
|
|
|
|
|
|
|
|
class ApplicationInstaller(multi.Thread):
|
|
|
|
|
|
2020-07-16 01:23:23 +05:00
|
|
|
LOCALHOST = 'localhost'
|
2021-03-04 21:04:32 +05:00
|
|
|
REMOTE = 0
|
|
|
|
|
PORT = '3306'
|
2022-01-29 13:38:08 +05:00
|
|
|
MauticVersion = '4.1.2'
|
2020-07-16 01:23:23 +05:00
|
|
|
|
2018-07-13 04:26:40 +05:00
|
|
|
def __init__(self, installApp, extraArgs):
|
|
|
|
|
multi.Thread.__init__(self)
|
|
|
|
|
self.installApp = installApp
|
|
|
|
|
self.extraArgs = extraArgs
|
2020-01-07 12:41:32 +05:00
|
|
|
if extraArgs != None:
|
2020-02-14 23:30:49 +05:00
|
|
|
try:
|
|
|
|
|
self.tempStatusPath = self.extraArgs['tempStatusPath']
|
|
|
|
|
except:
|
|
|
|
|
pass
|
2018-07-13 04:26:40 +05:00
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
try:
|
2020-05-04 13:36:27 +05:00
|
|
|
|
2018-07-13 04:26:40 +05:00
|
|
|
if self.installApp == 'wordpress':
|
|
|
|
|
self.installWordPress()
|
2018-07-13 21:45:40 +05:00
|
|
|
elif self.installApp == 'joomla':
|
|
|
|
|
self.installJoomla()
|
2018-08-05 01:46:31 +05:00
|
|
|
elif self.installApp == 'prestashop':
|
|
|
|
|
self.installPrestaShop()
|
2019-11-07 09:37:06 +05:00
|
|
|
elif self.installApp == 'magento':
|
|
|
|
|
self.installMagento()
|
2019-12-23 17:02:34 +05:00
|
|
|
elif self.installApp == 'convertDomainToSite':
|
|
|
|
|
self.convertDomainToSite()
|
2020-05-04 13:36:27 +05:00
|
|
|
elif self.installApp == 'updatePackage':
|
|
|
|
|
self.updatePackage()
|
2020-08-25 15:49:52 +05:00
|
|
|
elif self.installApp == 'mautic':
|
|
|
|
|
self.installMautic()
|
2018-07-13 04:26:40 +05:00
|
|
|
|
2019-12-10 15:09:10 +05:00
|
|
|
except BaseException as msg:
|
2019-11-07 09:37:06 +05:00
|
|
|
logging.writeToFile(str(msg) + ' [ApplicationInstaller.run]')
|
2018-07-13 04:26:40 +05:00
|
|
|
|
2020-08-25 15:49:52 +05:00
|
|
|
def installMautic(self):
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
admin = self.extraArgs['admin']
|
|
|
|
|
domainName = self.extraArgs['domainName']
|
|
|
|
|
home = self.extraArgs['home']
|
|
|
|
|
tempStatusPath = self.extraArgs['tempStatusPath']
|
|
|
|
|
self.tempStatusPath = tempStatusPath
|
|
|
|
|
username = self.extraArgs['username']
|
|
|
|
|
password = self.extraArgs['password']
|
|
|
|
|
email = self.extraArgs['email']
|
|
|
|
|
|
|
|
|
|
FNULL = open(os.devnull, 'w')
|
|
|
|
|
|
|
|
|
|
## Open Status File
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Setting up paths,0')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
finalPath = ''
|
|
|
|
|
self.permPath = ''
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
website = ChildDomains.objects.get(domain=domainName)
|
|
|
|
|
externalApp = website.master.externalApp
|
|
|
|
|
self.masterDomain = website.master.domain
|
|
|
|
|
|
|
|
|
|
if home == '0':
|
|
|
|
|
path = self.extraArgs['path']
|
|
|
|
|
finalPath = website.path.rstrip('/') + "/" + path + "/"
|
|
|
|
|
else:
|
|
|
|
|
finalPath = website.path
|
|
|
|
|
|
|
|
|
|
if website.master.package.dataBases > website.master.databases_set.all().count():
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
raise BaseException("Maximum database limit reached for this website.")
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Setting up Database,20')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website.master)
|
|
|
|
|
self.permPath = website.path
|
|
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
website = Websites.objects.get(domain=domainName)
|
|
|
|
|
externalApp = website.externalApp
|
|
|
|
|
self.masterDomain = website.domain
|
|
|
|
|
|
|
|
|
|
if home == '0':
|
|
|
|
|
path = self.extraArgs['path']
|
|
|
|
|
finalPath = "/home/" + domainName + "/public_html/" + path + "/"
|
|
|
|
|
else:
|
|
|
|
|
finalPath = "/home/" + domainName + "/public_html/"
|
|
|
|
|
|
|
|
|
|
if website.package.dataBases > website.databases_set.all().count():
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
raise BaseException("Maximum database limit reached for this website.")
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Setting up Database,20')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website)
|
|
|
|
|
self.permPath = '/home/%s/public_html' % (website.domain)
|
|
|
|
|
|
|
|
|
|
## Security Check
|
|
|
|
|
|
|
|
|
|
command = 'chmod 755 %s' % (self.permPath)
|
|
|
|
|
ProcessUtilities.executioner(command)
|
|
|
|
|
|
|
|
|
|
if finalPath.find("..") > -1:
|
|
|
|
|
raise BaseException("Specified path must be inside virtual host home.")
|
|
|
|
|
|
|
|
|
|
if not os.path.exists(finalPath):
|
|
|
|
|
command = 'mkdir -p ' + finalPath
|
|
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
## checking for directories/files
|
|
|
|
|
|
|
|
|
|
if self.dataLossCheck(finalPath, tempStatusPath) == 0:
|
|
|
|
|
raise BaseException('Directory is not empty.')
|
|
|
|
|
|
|
|
|
|
####
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Downloading Mautic Core,30')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
2022-01-29 13:38:08 +05:00
|
|
|
command = "wget https://github.com/mautic/mautic/releases/download/%s/%s.zip" % (ApplicationInstaller.MauticVersion, ApplicationInstaller.MauticVersion)
|
2020-08-25 15:49:52 +05:00
|
|
|
ProcessUtilities.outputExecutioner(command, externalApp, None, finalPath)
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Extracting Mautic Core,50')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
2022-01-29 13:38:08 +05:00
|
|
|
command = "unzip %s.zip" % (ApplicationInstaller.MauticVersion)
|
2020-08-25 15:49:52 +05:00
|
|
|
ProcessUtilities.outputExecutioner(command, externalApp, None, finalPath)
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Running Mautic installer,70')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
if home == '0':
|
|
|
|
|
path = self.extraArgs['path']
|
|
|
|
|
finalURL = domainName + '/' + path
|
|
|
|
|
else:
|
|
|
|
|
finalURL = domainName
|
|
|
|
|
|
|
|
|
|
localDB = "/home/cyberpanel/" + str(randint(1000, 9999))
|
|
|
|
|
|
|
|
|
|
localDBContent = """<?php
|
|
|
|
|
// Example local.php to test install (to adapt of course)
|
|
|
|
|
$parameters = array(
|
|
|
|
|
// Do not set db_driver and mailer_from_name as they are used to assume Mautic is installed
|
|
|
|
|
'db_host' => 'localhost',
|
|
|
|
|
'db_table_prefix' => null,
|
|
|
|
|
'db_port' => 3306,
|
|
|
|
|
'db_name' => '%s',
|
|
|
|
|
'db_user' => '%s',
|
|
|
|
|
'db_password' => '%s',
|
|
|
|
|
'db_backup_tables' => true,
|
|
|
|
|
'db_backup_prefix' => 'bak_',
|
|
|
|
|
'admin_email' => '%s',
|
|
|
|
|
'admin_password' => '%s',
|
|
|
|
|
'mailer_transport' => null,
|
|
|
|
|
'mailer_host' => null,
|
|
|
|
|
'mailer_port' => null,
|
|
|
|
|
'mailer_user' => null,
|
|
|
|
|
'mailer_password' => null,
|
|
|
|
|
'mailer_api_key' => null,
|
|
|
|
|
'mailer_encryption' => null,
|
|
|
|
|
'mailer_auth_mode' => null,
|
|
|
|
|
);""" % (dbName, dbUser, dbPassword, email, password)
|
|
|
|
|
|
|
|
|
|
writeToFile = open(localDB, 'w')
|
|
|
|
|
writeToFile.write(localDBContent)
|
|
|
|
|
writeToFile.close()
|
|
|
|
|
|
|
|
|
|
command = 'rm -rf %s/app/config/local.php' % (finalPath)
|
|
|
|
|
ProcessUtilities.executioner(command)
|
|
|
|
|
|
|
|
|
|
command = 'mv %s %s/app/config/local.php' % (localDB, finalPath)
|
|
|
|
|
ProcessUtilities.executioner(command)
|
|
|
|
|
|
2022-01-29 13:38:08 +05:00
|
|
|
command = "/usr/local/lsws/lsphp74/bin/php bin/console mautic:install http://%s -f" % (finalURL)
|
2020-08-25 15:49:52 +05:00
|
|
|
result = ProcessUtilities.outputExecutioner(command, 'root', None, finalPath)
|
|
|
|
|
|
|
|
|
|
if result.find('Install complete') == -1:
|
|
|
|
|
raise BaseException(result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
from filemanager.filemanager import FileManager
|
|
|
|
|
|
|
|
|
|
fm = FileManager(None, None)
|
|
|
|
|
fm.fixPermissions(self.masterDomain)
|
|
|
|
|
|
|
|
|
|
installUtilities.reStartLiteSpeedSocket()
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines("Successfully Installed. [200]")
|
|
|
|
|
statusFile.close()
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except BaseException as msg:
|
|
|
|
|
# remove the downloaded files
|
|
|
|
|
FNULL = open(os.devnull, 'w')
|
|
|
|
|
|
|
|
|
|
homeDir = "/home/" + domainName + "/public_html"
|
|
|
|
|
|
|
|
|
|
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
|
|
|
|
groupName = 'nobody'
|
|
|
|
|
else:
|
|
|
|
|
groupName = 'nogroup'
|
|
|
|
|
|
|
|
|
|
if not os.path.exists(homeDir):
|
|
|
|
|
command = "chown " + externalApp + ":" + groupName + " " + homeDir
|
|
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
mysqlUtilities.deleteDatabase(dbName, dbUser)
|
|
|
|
|
db = Databases.objects.get(dbName=dbName)
|
|
|
|
|
db.delete()
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
command = 'chmod 750 %s' % (self.permPath)
|
|
|
|
|
ProcessUtilities.executioner(command)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
statusFile = open(self.tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines(str(msg) + " [404]")
|
|
|
|
|
statusFile.close()
|
|
|
|
|
return 0
|
|
|
|
|
|
2020-05-04 13:36:27 +05:00
|
|
|
def updatePackage(self):
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
package = self.extraArgs['package']
|
|
|
|
|
|
|
|
|
|
from serverStatus.serverStatusUtil import ServerStatusUtil
|
|
|
|
|
|
|
|
|
|
f = open(ServerStatusUtil.lswsInstallStatusPath, 'a')
|
|
|
|
|
|
2020-05-15 01:07:04 +05:00
|
|
|
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
2020-05-04 13:36:27 +05:00
|
|
|
|
2020-05-06 00:25:46 +05:00
|
|
|
if package == 'all':
|
2020-05-13 20:20:23 +05:00
|
|
|
command = 'DEBIAN_FRONTEND=noninteractive apt-get update -y'
|
2020-05-06 00:25:46 +05:00
|
|
|
f.write(ProcessUtilities.outputExecutioner(command))
|
2020-05-04 13:36:27 +05:00
|
|
|
|
2020-05-06 00:25:46 +05:00
|
|
|
f.flush()
|
|
|
|
|
|
|
|
|
|
command = 'apt-get upgrade -y'
|
|
|
|
|
f.write(ProcessUtilities.outputExecutioner(command))
|
|
|
|
|
else:
|
|
|
|
|
command = 'apt-get install --only-upgrade %s -y' % (package)
|
|
|
|
|
f.write(ProcessUtilities.outputExecutioner(command))
|
|
|
|
|
|
|
|
|
|
f.close()
|
2020-05-24 10:20:17 +01:00
|
|
|
elif ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
2020-05-06 15:30:26 +05:00
|
|
|
if package == 'all':
|
|
|
|
|
command = 'yum update -y'
|
|
|
|
|
f.write(ProcessUtilities.outputExecutioner(command))
|
|
|
|
|
else:
|
|
|
|
|
command = 'yum update %s -y' % (package)
|
|
|
|
|
f.write(ProcessUtilities.outputExecutioner(command))
|
2020-05-04 13:36:27 +05:00
|
|
|
|
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
|
|
logging.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
|
|
|
|
'Package(s) upgraded successfully. [200]',
|
|
|
|
|
1)
|
|
|
|
|
|
|
|
|
|
except BaseException as msg:
|
|
|
|
|
from serverStatus.serverStatusUtil import ServerStatusUtil
|
|
|
|
|
logging.statusWriter(ServerStatusUtil.lswsInstallStatusPath, 'Failed. Error: %s. [404]' % (str(msg)), 1)
|
|
|
|
|
return 0
|
|
|
|
|
|
2019-12-23 17:02:34 +05:00
|
|
|
def convertDomainToSite(self):
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
from websiteFunctions.website import WebsiteManager
|
|
|
|
|
import json, time
|
|
|
|
|
|
|
|
|
|
request = self.extraArgs['request']
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
statusFile = open(self.tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Deleting domain as child..,20')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
data = json.loads(request.body)
|
|
|
|
|
|
2020-02-13 20:21:12 +05:00
|
|
|
if data['package'] == None or data['domainName'] == None or data['adminEmail'] == None \
|
|
|
|
|
or data['phpSelection'] == None or data['websiteOwner'] == None:
|
|
|
|
|
raise BaseException('Please provide all values.')
|
|
|
|
|
|
2019-12-23 17:02:34 +05:00
|
|
|
domainName = data['domainName']
|
|
|
|
|
|
|
|
|
|
childDomain = ChildDomains.objects.get(domain=domainName)
|
|
|
|
|
path = childDomain.path
|
|
|
|
|
|
|
|
|
|
wm = WebsiteManager()
|
|
|
|
|
|
|
|
|
|
wm.submitDomainDeletion(request.session['userID'], {'websiteName': domainName})
|
|
|
|
|
time.sleep(5)
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
statusFile = open(self.tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Creating domain as website..,40')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
resp = wm.submitWebsiteCreation(request.session['userID'], data)
|
|
|
|
|
respData = json.loads(resp.content.decode('utf-8'))
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
respDataStatus = ProcessUtilities.outputExecutioner("cat " + respData['tempStatusPath'])
|
|
|
|
|
|
|
|
|
|
if respDataStatus.find('[200]') > -1:
|
|
|
|
|
break
|
|
|
|
|
elif respDataStatus.find('[404]') > -1:
|
|
|
|
|
statusFile = open(self.tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines(respDataStatus['currentStatus'] + ' [404]')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
return 0
|
|
|
|
|
else:
|
|
|
|
|
statusFile = open(self.tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines(respDataStatus)
|
|
|
|
|
statusFile.close()
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
statusFile = open(self.tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Moving data..,80')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
command = 'rm -rf /home/%s/public_html' % (domainName)
|
|
|
|
|
ProcessUtilities.executioner(command)
|
|
|
|
|
|
|
|
|
|
command = 'mv %s /home/%s/public_html' % (path, domainName)
|
|
|
|
|
ProcessUtilities.executioner(command)
|
|
|
|
|
|
2020-04-07 12:25:14 +05:00
|
|
|
from filemanager.filemanager import FileManager
|
2019-12-23 17:02:34 +05:00
|
|
|
|
2020-04-07 12:25:14 +05:00
|
|
|
fm = FileManager(None, None)
|
|
|
|
|
fm.fixPermissions(domainName)
|
2019-12-23 17:02:34 +05:00
|
|
|
|
|
|
|
|
statusFile = open(self.tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Successfully converted. [200]')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
except BaseException as msg:
|
|
|
|
|
statusFile = open(self.tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines(str(msg) + " [404]")
|
|
|
|
|
statusFile.close()
|
|
|
|
|
return 0
|
|
|
|
|
|
2018-07-13 04:26:40 +05:00
|
|
|
def installWPCLI(self):
|
|
|
|
|
try:
|
2021-01-12 19:16:15 -05:00
|
|
|
command = 'wget -O /usr/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar'
|
2019-03-26 16:19:03 +05:00
|
|
|
ProcessUtilities.executioner(command)
|
2018-07-13 04:26:40 +05:00
|
|
|
|
2021-01-12 19:16:15 -05:00
|
|
|
command = 'chmod +x /usr/bin/wp'
|
2019-03-26 16:19:03 +05:00
|
|
|
ProcessUtilities.executioner(command)
|
2018-07-13 04:26:40 +05:00
|
|
|
|
2019-12-10 15:09:10 +05:00
|
|
|
except BaseException as msg:
|
2019-11-07 09:37:06 +05:00
|
|
|
logging.writeToFile(str(msg) + ' [ApplicationInstaller.installWPCLI]')
|
2018-07-13 04:26:40 +05:00
|
|
|
|
2020-02-22 10:37:01 +05:00
|
|
|
def dataLossCheck(self, finalPath, tempStatusPath):
|
|
|
|
|
dirFiles = os.listdir(finalPath)
|
2018-11-10 16:05:40 +05:00
|
|
|
|
2020-02-22 10:37:01 +05:00
|
|
|
if len(dirFiles) <= 3:
|
2018-11-10 16:05:40 +05:00
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
|
2018-07-26 23:13:02 +05:00
|
|
|
def installGit(self):
|
2018-07-26 04:11:10 +05:00
|
|
|
try:
|
2018-11-08 12:11:42 +05:00
|
|
|
if os.path.exists("/etc/lsb-release"):
|
|
|
|
|
command = 'apt -y install git'
|
2019-03-26 16:19:03 +05:00
|
|
|
ProcessUtilities.executioner(command)
|
2018-11-08 12:11:42 +05:00
|
|
|
else:
|
|
|
|
|
|
2020-02-22 10:37:01 +05:00
|
|
|
command = 'yum install git -y'
|
2019-03-26 16:19:03 +05:00
|
|
|
ProcessUtilities.executioner(command)
|
2018-07-26 04:11:10 +05:00
|
|
|
|
2019-12-10 15:09:10 +05:00
|
|
|
except BaseException as msg:
|
2019-11-07 09:37:06 +05:00
|
|
|
logging.writeToFile(str(msg) + ' [ApplicationInstaller.installGit]')
|
2018-07-26 04:11:10 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
def dbCreation(self, tempStatusPath, website):
|
2020-07-16 01:23:23 +05:00
|
|
|
passFile = "/etc/cyberpanel/mysqlPassword"
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
import json
|
|
|
|
|
jsonData = json.loads(open(passFile, 'r').read())
|
|
|
|
|
mysqlhost = jsonData['mysqlhost']
|
|
|
|
|
ApplicationInstaller.LOCALHOST = mysqlhost
|
2021-03-04 21:04:32 +05:00
|
|
|
ApplicationInstaller.REMOTE = 1
|
|
|
|
|
ApplicationInstaller.PORT = jsonData['mysqlport']
|
2020-07-16 01:23:23 +05:00
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
try:
|
|
|
|
|
dbName = randomPassword.generate_pass()
|
|
|
|
|
dbUser = dbName
|
|
|
|
|
dbPassword = randomPassword.generate_pass()
|
|
|
|
|
|
|
|
|
|
## DB Creation
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
|
return dbName, dbUser, dbPassword
|
|
|
|
|
|
2019-12-10 15:09:10 +05:00
|
|
|
except BaseException as msg:
|
2018-08-21 13:10:40 +05:00
|
|
|
logging.writeToFile(str(msg) + '[ApplicationInstallerdbCreation]')
|
|
|
|
|
|
2018-07-13 04:26:40 +05:00
|
|
|
def installWordPress(self):
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
domainName = self.extraArgs['domainName']
|
|
|
|
|
home = self.extraArgs['home']
|
|
|
|
|
tempStatusPath = self.extraArgs['tempStatusPath']
|
2020-02-28 11:40:55 +05:00
|
|
|
self.tempStatusPath = tempStatusPath
|
2018-07-13 04:26:40 +05:00
|
|
|
blogTitle = self.extraArgs['blogTitle']
|
|
|
|
|
adminUser = self.extraArgs['adminUser']
|
|
|
|
|
adminPassword = self.extraArgs['adminPassword']
|
|
|
|
|
adminEmail = self.extraArgs['adminEmail']
|
|
|
|
|
|
2020-12-25 14:18:47 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
FNULL = open(os.devnull, 'w')
|
2018-07-13 04:26:40 +05:00
|
|
|
|
|
|
|
|
### Check WP CLI
|
|
|
|
|
|
|
|
|
|
try:
|
2020-02-21 14:05:53 +05:00
|
|
|
command = 'wp --info'
|
2019-04-01 15:19:54 +05:00
|
|
|
outout = ProcessUtilities.outputExecutioner(command)
|
2018-07-13 04:26:40 +05:00
|
|
|
|
2019-04-01 15:19:54 +05:00
|
|
|
if not outout.find('WP-CLI root dir:') > -1:
|
2018-07-13 04:26:40 +05:00
|
|
|
self.installWPCLI()
|
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
|
self.installWPCLI()
|
|
|
|
|
|
|
|
|
|
## Open Status File
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Setting up paths,0')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
finalPath = ''
|
2020-03-23 12:29:42 +05:00
|
|
|
self.permPath = ''
|
2018-08-21 13:10:40 +05:00
|
|
|
|
2018-07-13 04:26:40 +05:00
|
|
|
try:
|
|
|
|
|
website = ChildDomains.objects.get(domain=domainName)
|
|
|
|
|
externalApp = website.master.externalApp
|
2020-04-08 23:41:05 +05:00
|
|
|
self.masterDomain = website.master.domain
|
2018-07-13 04:26:40 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
if home == '0':
|
|
|
|
|
path = self.extraArgs['path']
|
|
|
|
|
finalPath = website.path.rstrip('/') + "/" + path + "/"
|
|
|
|
|
else:
|
|
|
|
|
finalPath = website.path
|
|
|
|
|
|
|
|
|
|
if website.master.package.dataBases > website.master.databases_set.all().count():
|
|
|
|
|
pass
|
|
|
|
|
else:
|
2020-02-22 11:22:40 +05:00
|
|
|
raise BaseException("Maximum database limit reached for this website.")
|
2018-08-21 13:10:40 +05:00
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Setting up Database,20')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website.master)
|
2020-04-06 12:33:20 +05:00
|
|
|
self.permPath = website.path
|
2020-12-25 14:18:47 +05:00
|
|
|
except BaseException as msg:
|
|
|
|
|
|
2018-07-13 04:26:40 +05:00
|
|
|
website = Websites.objects.get(domain=domainName)
|
|
|
|
|
externalApp = website.externalApp
|
2020-04-08 23:41:05 +05:00
|
|
|
self.masterDomain = website.domain
|
2018-07-13 04:26:40 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
if home == '0':
|
|
|
|
|
path = self.extraArgs['path']
|
|
|
|
|
finalPath = "/home/" + domainName + "/public_html/" + path + "/"
|
|
|
|
|
else:
|
|
|
|
|
finalPath = "/home/" + domainName + "/public_html/"
|
2018-07-13 04:26:40 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
if website.package.dataBases > website.databases_set.all().count():
|
|
|
|
|
pass
|
|
|
|
|
else:
|
2020-02-22 11:22:40 +05:00
|
|
|
raise BaseException("Maximum database limit reached for this website.")
|
2018-07-13 04:26:40 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Setting up Database,20')
|
|
|
|
|
statusFile.close()
|
2018-07-13 04:26:40 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website)
|
2020-03-23 12:29:42 +05:00
|
|
|
self.permPath = '/home/%s/public_html' % (website.domain)
|
2018-07-13 04:26:40 +05:00
|
|
|
|
2020-12-25 14:18:47 +05:00
|
|
|
|
2018-07-13 04:26:40 +05:00
|
|
|
## Security Check
|
|
|
|
|
|
2020-03-23 12:29:42 +05:00
|
|
|
command = 'chmod 755 %s' % (self.permPath)
|
2020-02-22 10:37:01 +05:00
|
|
|
ProcessUtilities.executioner(command)
|
|
|
|
|
|
2018-07-13 04:26:40 +05:00
|
|
|
if finalPath.find("..") > -1:
|
2020-02-22 11:22:40 +05:00
|
|
|
raise BaseException("Specified path must be inside virtual host home.")
|
2018-07-13 04:26:40 +05:00
|
|
|
|
|
|
|
|
if not os.path.exists(finalPath):
|
2019-11-24 12:14:18 +05:00
|
|
|
command = 'mkdir -p ' + finalPath
|
2019-07-16 23:23:16 +05:00
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
2018-07-13 04:26:40 +05:00
|
|
|
|
|
|
|
|
## checking for directories/files
|
|
|
|
|
|
2018-11-10 16:05:40 +05:00
|
|
|
if self.dataLossCheck(finalPath, tempStatusPath) == 0:
|
2020-02-22 10:37:01 +05:00
|
|
|
raise BaseException('Directory is not empty.')
|
2018-07-13 04:26:40 +05:00
|
|
|
|
|
|
|
|
####
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Downloading WordPress Core,30')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
2020-12-23 19:06:42 +05:00
|
|
|
try:
|
|
|
|
|
command = "wp core download --allow-root --path=%s --version=%s" % (finalPath, self.extraArgs['version'])
|
2020-12-25 14:18:47 +05:00
|
|
|
except:
|
2020-12-23 19:06:42 +05:00
|
|
|
command = "wp core download --allow-root --path=" + finalPath
|
|
|
|
|
|
2021-01-12 17:56:36 +05:00
|
|
|
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
|
|
|
|
|
2021-04-13 01:03:40 +05:00
|
|
|
if os.path.exists(ProcessUtilities.debugPath):
|
|
|
|
|
logging.writeToFile(str(result))
|
|
|
|
|
|
2021-01-12 17:56:36 +05:00
|
|
|
if result.find('Success:') == -1:
|
|
|
|
|
raise BaseException(result)
|
2018-07-13 04:26:40 +05:00
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Configuring the installation,40')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
2021-03-04 21:14:11 +05:00
|
|
|
command = "wp core config --dbname=" + dbName + " --dbuser=" + dbUser + " --dbpass=" + dbPassword + " --dbhost=%s:%s --dbprefix=wp_ --allow-root --path=" % (ApplicationInstaller.LOCALHOST, ApplicationInstaller.PORT) + finalPath
|
2021-01-12 17:56:36 +05:00
|
|
|
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
|
|
|
|
|
2021-04-13 01:03:40 +05:00
|
|
|
if os.path.exists(ProcessUtilities.debugPath):
|
|
|
|
|
logging.writeToFile(str(result))
|
|
|
|
|
|
2021-01-12 17:56:36 +05:00
|
|
|
if result.find('Success:') == -1:
|
|
|
|
|
raise BaseException(result)
|
2018-07-13 04:26:40 +05:00
|
|
|
|
|
|
|
|
if home == '0':
|
|
|
|
|
path = self.extraArgs['path']
|
|
|
|
|
finalURL = domainName + '/' + path
|
|
|
|
|
else:
|
|
|
|
|
finalURL = domainName
|
|
|
|
|
|
2019-11-24 12:14:18 +05:00
|
|
|
command = 'wp core install --url="http://' + finalURL + '" --title="' + blogTitle + '" --admin_user="' + adminUser + '" --admin_password="' + adminPassword + '" --admin_email="' + adminEmail + '" --allow-root --path=' + finalPath
|
2021-01-12 17:56:36 +05:00
|
|
|
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
|
|
|
|
|
2021-04-13 01:03:40 +05:00
|
|
|
if os.path.exists(ProcessUtilities.debugPath):
|
|
|
|
|
logging.writeToFile(str(result))
|
|
|
|
|
|
2021-01-12 17:56:36 +05:00
|
|
|
if result.find('Success:') == -1:
|
|
|
|
|
raise BaseException(result)
|
2018-07-13 04:26:40 +05:00
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Installing LSCache Plugin,80')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
2019-11-24 12:14:18 +05:00
|
|
|
command = "wp plugin install litespeed-cache --allow-root --path=" + finalPath
|
2021-01-12 17:56:36 +05:00
|
|
|
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
|
|
|
|
|
2021-04-13 01:03:40 +05:00
|
|
|
if os.path.exists(ProcessUtilities.debugPath):
|
|
|
|
|
logging.writeToFile(str(result))
|
|
|
|
|
|
2021-01-12 17:56:36 +05:00
|
|
|
if result.find('Success:') == -1:
|
|
|
|
|
raise BaseException(result)
|
2018-07-13 04:26:40 +05:00
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Activating LSCache Plugin,90')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
2019-11-24 12:14:18 +05:00
|
|
|
command = "wp plugin activate litespeed-cache --allow-root --path=" + finalPath
|
2021-01-12 17:56:36 +05:00
|
|
|
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
2018-07-13 04:26:40 +05:00
|
|
|
|
2021-04-13 01:03:40 +05:00
|
|
|
if os.path.exists(ProcessUtilities.debugPath):
|
|
|
|
|
logging.writeToFile(str(result))
|
|
|
|
|
|
2021-01-12 17:56:36 +05:00
|
|
|
if result.find('Success:') == -1:
|
|
|
|
|
raise BaseException(result)
|
2021-01-02 00:45:29 +05:00
|
|
|
|
2021-01-12 17:56:36 +05:00
|
|
|
try:
|
|
|
|
|
if self.extraArgs['updates']:
|
|
|
|
|
if self.extraArgs['updates'] == 'Disabled':
|
|
|
|
|
command = "wp config set WP_AUTO_UPDATE_CORE false --raw --allow-root --path=" + finalPath
|
|
|
|
|
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
if result.find('Success:') == -1:
|
|
|
|
|
raise BaseException(result)
|
|
|
|
|
elif self.extraArgs['updates'] == 'Minor and Security Updates':
|
|
|
|
|
command = "wp config set WP_AUTO_UPDATE_CORE minor --allow-root --path=" + finalPath
|
|
|
|
|
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
if result.find('Success:') == -1:
|
|
|
|
|
raise BaseException(result)
|
|
|
|
|
else:
|
|
|
|
|
command = "wp config set WP_AUTO_UPDATE_CORE true --raw --allow-root --path=" + finalPath
|
|
|
|
|
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
if result.find('Success:') == -1:
|
|
|
|
|
raise BaseException(result)
|
|
|
|
|
except:
|
|
|
|
|
pass
|
2021-01-02 00:45:29 +05:00
|
|
|
|
2021-02-02 12:49:08 +05:00
|
|
|
try:
|
|
|
|
|
if self.extraArgs['appsSet'] == 'WordPress + LSCache + Classic Editor':
|
|
|
|
|
|
|
|
|
|
command = "wp plugin install classic-editor --allow-root --path=" + finalPath
|
|
|
|
|
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
if result.find('Success:') == -1:
|
|
|
|
|
raise BaseException(result)
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Activating Classic Editor Plugin,90')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
command = "wp plugin activate classic-editor --allow-root --path=" + finalPath
|
|
|
|
|
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
if result.find('Success:') == -1:
|
|
|
|
|
raise BaseException(result)
|
|
|
|
|
|
|
|
|
|
elif self.extraArgs['appsSet'] == 'WordPress + LSCache + WooCommerce':
|
|
|
|
|
|
|
|
|
|
command = "wp plugin install woocommerce --allow-root --path=" + finalPath
|
|
|
|
|
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
if result.find('Success:') == -1:
|
|
|
|
|
raise BaseException(result)
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Activating WooCommerce Plugin,90')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
command = "wp plugin activate woocommerce --allow-root --path=" + finalPath
|
|
|
|
|
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
if result.find('Success:') == -1:
|
|
|
|
|
raise BaseException(result)
|
|
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
2020-12-25 14:18:47 +05:00
|
|
|
|
2018-07-13 04:26:40 +05:00
|
|
|
##
|
|
|
|
|
|
2021-09-23 19:30:42 +05:00
|
|
|
# from filemanager.filemanager import FileManager
|
|
|
|
|
#
|
|
|
|
|
# fm = FileManager(None, None)
|
|
|
|
|
# fm.fixPermissions(self.masterDomain)
|
2020-02-22 10:37:01 +05:00
|
|
|
|
2018-07-13 04:26:40 +05:00
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines("Successfully Installed. [200]")
|
|
|
|
|
statusFile.close()
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
2019-12-10 15:09:10 +05:00
|
|
|
except BaseException as msg:
|
2018-08-05 01:46:31 +05:00
|
|
|
# remove the downloaded files
|
2020-04-03 11:28:27 +05:00
|
|
|
|
2021-04-13 01:03:40 +05:00
|
|
|
if not os.path.exists(ProcessUtilities.debugPath):
|
|
|
|
|
from filemanager.filemanager import FileManager
|
|
|
|
|
fm = FileManager(None, None)
|
|
|
|
|
fm.fixPermissions(self.masterDomain)
|
2018-08-05 01:46:31 +05:00
|
|
|
|
2021-04-13 01:03:40 +05:00
|
|
|
try:
|
|
|
|
|
mysqlUtilities.deleteDatabase(dbName, dbUser)
|
|
|
|
|
db = Databases.objects.get(dbName=dbName)
|
|
|
|
|
db.delete()
|
|
|
|
|
except:
|
|
|
|
|
pass
|
2018-08-05 01:46:31 +05:00
|
|
|
|
2020-02-28 11:40:55 +05:00
|
|
|
statusFile = open(self.tempStatusPath, 'w')
|
2018-08-05 01:46:31 +05:00
|
|
|
statusFile.writelines(str(msg) + " [404]")
|
|
|
|
|
statusFile.close()
|
|
|
|
|
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']
|
2020-02-28 11:40:55 +05:00
|
|
|
self.tempStatusPath = tempStatusPath
|
2018-08-05 01:46:31 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
FNULL = open(os.devnull, 'w')
|
2018-08-05 01:46:31 +05:00
|
|
|
|
|
|
|
|
## Open Status File
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Setting up paths,0')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
finalPath = ''
|
2020-03-23 12:29:42 +05:00
|
|
|
self.permPath = ''
|
2018-08-21 13:10:40 +05:00
|
|
|
|
2018-08-05 01:46:31 +05:00
|
|
|
try:
|
|
|
|
|
website = ChildDomains.objects.get(domain=domainName)
|
|
|
|
|
externalApp = website.master.externalApp
|
2020-04-08 23:41:05 +05:00
|
|
|
self.masterDomain = website.master.domain
|
2018-08-05 01:46:31 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
if home == '0':
|
|
|
|
|
path = self.extraArgs['path']
|
|
|
|
|
finalPath = website.path.rstrip('/') + "/" + path + "/"
|
|
|
|
|
else:
|
|
|
|
|
finalPath = website.path + "/"
|
|
|
|
|
|
|
|
|
|
if website.master.package.dataBases > website.master.databases_set.all().count():
|
|
|
|
|
pass
|
|
|
|
|
else:
|
2020-02-22 11:22:40 +05:00
|
|
|
raise BaseException("Maximum database limit reached for this website.")
|
2018-08-21 13:10:40 +05:00
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Setting up Database,20')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website.master)
|
2020-04-06 12:33:20 +05:00
|
|
|
self.permPath = website.path
|
2018-08-05 01:46:31 +05:00
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
website = Websites.objects.get(domain=domainName)
|
|
|
|
|
externalApp = website.externalApp
|
2020-04-08 23:41:05 +05:00
|
|
|
self.masterDomain = website.domain
|
2018-08-05 01:46:31 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
if home == '0':
|
|
|
|
|
path = self.extraArgs['path']
|
|
|
|
|
finalPath = "/home/" + domainName + "/public_html/" + path + "/"
|
|
|
|
|
else:
|
|
|
|
|
finalPath = "/home/" + domainName + "/public_html/"
|
2018-08-05 01:46:31 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
if website.package.dataBases > website.databases_set.all().count():
|
|
|
|
|
pass
|
|
|
|
|
else:
|
2020-02-22 11:22:40 +05:00
|
|
|
raise BaseException("Maximum database limit reached for this website.")
|
2018-08-05 01:46:31 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Setting up Database,20')
|
|
|
|
|
statusFile.close()
|
2018-08-05 01:46:31 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website)
|
2020-03-23 12:29:42 +05:00
|
|
|
self.permPath = '/home/%s/public_html' % (website.domain)
|
2018-08-05 01:46:31 +05:00
|
|
|
|
|
|
|
|
## Security Check
|
|
|
|
|
|
2020-03-23 12:29:42 +05:00
|
|
|
command = 'chmod 755 %s' % (self.permPath)
|
2020-02-22 10:37:01 +05:00
|
|
|
ProcessUtilities.executioner(command)
|
|
|
|
|
|
2018-08-05 01:46:31 +05:00
|
|
|
if finalPath.find("..") > -1:
|
2020-02-22 10:37:01 +05:00
|
|
|
raise BaseException('Specified path must be inside virtual host home.')
|
2018-08-05 01:46:31 +05:00
|
|
|
|
|
|
|
|
if not os.path.exists(finalPath):
|
2020-02-22 10:37:01 +05:00
|
|
|
command = 'mkdir -p ' + finalPath
|
2019-07-16 23:23:16 +05:00
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
2018-08-05 01:46:31 +05:00
|
|
|
|
|
|
|
|
## checking for directories/files
|
|
|
|
|
|
2018-11-10 16:05:40 +05:00
|
|
|
if self.dataLossCheck(finalPath, tempStatusPath) == 0:
|
2020-02-22 10:37:01 +05:00
|
|
|
raise BaseException('Directory is not empty.')
|
2018-08-05 01:46:31 +05:00
|
|
|
|
|
|
|
|
####
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Downloading and extracting PrestaShop Core..,30')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
2020-02-22 11:22:40 +05:00
|
|
|
command = "wget https://download.prestashop.com/download/releases/prestashop_1.7.4.2.zip -P %s" % (
|
2019-11-07 09:37:06 +05:00
|
|
|
finalPath)
|
2019-07-16 23:23:16 +05:00
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
2018-08-05 01:46:31 +05:00
|
|
|
|
2020-02-22 11:22:40 +05:00
|
|
|
command = "unzip -o %sprestashop_1.7.4.2.zip -d " % (finalPath) + finalPath
|
2019-07-16 23:23:16 +05:00
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
2018-08-05 01:46:31 +05:00
|
|
|
|
2020-02-22 11:22:40 +05:00
|
|
|
command = "unzip -o %sprestashop.zip -d " % (finalPath) + finalPath
|
2019-07-16 23:23:16 +05:00
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
2018-08-05 01:46:31 +05:00
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Configuring the installation,40')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
if home == '0':
|
|
|
|
|
path = self.extraArgs['path']
|
2019-11-07 09:37:06 +05:00
|
|
|
# finalURL = domainName + '/' + path
|
2018-12-06 15:03:43 +05:00
|
|
|
finalURL = domainName
|
2018-08-05 01:46:31 +05:00
|
|
|
else:
|
|
|
|
|
finalURL = domainName
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Installing and configuring PrestaShop..,60')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
2020-02-22 10:37:01 +05:00
|
|
|
command = "php " + finalPath + "install/index_cli.php --domain=" + finalURL + \
|
2018-08-05 01:46:31 +05:00
|
|
|
" --db_server=localhost --db_name=" + dbName + " --db_user=" + dbUser + " --db_password=" + dbPassword \
|
|
|
|
|
+ " --name='" + shopName + "' --firstname=" + firstName + " --lastname=" + lastName + \
|
|
|
|
|
" --email=" + email + " --password=" + password
|
2019-07-16 23:23:16 +05:00
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
2018-08-05 01:46:31 +05:00
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
2020-02-21 17:36:09 +05:00
|
|
|
command = "rm -rf " + finalPath + "install"
|
2019-07-16 23:23:16 +05:00
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
2018-08-05 01:46:31 +05:00
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
2020-04-08 23:41:05 +05:00
|
|
|
from filemanager.filemanager import FileManager
|
2018-08-05 01:46:31 +05:00
|
|
|
|
2020-04-08 23:41:05 +05:00
|
|
|
fm = FileManager(None, None)
|
|
|
|
|
fm.fixPermissions(self.masterDomain)
|
2020-02-22 10:37:01 +05:00
|
|
|
|
2018-08-05 01:46:31 +05:00
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines("Successfully Installed. [200]")
|
|
|
|
|
statusFile.close()
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
2019-12-10 15:09:10 +05:00
|
|
|
except BaseException as msg:
|
2018-07-13 04:26:40 +05:00
|
|
|
# remove the downloaded files
|
|
|
|
|
|
|
|
|
|
homeDir = "/home/" + domainName + "/public_html"
|
|
|
|
|
|
2020-05-24 10:20:17 +01:00
|
|
|
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
2020-04-03 11:28:27 +05:00
|
|
|
groupName = 'nobody'
|
|
|
|
|
else:
|
|
|
|
|
groupName = 'nogroup'
|
|
|
|
|
|
2018-07-13 04:26:40 +05:00
|
|
|
if not os.path.exists(homeDir):
|
2020-04-03 11:28:27 +05:00
|
|
|
command = "chown -R " + externalApp + ":" + groupName + " " + homeDir
|
2019-07-16 23:23:16 +05:00
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
2018-07-13 04:26:40 +05:00
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
mysqlUtilities.deleteDatabase(dbName, dbUser)
|
|
|
|
|
db = Databases.objects.get(dbName=dbName)
|
|
|
|
|
db.delete()
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
2020-03-23 12:29:42 +05:00
|
|
|
command = 'chmod 750 %s' % (self.permPath)
|
2020-02-22 10:37:01 +05:00
|
|
|
ProcessUtilities.executioner(command)
|
|
|
|
|
|
2020-02-28 11:40:55 +05:00
|
|
|
statusFile = open(self.tempStatusPath, 'w')
|
2018-07-13 04:26:40 +05:00
|
|
|
statusFile.writelines(str(msg) + " [404]")
|
|
|
|
|
statusFile.close()
|
|
|
|
|
return 0
|
2018-07-13 21:45:40 +05:00
|
|
|
|
|
|
|
|
def installJoomla(self):
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
domainName = self.extraArgs['domain']
|
2018-07-13 21:45:40 +05:00
|
|
|
password = self.extraArgs['password']
|
|
|
|
|
prefix = self.extraArgs['prefix']
|
2020-10-08 12:18:51 +05:00
|
|
|
home = self.extraArgs['home']
|
2020-10-08 21:33:57 +05:00
|
|
|
siteName = self.extraArgs['siteName']
|
2020-10-08 22:08:42 +05:00
|
|
|
|
2018-07-13 21:45:40 +05:00
|
|
|
tempStatusPath = self.extraArgs['tempStatusPath']
|
2020-02-28 11:40:55 +05:00
|
|
|
self.tempStatusPath = tempStatusPath
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-02-21 21:26:36 +05:00
|
|
|
permPath = '/home/%s/public_html' % (domainName)
|
|
|
|
|
command = 'chmod 755 %s' % (permPath)
|
|
|
|
|
ProcessUtilities.executioner(command)
|
|
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
## Get Joomla
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
try:
|
|
|
|
|
website = ChildDomains.objects.get(domain=domainName)
|
|
|
|
|
externalApp = website.master.externalApp
|
|
|
|
|
self.masterDomain = website.master.domain
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
if home == '0':
|
|
|
|
|
path = self.extraArgs['path']
|
|
|
|
|
finalPath = website.path.rstrip('/') + "/" + path + "/"
|
|
|
|
|
else:
|
|
|
|
|
finalPath = website.path + "/"
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
if website.master.package.dataBases > website.master.databases_set.all().count():
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
raise BaseException("Maximum database limit reached for this website.")
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Setting up Database,20')
|
|
|
|
|
statusFile.close()
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website.master)
|
|
|
|
|
self.permPath = website.path
|
|
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
website = Websites.objects.get(domain=domainName)
|
|
|
|
|
externalApp = website.externalApp
|
|
|
|
|
self.masterDomain = website.domain
|
|
|
|
|
|
|
|
|
|
if home == '0':
|
|
|
|
|
path = self.extraArgs['path']
|
|
|
|
|
finalPath = "/home/" + domainName + "/public_html/" + path + "/"
|
|
|
|
|
else:
|
|
|
|
|
finalPath = "/home/" + domainName + "/public_html/"
|
|
|
|
|
|
|
|
|
|
if website.package.dataBases > website.databases_set.all().count():
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
raise BaseException("Maximum database limit reached for this website.")
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Installing Joomla Console..,30')
|
|
|
|
|
statusFile.close()
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website)
|
|
|
|
|
self.permPath = '/home/%s/public_html' % (website.domain)
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
## Dataloss check
|
2019-11-24 12:14:18 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
command = 'ls -la %s' % (finalPath)
|
|
|
|
|
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
if result.find('No such file or directory') > -1:
|
|
|
|
|
command = 'mkdir %s' % (finalPath)
|
|
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
if self.dataLossCheck(finalPath, tempStatusPath) == 0:
|
|
|
|
|
raise BaseException('Directory is not empty.')
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-11-10 14:18:07 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
|
2020-10-12 13:25:27 +05:00
|
|
|
### Decide joomla console path
|
|
|
|
|
import getpass
|
|
|
|
|
|
|
|
|
|
if getpass.getuser() == 'root':
|
2020-11-10 14:18:07 +05:00
|
|
|
command = 'export COMPOSER_ALLOW_SUPERUSER=1;composer global require joomlatools/console'
|
|
|
|
|
ProcessUtilities.outputExecutioner(command, externalApp, None, self.permPath)
|
2020-10-12 13:25:27 +05:00
|
|
|
joomlaPath = '/root/.config/composer/vendor/bin/joomla'
|
|
|
|
|
else:
|
2020-11-10 14:18:07 +05:00
|
|
|
command = 'composer global require joomlatools/console'
|
|
|
|
|
ProcessUtilities.outputExecutioner(command, externalApp, None, self.permPath)
|
2020-11-10 15:29:47 +05:00
|
|
|
joomlaPath = '/home/%s/.config/composer/vendor/bin/joomla' % (self.masterDomain)
|
2020-10-12 13:25:27 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
## Run the install command
|
2018-07-13 21:45:40 +05:00
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
2020-10-08 12:18:51 +05:00
|
|
|
statusFile.writelines('Installing Joomla..,40')
|
2018-07-13 21:45:40 +05:00
|
|
|
statusFile.close()
|
|
|
|
|
|
2020-10-12 13:25:27 +05:00
|
|
|
command = '%s site:create %s --mysql-login %s:%s --mysql-database %s --mysql_db_prefix=%s --www %s --sample-data=blog --skip-create-statement' % (joomlaPath, dbUser, dbUser, dbPassword, dbName, prefix , finalPath)
|
2020-10-08 12:18:51 +05:00
|
|
|
|
|
|
|
|
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
if result.find('admin/admin') == -1:
|
|
|
|
|
raise BaseException(result)
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
### Update password as per user requirments
|
2018-07-13 21:45:40 +05:00
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
2020-10-08 12:18:51 +05:00
|
|
|
statusFile.writelines('Updating admin password..,70')
|
2018-07-13 21:45:40 +05:00
|
|
|
statusFile.close()
|
|
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
try:
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
salt = randomPassword.generate_pass(32)
|
|
|
|
|
# return salt
|
|
|
|
|
password_hash = hashlib.md5((password + salt).encode('utf-8')).hexdigest()
|
|
|
|
|
password = password_hash + ":" + salt
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
import MySQLdb.cursors as cursors
|
|
|
|
|
import MySQLdb as mysql
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
conn = mysql.connect(host='localhost', user=dbUser, passwd=dbPassword, port=3306,
|
|
|
|
|
cursorclass=cursors.SSCursor)
|
|
|
|
|
cursor = conn.cursor()
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
cursor.execute("use %s;UPDATE j_users SET password = '%s' where username = 'admin';FLUSH PRIVILEGES;" % (dbName, password))
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
conn.close()
|
|
|
|
|
except BaseException as msg:
|
|
|
|
|
logging.writeToFile(str(msg))
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
try:
|
|
|
|
|
os.remove('/usr/local/CyberCP/joomla.zip')
|
|
|
|
|
os.remove('/usr/local/CyberCP/lscache_plugin.zip')
|
2020-10-09 15:04:44 +05:00
|
|
|
os.remove('/usr/local/CyberCP/pkg_lscache.xml')
|
|
|
|
|
os.remove('/usr/local/CyberCP/pkg_script.php')
|
2020-10-08 12:18:51 +05:00
|
|
|
except:
|
|
|
|
|
pass
|
2020-04-03 11:28:27 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Installing LiteSpeed Cache Joomla plugin..,80')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
command = 'wget https://raw.githubusercontent.com/litespeedtech/lscache-joomla/master/package/lscache-1.3.1.zip -O /usr/local/CyberCP/joomla.zip'
|
2019-11-24 12:14:18 +05:00
|
|
|
ProcessUtilities.executioner(command)
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-09 15:04:44 +05:00
|
|
|
command = 'unzip -o /usr/local/CyberCP/joomla.zip -d /usr/local/CyberCP/'
|
2020-10-08 12:18:51 +05:00
|
|
|
ProcessUtilities.executioner(command)
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-12 13:25:27 +05:00
|
|
|
command = '%s extension:installfile %s --www %s /usr/local/CyberCP/lscache_plugin.zip' % (joomlaPath, dbUser, finalPath)
|
2020-10-08 12:18:51 +05:00
|
|
|
ProcessUtilities.executioner(command)
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2020-10-12 13:25:27 +05:00
|
|
|
command = '%s extension:installfile %s --www %s /usr/local/CyberCP/com_lscache.zip' % (joomlaPath, dbUser, finalPath)
|
2020-10-08 12:18:51 +05:00
|
|
|
ProcessUtilities.executioner(command)
|
|
|
|
|
|
2020-10-12 13:25:27 +05:00
|
|
|
command = '%s extension:enable %s --www %s lscache' % (joomlaPath, dbUser, finalPath)
|
2020-10-08 22:08:42 +05:00
|
|
|
|
2020-02-21 21:26:36 +05:00
|
|
|
ProcessUtilities.executioner(command)
|
|
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
command = 'mv %s%s/* %s' % (finalPath, dbUser, finalPath)
|
2020-10-09 15:04:44 +05:00
|
|
|
ProcessUtilities.executioner(command, None, True)
|
2020-10-08 12:18:51 +05:00
|
|
|
|
|
|
|
|
command = 'mv %s%s/.[^.]* %s' % (finalPath, dbUser, finalPath)
|
2020-10-09 15:04:44 +05:00
|
|
|
ProcessUtilities.executioner(command, None, True)
|
2020-10-08 12:18:51 +05:00
|
|
|
|
|
|
|
|
command = "sed -i 's|$debug = 1|$debug = 0|g' %sconfiguration.php" % (finalPath)
|
2020-10-09 15:04:44 +05:00
|
|
|
ProcessUtilities.executioner(command, None, True)
|
2020-10-08 12:18:51 +05:00
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
from filemanager.filemanager import FileManager
|
|
|
|
|
|
|
|
|
|
fm = FileManager(None, None)
|
|
|
|
|
fm.fixPermissions(self.masterDomain)
|
|
|
|
|
|
2020-10-08 22:08:42 +05:00
|
|
|
|
2020-10-08 22:04:58 +05:00
|
|
|
command = "sed -i \"s|sitename = '%s'|sitename = '%s'|g\" %sconfiguration.php" % (
|
2020-10-08 21:45:07 +05:00
|
|
|
dbUser, siteName, finalPath)
|
2020-10-09 15:04:44 +05:00
|
|
|
ProcessUtilities.executioner(command, externalApp, True)
|
2020-10-08 21:45:07 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
installUtilities.reStartLiteSpeedSocket()
|
|
|
|
|
|
2020-10-09 15:04:44 +05:00
|
|
|
content = """
|
|
|
|
|
=====================================================================
|
|
|
|
|
Joomla Successfully installed, login details below:
|
|
|
|
|
Username: admin
|
|
|
|
|
Password: %s
|
|
|
|
|
=====================================================================
|
|
|
|
|
""" % (self.extraArgs['password'])
|
|
|
|
|
|
|
|
|
|
print(content)
|
|
|
|
|
|
2018-07-13 21:45:40 +05:00
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines("Successfully Installed. [200]")
|
|
|
|
|
statusFile.close()
|
|
|
|
|
return 0
|
|
|
|
|
|
2019-12-10 15:09:10 +05:00
|
|
|
except BaseException as msg:
|
2018-07-13 21:45:40 +05:00
|
|
|
# remove the downloaded files
|
|
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
from filemanager.filemanager import FileManager
|
2020-04-03 11:28:27 +05:00
|
|
|
|
2020-10-08 12:18:51 +05:00
|
|
|
fm = FileManager(None, None)
|
|
|
|
|
fm.fixPermissions(self.masterDomain)
|
2018-07-13 21:45:40 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
try:
|
|
|
|
|
mysqlUtilities.deleteDatabase(dbName, dbUser)
|
|
|
|
|
db = Databases.objects.get(dbName=dbName)
|
|
|
|
|
db.delete()
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
2020-02-21 21:26:36 +05:00
|
|
|
permPath = '/home/%s/public_html' % (domainName)
|
2020-02-22 10:37:01 +05:00
|
|
|
command = 'chmod 750 %s' % (permPath)
|
2020-02-21 21:26:36 +05:00
|
|
|
ProcessUtilities.executioner(command)
|
|
|
|
|
|
2020-02-28 11:40:55 +05:00
|
|
|
statusFile = open(self.tempStatusPath, 'w')
|
2018-07-13 21:45:40 +05:00
|
|
|
statusFile.writelines(str(msg) + " [404]")
|
|
|
|
|
statusFile.close()
|
2019-07-16 23:23:16 +05:00
|
|
|
logging.writeToFile(str(msg))
|
2018-07-13 21:45:40 +05:00
|
|
|
return 0
|
2018-07-28 01:25:51 +05:00
|
|
|
|
2020-08-24 05:50:28 +05:00
|
|
|
# def installMagento(self):
|
|
|
|
|
# try:
|
|
|
|
|
#
|
|
|
|
|
# username = self.extraArgs['username']
|
|
|
|
|
# domainName = self.extraArgs['domainName']
|
|
|
|
|
# home = self.extraArgs['home']
|
|
|
|
|
# firstName = self.extraArgs['firstName']
|
|
|
|
|
# lastName = self.extraArgs['lastName']
|
|
|
|
|
# email = self.extraArgs['email']
|
|
|
|
|
# password = self.extraArgs['password']
|
|
|
|
|
# tempStatusPath = self.extraArgs['tempStatusPath']
|
|
|
|
|
# sampleData = self.extraArgs['sampleData']
|
|
|
|
|
# self.tempStatusPath = tempStatusPath
|
|
|
|
|
#
|
|
|
|
|
# FNULL = open(os.devnull, 'w')
|
|
|
|
|
#
|
|
|
|
|
# ## Open Status File
|
|
|
|
|
#
|
|
|
|
|
# statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
# statusFile.writelines('Setting up paths,0')
|
|
|
|
|
# statusFile.close()
|
|
|
|
|
#
|
|
|
|
|
# finalPath = ''
|
|
|
|
|
# self.premPath = ''
|
|
|
|
|
#
|
|
|
|
|
# try:
|
|
|
|
|
# website = ChildDomains.objects.get(domain=domainName)
|
|
|
|
|
# externalApp = website.master.externalApp
|
|
|
|
|
# self.masterDomain = website.master.domain
|
|
|
|
|
#
|
|
|
|
|
# if home == '0':
|
|
|
|
|
# path = self.extraArgs['path']
|
|
|
|
|
# finalPath = website.path.rstrip('/') + "/" + path + "/"
|
|
|
|
|
# else:
|
|
|
|
|
# finalPath = website.path + "/"
|
|
|
|
|
#
|
|
|
|
|
# if website.master.package.dataBases > website.master.databases_set.all().count():
|
|
|
|
|
# pass
|
|
|
|
|
# else:
|
|
|
|
|
# raise BaseException( "Maximum database limit reached for this website.")
|
|
|
|
|
#
|
|
|
|
|
# statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
# statusFile.writelines('Setting up Database,20')
|
|
|
|
|
# statusFile.close()
|
|
|
|
|
#
|
|
|
|
|
# dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website.master)
|
|
|
|
|
# self.permPath = website.path
|
|
|
|
|
#
|
|
|
|
|
# except:
|
|
|
|
|
# website = Websites.objects.get(domain=domainName)
|
|
|
|
|
# externalApp = website.externalApp
|
|
|
|
|
# self.masterDomain = website.domain
|
|
|
|
|
#
|
|
|
|
|
# if home == '0':
|
|
|
|
|
# path = self.extraArgs['path']
|
|
|
|
|
# finalPath = "/home/" + domainName + "/public_html/" + path + "/"
|
|
|
|
|
# else:
|
|
|
|
|
# finalPath = "/home/" + domainName + "/public_html/"
|
|
|
|
|
#
|
|
|
|
|
# if website.package.dataBases > website.databases_set.all().count():
|
|
|
|
|
# pass
|
|
|
|
|
# else:
|
|
|
|
|
# raise BaseException( "Maximum database limit reached for this website.")
|
|
|
|
|
#
|
|
|
|
|
# statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
# statusFile.writelines('Setting up Database,20')
|
|
|
|
|
# statusFile.close()
|
|
|
|
|
#
|
|
|
|
|
# dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website)
|
|
|
|
|
# self.permPath = '/home/%s/public_html' % (website.domain)
|
|
|
|
|
#
|
|
|
|
|
# ## Security Check
|
|
|
|
|
#
|
|
|
|
|
# if finalPath.find("..") > -1:
|
|
|
|
|
# raise BaseException( "Specified path must be inside virtual host home.")
|
|
|
|
|
#
|
|
|
|
|
# command = 'chmod 755 %s' % (self.permPath)
|
|
|
|
|
# ProcessUtilities.executioner(command)
|
|
|
|
|
#
|
|
|
|
|
# if not os.path.exists(finalPath):
|
|
|
|
|
# command = 'mkdir -p ' + finalPath
|
|
|
|
|
# ProcessUtilities.executioner(command, externalApp)
|
|
|
|
|
#
|
|
|
|
|
# ## checking for directories/files
|
|
|
|
|
#
|
|
|
|
|
# if self.dataLossCheck(finalPath, tempStatusPath) == 0:
|
|
|
|
|
# raise BaseException('Directory not empty.')
|
|
|
|
|
#
|
|
|
|
|
# ####
|
|
|
|
|
#
|
|
|
|
|
# statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
# statusFile.writelines('Downloading Magento Community Core via composer to document root ..,30')
|
|
|
|
|
# statusFile.close()
|
|
|
|
|
#
|
|
|
|
|
# command = 'composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition %s' % (finalPath)
|
|
|
|
|
#
|
|
|
|
|
# ProcessUtilities.executioner(command, externalApp)
|
|
|
|
|
#
|
|
|
|
|
# ###
|
|
|
|
|
#
|
|
|
|
|
# statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
# statusFile.writelines('Configuring the installation,40')
|
|
|
|
|
# statusFile.close()
|
|
|
|
|
#
|
|
|
|
|
# if home == '0':
|
|
|
|
|
# path = self.extraArgs['path']
|
|
|
|
|
# # finalURL = domainName + '/' + path
|
|
|
|
|
# finalURL = domainName
|
|
|
|
|
# else:
|
|
|
|
|
# finalURL = domainName
|
|
|
|
|
#
|
|
|
|
|
# statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
# statusFile.writelines('Installing and configuring Magento..,60')
|
|
|
|
|
# statusFile.close()
|
|
|
|
|
#
|
|
|
|
|
# command = '/usr/local/lsws/lsphp73/bin/php -d memory_limit=512M %sbin/magento setup:install --base-url="http://%s" ' \
|
|
|
|
|
# ' --db-host="localhost" --db-name="%s" --db-user="%s" --db-password="%s" --admin-firstname="%s" ' \
|
|
|
|
|
# ' --admin-lastname="%s" --admin-email="%s" --admin-user="%s" --admin-password="%s" --language="%s" --timezone="%s" ' \
|
|
|
|
|
# ' --use-rewrites=1 --search-engine="elasticsearch7" --elasticsearch-host="localhost" --elasticsearch-port="9200" ' \
|
|
|
|
|
# ' --elasticsearch-index-prefix="%s"' \
|
|
|
|
|
# % (finalPath, finalURL, dbName, dbUser, dbPassword, firstName, lastName, email, username, password, 'language', 'timezone', dbName )
|
|
|
|
|
#
|
|
|
|
|
# result = ProcessUtilities.outputExecutioner(command, externalApp)
|
|
|
|
|
# logging.writeToFile(result)
|
|
|
|
|
#
|
|
|
|
|
# ##
|
|
|
|
|
#
|
|
|
|
|
# ProcessUtilities.executioner(command, externalApp)
|
|
|
|
|
#
|
|
|
|
|
# ##
|
|
|
|
|
#
|
|
|
|
|
# from filemanager.filemanager import FileManager
|
|
|
|
|
#
|
|
|
|
|
# fm = FileManager(None, None)
|
|
|
|
|
# fm.fixPermissions(self.masterDomain)
|
|
|
|
|
#
|
|
|
|
|
# installUtilities.reStartLiteSpeed()
|
|
|
|
|
#
|
|
|
|
|
# statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
# statusFile.writelines("Successfully Installed. [200]")
|
|
|
|
|
# statusFile.close()
|
|
|
|
|
# return 0
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# except BaseException as msg:
|
|
|
|
|
# # remove the downloaded files
|
|
|
|
|
#
|
|
|
|
|
# homeDir = "/home/" + domainName + "/public_html"
|
|
|
|
|
#
|
|
|
|
|
# if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
|
|
|
|
# groupName = 'nobody'
|
|
|
|
|
# else:
|
|
|
|
|
# groupName = 'nogroup'
|
|
|
|
|
#
|
|
|
|
|
# if not os.path.exists(homeDir):
|
|
|
|
|
# command = "chown -R " + externalApp + ":" + groupName + " " + homeDir
|
|
|
|
|
# ProcessUtilities.executioner(command, externalApp)
|
|
|
|
|
#
|
|
|
|
|
# try:
|
|
|
|
|
# mysqlUtilities.deleteDatabase(dbName, dbUser)
|
|
|
|
|
# db = Databases.objects.get(dbName=dbName)
|
|
|
|
|
# db.delete()
|
|
|
|
|
# except:
|
|
|
|
|
# pass
|
|
|
|
|
#
|
|
|
|
|
# permPath = '/home/%s/public_html' % (domainName)
|
|
|
|
|
# command = 'chmod 750 %s' % (permPath)
|
|
|
|
|
# ProcessUtilities.executioner(command)
|
|
|
|
|
#
|
|
|
|
|
# statusFile = open(self.tempStatusPath, 'w')
|
|
|
|
|
# statusFile.writelines(str(msg) + " [404]")
|
|
|
|
|
# statusFile.close()
|
|
|
|
|
# return 0
|
2020-12-22 12:12:41 +05:00
|
|
|
|
|
|
|
|
def DeployWordPress(self):
|
|
|
|
|
try:
|
2020-12-23 19:06:42 +05:00
|
|
|
|
2021-01-12 17:56:36 +05:00
|
|
|
if self.extraArgs['createSite']:
|
|
|
|
|
logging.statusWriter(self.extraArgs['tempStatusPath'], 'Creating this application..,10')
|
2020-12-23 19:06:42 +05:00
|
|
|
|
2021-01-12 17:56:36 +05:00
|
|
|
## Create site
|
2020-12-23 19:06:42 +05:00
|
|
|
|
2021-01-12 17:56:36 +05:00
|
|
|
import re
|
|
|
|
|
from plogical.virtualHostUtilities import virtualHostUtilities
|
|
|
|
|
tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
|
|
|
|
externalApp = "".join(re.findall("[a-zA-Z]+", self.extraArgs['domain']))[:5] + str(randint(1000, 9999))
|
|
|
|
|
|
|
|
|
|
virtualHostUtilities.createVirtualHost(self.extraArgs['domain'], self.extraArgs['email'], 'PHP 7.4',
|
|
|
|
|
externalApp, 1, 1, 0,
|
|
|
|
|
'admin', 'Default', 0, tempStatusPath,
|
|
|
|
|
0)
|
|
|
|
|
result = open(tempStatusPath, 'r').read()
|
|
|
|
|
if result.find('[404]') > -1:
|
|
|
|
|
logging.statusWriter(self.extraArgs['tempStatusPath'], 'Failed to create application. Error: %s [404]' % (result))
|
|
|
|
|
return 0
|
2020-12-22 12:12:41 +05:00
|
|
|
|
2020-12-23 19:06:42 +05:00
|
|
|
## Install WordPress
|
|
|
|
|
|
|
|
|
|
logging.statusWriter(self.extraArgs['tempStatusPath'], 'Installing WordPress.,50')
|
|
|
|
|
|
|
|
|
|
currentTemp = self.extraArgs['tempStatusPath']
|
|
|
|
|
self.extraArgs['domainName'] = self.extraArgs['domain']
|
|
|
|
|
self.extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
|
|
|
|
|
self.extraArgs['blogTitle'] = self.extraArgs['title']
|
|
|
|
|
self.extraArgs['adminUser'] = self.extraArgs['userName']
|
|
|
|
|
self.extraArgs['adminPassword'] = self.extraArgs['password']
|
|
|
|
|
self.extraArgs['adminEmail'] = self.extraArgs['email']
|
|
|
|
|
|
|
|
|
|
self.installWordPress()
|
|
|
|
|
|
|
|
|
|
result = open(self.extraArgs['tempStatusPath'], 'r').read()
|
|
|
|
|
if result.find('[404]') > -1:
|
2021-01-12 17:56:36 +05:00
|
|
|
self.extraArgs['tempStatusPath'] = currentTemp
|
|
|
|
|
raise BaseException('Failed to install WordPress. Error: %s [404]' % (result))
|
2020-12-23 19:06:42 +05:00
|
|
|
|
|
|
|
|
self.extraArgs['tempStatusPath'] = currentTemp
|
2020-12-22 12:12:41 +05:00
|
|
|
|
2020-12-25 14:18:47 +05:00
|
|
|
|
2020-12-22 12:12:41 +05:00
|
|
|
logging.statusWriter(self.extraArgs['tempStatusPath'], 'Completed [200].')
|
|
|
|
|
|
2020-12-31 22:54:07 +05:00
|
|
|
try:
|
|
|
|
|
### Save config in db
|
|
|
|
|
|
|
|
|
|
from cloudAPI.models import WPDeployments
|
|
|
|
|
from websiteFunctions.models import Websites
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
website = Websites.objects.get(domain=self.extraArgs['domain'])
|
|
|
|
|
del self.extraArgs['adminPassword']
|
|
|
|
|
del self.extraArgs['password']
|
|
|
|
|
del self.extraArgs['tempStatusPath']
|
|
|
|
|
del self.extraArgs['domain']
|
|
|
|
|
del self.extraArgs['adminEmail']
|
|
|
|
|
del self.extraArgs['adminUser']
|
|
|
|
|
del self.extraArgs['blogTitle']
|
|
|
|
|
del self.extraArgs['appsSet']
|
|
|
|
|
|
|
|
|
|
wpDeploy = WPDeployments(owner=website, config=json.dumps(self.extraArgs))
|
|
|
|
|
wpDeploy.save()
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
2021-01-02 00:45:29 +05:00
|
|
|
## Set up cron if missing
|
|
|
|
|
|
|
|
|
|
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
|
|
|
|
localCronPath = "/var/spool/cron/root"
|
|
|
|
|
else:
|
|
|
|
|
localCronPath = "/var/spool/cron/crontabs/root"
|
|
|
|
|
|
|
|
|
|
cronData = open(localCronPath, 'r').read()
|
|
|
|
|
|
|
|
|
|
if cronData.find('WPAutoUpdates.py') == -1:
|
|
|
|
|
writeToFile = open(localCronPath, 'a')
|
|
|
|
|
writeToFile.write('0 12 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/WPAutoUpdates.py\n')
|
|
|
|
|
writeToFile.close()
|
|
|
|
|
|
2020-12-22 12:12:41 +05:00
|
|
|
except BaseException as msg:
|
2021-01-12 17:56:36 +05:00
|
|
|
self.extraArgs['websiteName'] = self.extraArgs['domain']
|
|
|
|
|
from websiteFunctions.website import WebsiteManager
|
|
|
|
|
wm = WebsiteManager()
|
|
|
|
|
wm.submitWebsiteDeletion(1, self.extraArgs)
|
2020-12-22 12:12:41 +05:00
|
|
|
logging.statusWriter(self.extraArgs['tempStatusPath'], '%s [404].' % (str(msg)))
|
2021-01-12 20:12:18 -05:00
|
|
|
|
|
|
|
|
def installWhmcs(self):
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
admin = self.extraArgs['admin']
|
|
|
|
|
domainName = self.extraArgs['domainName']
|
|
|
|
|
home = self.extraArgs['home']
|
|
|
|
|
firstName = self.extraArgs['firstName']
|
|
|
|
|
lastName = self.extraArgs['lastName']
|
|
|
|
|
email = self.extraArgs['email']
|
|
|
|
|
username = self.extraArgs['username']
|
|
|
|
|
password = self.extraArgs['password']
|
|
|
|
|
whmcs_installer = self.extraArgs['whmcsinstallerpath']
|
|
|
|
|
whmcs_licensekey = self.extraArgs['whmcslicensekey']
|
|
|
|
|
tempStatusPath = self.extraArgs['tempStatusPath']
|
|
|
|
|
self.tempStatusPath = tempStatusPath
|
|
|
|
|
|
|
|
|
|
FNULL = open(os.devnull, 'w')
|
|
|
|
|
|
|
|
|
|
## Open Status File
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Setting up paths,0')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
finalPath = ''
|
|
|
|
|
self.permPath = ''
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
website = ChildDomains.objects.get(domain=domainName)
|
|
|
|
|
externalApp = website.master.externalApp
|
|
|
|
|
self.masterDomain = website.master.domain
|
|
|
|
|
|
|
|
|
|
if home == '0':
|
|
|
|
|
path = self.extraArgs['path']
|
|
|
|
|
finalPath = website.path.rstrip('/') + "/" + path + "/"
|
|
|
|
|
else:
|
|
|
|
|
finalPath = website.path + "/"
|
|
|
|
|
|
|
|
|
|
if website.master.package.dataBases > website.master.databases_set.all().count():
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
raise BaseException("Maximum database limit reached for this website.")
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Setting up Database,20')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website.master)
|
|
|
|
|
self.permPath = website.path
|
|
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
website = Websites.objects.get(domain=domainName)
|
|
|
|
|
externalApp = website.externalApp
|
|
|
|
|
self.masterDomain = website.domain
|
|
|
|
|
|
|
|
|
|
if home == '0':
|
|
|
|
|
path = self.extraArgs['path']
|
|
|
|
|
finalPath = "/home/" + domainName + "/public_html/" + path + "/"
|
|
|
|
|
else:
|
|
|
|
|
finalPath = "/home/" + domainName + "/public_html/"
|
|
|
|
|
|
|
|
|
|
if website.package.dataBases > website.databases_set.all().count():
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
raise BaseException("Maximum database limit reached for this website.")
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Setting up Database,20')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website)
|
|
|
|
|
self.permPath = '/home/%s/public_html' % (website.domain)
|
|
|
|
|
|
|
|
|
|
## Security Check
|
|
|
|
|
|
|
|
|
|
command = 'chmod 755 %s' % (self.permPath)
|
|
|
|
|
ProcessUtilities.executioner(command)
|
|
|
|
|
|
|
|
|
|
if finalPath.find("..") > -1:
|
|
|
|
|
raise BaseException('Specified path must be inside virtual host home.')
|
|
|
|
|
|
|
|
|
|
if not os.path.exists(finalPath):
|
|
|
|
|
command = 'mkdir -p ' + finalPath
|
|
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
## checking for directories/files
|
|
|
|
|
|
|
|
|
|
if self.dataLossCheck(finalPath, tempStatusPath) == 0:
|
|
|
|
|
raise BaseException('Directory is not empty.')
|
|
|
|
|
|
|
|
|
|
####
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Extracting WHMCS Installer zip..,30')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
command = "unzip -qq %s -d %s" % (whmcs_installer, finalPath)
|
|
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Configuring the installation,40')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
if home == '0':
|
|
|
|
|
path = self.extraArgs['path']
|
|
|
|
|
# finalURL = domainName + '/' + path
|
|
|
|
|
finalURL = domainName
|
|
|
|
|
else:
|
|
|
|
|
finalURL = domainName
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Installing and configuring WHMCS..,60')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
command = "chown -R " + externalApp + ":" + groupName + " " + homeDir
|
|
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
# Walk through whmcs webinstaller via curl with all except errors hidden https://stackoverflow.com/a/49502232
|
|
|
|
|
# Accept EULA and generate configuration.php
|
|
|
|
|
command = "curl %s/install/install.php?step=2 --insecure --silent --output /dev/null --show-error --fail" % (finalURL)
|
|
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
command = "curl %s/install/install.php?step=2 --insecure --silent --output /dev/null --show-error --fail" % (finalURL)
|
|
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
command = "mv %s/configuration.php.new %s/configuration.php" % (finalPath, finalPath)
|
|
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
# Post database and license information to webinstaller form
|
|
|
|
|
command = """
|
|
|
|
|
curl %s/install/install.php?step=4" \
|
|
|
|
|
-H 'Content-Type: application/x-www-form-urlencoded' \
|
|
|
|
|
--data "licenseKey=%s&databaseHost=localhost&databasePort=&databaseUsername=%s&databasePassword=%s&databaseName=%s" \
|
|
|
|
|
--compressed \
|
|
|
|
|
--insecure \
|
|
|
|
|
--silent \
|
|
|
|
|
--output /dev/null \
|
|
|
|
|
--show-error \
|
|
|
|
|
--fail
|
|
|
|
|
""" % (whmcs_licensekey, dbUser, dbPassword, dbName)
|
|
|
|
|
|
|
|
|
|
# Post admin user and password information to webinstaller form
|
|
|
|
|
command = """
|
|
|
|
|
curl %s/install/install.php?step=5" \
|
|
|
|
|
-H 'Content-Type: application/x-www-form-urlencoded' \
|
|
|
|
|
--data "firstName=%s&lastName=%s&email=%s&username=%s&password=%s&confirmPassword=%s" \
|
|
|
|
|
--compressed \
|
|
|
|
|
--insecure \
|
|
|
|
|
--silent \
|
|
|
|
|
--output /dev/null \
|
|
|
|
|
--show-error \
|
|
|
|
|
--fail
|
|
|
|
|
""" % (firstName, lastName, email, username, password, password)
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
command = "rm -rf " + finalPath + "install"
|
|
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Update whmcs urls to siteurl
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines('Update whmcs urls to siteurl..,70')
|
|
|
|
|
statusFile.close()
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
import MySQLdb.cursors as cursors
|
|
|
|
|
import MySQLdb as mysql
|
|
|
|
|
|
|
|
|
|
conn = mysql.connect(host='localhost', user=dbUser, passwd=dbPassword, port=3306,
|
|
|
|
|
cursorclass=cursors.SSCursor)
|
|
|
|
|
cursor = conn.cursor()
|
|
|
|
|
|
|
|
|
|
cursor.execute("use %s;UPDATE tblconfiguration SET value='%s' WHERE setting='SystemURL';" % (dbName, finalURL))
|
|
|
|
|
cursor.execute("use %s;UPDATE tblconfiguration SET value='%s' WHERE setting='Domain';" % (dbName, finalURL))
|
|
|
|
|
cursor.execute("use %s;UPDATE tblconfiguration SET value='%s' WHERE setting='SystemSSLURL';" % (dbName, finalURL))
|
|
|
|
|
|
|
|
|
|
conn.close()
|
|
|
|
|
except BaseException as msg:
|
|
|
|
|
logging.writeToFile(str(msg))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Secure WHMCS configuration.php file : https://docs.whmcs.com/Further_Security_Steps#Secure_the_configuration.php_File
|
2021-01-13 09:22:55 -05:00
|
|
|
command = "chmod 400 %s/configuration.php" % (finalPath)
|
2021-01-12 20:12:18 -05:00
|
|
|
ProcessUtilities.executioner(command)
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
from filemanager.filemanager import FileManager
|
|
|
|
|
|
|
|
|
|
fm = FileManager(None, None)
|
|
|
|
|
fm.fixPermissions(self.masterDomain)
|
|
|
|
|
|
|
|
|
|
statusFile = open(tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines("Successfully Installed. [200]")
|
|
|
|
|
statusFile.close()
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except BaseException as msg:
|
|
|
|
|
# remove the downloaded files
|
|
|
|
|
|
|
|
|
|
homeDir = "/home/" + domainName + "/public_html"
|
|
|
|
|
|
|
|
|
|
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
|
|
|
|
groupName = 'nobody'
|
|
|
|
|
else:
|
|
|
|
|
groupName = 'nogroup'
|
|
|
|
|
|
|
|
|
|
if not os.path.exists(homeDir):
|
|
|
|
|
command = "chown -R " + externalApp + ":" + groupName + " " + homeDir
|
|
|
|
|
ProcessUtilities.executioner(command, externalApp)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
mysqlUtilities.deleteDatabase(dbName, dbUser)
|
|
|
|
|
db = Databases.objects.get(dbName=dbName)
|
|
|
|
|
db.delete()
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
command = 'chmod 750 %s' % (self.permPath)
|
|
|
|
|
ProcessUtilities.executioner(command)
|
|
|
|
|
|
|
|
|
|
statusFile = open(self.tempStatusPath, 'w')
|
|
|
|
|
statusFile.writelines(str(msg) + " [404]")
|
|
|
|
|
statusFile.close()
|
|
|
|
|
return 0
|
2020-12-22 12:12:41 +05:00
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
parser = argparse.ArgumentParser(description='CyberPanel Application Installer')
|
|
|
|
|
parser.add_argument('function', help='Specify a function to call!')
|
|
|
|
|
parser.add_argument('--tempStatusPath', help='')
|
|
|
|
|
parser.add_argument('--appsSet', help='')
|
|
|
|
|
parser.add_argument('--domain', help='')
|
|
|
|
|
parser.add_argument('--email', help='')
|
|
|
|
|
parser.add_argument('--password', help='')
|
|
|
|
|
parser.add_argument('--pluginUpdates', help='')
|
|
|
|
|
parser.add_argument('--themeUpdates', help='')
|
|
|
|
|
parser.add_argument('--title', help='')
|
|
|
|
|
parser.add_argument('--updates', help='')
|
|
|
|
|
parser.add_argument('--userName', help='')
|
|
|
|
|
parser.add_argument('--version', help='')
|
2020-12-23 19:06:42 +05:00
|
|
|
parser.add_argument('--path', help='')
|
2021-01-12 17:56:36 +05:00
|
|
|
parser.add_argument('--createSite', help='')
|
2020-12-22 12:12:41 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
if args.function == "DeployWordPress":
|
|
|
|
|
|
|
|
|
|
extraArgs = {}
|
|
|
|
|
extraArgs['domain'] = args.domain
|
|
|
|
|
extraArgs['tempStatusPath'] = args.tempStatusPath
|
|
|
|
|
extraArgs['appsSet'] = args.appsSet
|
|
|
|
|
extraArgs['email'] = args.email
|
|
|
|
|
extraArgs['password'] = args.password
|
|
|
|
|
extraArgs['pluginUpdates'] = args.pluginUpdates
|
|
|
|
|
extraArgs['themeUpdates'] = args.themeUpdates
|
|
|
|
|
extraArgs['title'] = args.title
|
|
|
|
|
extraArgs['updates'] = args.updates
|
|
|
|
|
extraArgs['userName'] = args.userName
|
|
|
|
|
extraArgs['version'] = args.version
|
2021-01-12 17:56:36 +05:00
|
|
|
extraArgs['createSite'] = int(args.createSite)
|
2020-12-23 19:06:42 +05:00
|
|
|
|
2020-12-25 14:18:47 +05:00
|
|
|
if args.path != None:
|
2020-12-23 19:06:42 +05:00
|
|
|
extraArgs['path'] = args.path
|
|
|
|
|
extraArgs['home'] = '0'
|
2020-12-25 14:18:47 +05:00
|
|
|
else:
|
2020-12-23 19:06:42 +05:00
|
|
|
extraArgs['home'] = '1'
|
|
|
|
|
|
2020-12-22 12:12:41 +05:00
|
|
|
ai = ApplicationInstaller(None, extraArgs)
|
|
|
|
|
ai.DeployWordPress()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2021-01-12 19:16:15 -05:00
|
|
|
main()
|