Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
wp deploy
  • Loading branch information
usmannasir committed Dec 23, 2020
1 parent 5f1c0ae commit 9920b52
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 21 deletions.
5 changes: 5 additions & 0 deletions cloudAPI/cloudManager.py
Expand Up @@ -1924,6 +1924,11 @@ def DeployWordPress(self):
self.data['pluginUpdates'], self.data['themeUpdates'], self.data['title'], self.data['updates'],
self.data['userName'], self.data['version'])

try:
execPath = '%s --path %s' % (execPath, self.data['path'])
except:
pass

ProcessUtilities.popenExecutioner(execPath)

final_dic = {'status': 1, 'tempStatusPath': tempStatusPath}
Expand Down
75 changes: 54 additions & 21 deletions plogical/applicationInstaller.py
Expand Up @@ -467,7 +467,6 @@ def dbCreation(self, tempStatusPath, website):
def installWordPress(self):
try:

admin = self.extraArgs['admin']
domainName = self.extraArgs['domainName']
home = self.extraArgs['home']
tempStatusPath = self.extraArgs['tempStatusPath']
Expand Down Expand Up @@ -521,7 +520,6 @@ def installWordPress(self):

dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website.master)
self.permPath = website.path

except:
website = Websites.objects.get(domain=domainName)
externalApp = website.externalApp
Expand Down Expand Up @@ -568,7 +566,11 @@ def installWordPress(self):
statusFile.writelines('Downloading WordPress Core,30')
statusFile.close()

command = "wp core download --allow-root --path=" + finalPath
try:
command = "wp core download --allow-root --path=%s --version=%s" % (finalPath, self.extraArgs['version'])
except BaseException as msg:
command = "wp core download --allow-root --path=" + finalPath

ProcessUtilities.executioner(command, externalApp)

##
Expand Down Expand Up @@ -620,18 +622,10 @@ def installWordPress(self):

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)
from filemanager.filemanager import FileManager
fm = FileManager(None, None)
fm.fixPermissions(self.masterDomain)

try:
mysqlUtilities.deleteDatabase(dbName, dbUser)
Expand All @@ -640,10 +634,6 @@ def installWordPress(self):
except:
pass

command = 'chmod 750 %s' % (self.permPath)
ProcessUtilities.executioner(command)


statusFile = open(self.tempStatusPath, 'w')
statusFile.writelines(str(msg) + " [404]")
statusFile.close()
Expand Down Expand Up @@ -1221,10 +1211,45 @@ def installJoomla(self):

def DeployWordPress(self):
try:
logging.statusWriter(self.extraArgs['tempStatusPath'], 'Checking if MailServer SSL issued..,10')
logging.statusWriter(self.extraArgs['tempStatusPath'], 'Creating this application..,10')

## Create site

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, 0, 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

import time
time.sleep(5)
## 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:
logging.statusWriter(self.extraArgs['tempStatusPath'],
'Failed to install WordPress. Error: %s [404]' % (result))
return 0

self.extraArgs['tempStatusPath'] = currentTemp

logging.statusWriter(self.extraArgs['tempStatusPath'], 'Completed [200].')

Expand All @@ -1245,6 +1270,7 @@ def main():
parser.add_argument('--updates', help='')
parser.add_argument('--userName', help='')
parser.add_argument('--version', help='')
parser.add_argument('--path', help='')


args = parser.parse_args()
Expand All @@ -1263,6 +1289,13 @@ def main():
extraArgs['updates'] = args.updates
extraArgs['userName'] = args.userName
extraArgs['version'] = args.version

try:
extraArgs['path'] = args.path
extraArgs['home'] = '0'
except:
extraArgs['home'] = '1'

ai = ApplicationInstaller(None, extraArgs)
ai.DeployWordPress()

Expand Down

0 comments on commit 9920b52

Please sign in to comment.