Skip to content

Commit 9920b52

Browse files
committed
wp deploy
1 parent 5f1c0ae commit 9920b52

2 files changed

Lines changed: 59 additions & 21 deletions

File tree

cloudAPI/cloudManager.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,11 @@ def DeployWordPress(self):
19241924
self.data['pluginUpdates'], self.data['themeUpdates'], self.data['title'], self.data['updates'],
19251925
self.data['userName'], self.data['version'])
19261926

1927+
try:
1928+
execPath = '%s --path %s' % (execPath, self.data['path'])
1929+
except:
1930+
pass
1931+
19271932
ProcessUtilities.popenExecutioner(execPath)
19281933

19291934
final_dic = {'status': 1, 'tempStatusPath': tempStatusPath}

plogical/applicationInstaller.py

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ def dbCreation(self, tempStatusPath, website):
467467
def installWordPress(self):
468468
try:
469469

470-
admin = self.extraArgs['admin']
471470
domainName = self.extraArgs['domainName']
472471
home = self.extraArgs['home']
473472
tempStatusPath = self.extraArgs['tempStatusPath']
@@ -521,7 +520,6 @@ def installWordPress(self):
521520

522521
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website.master)
523522
self.permPath = website.path
524-
525523
except:
526524
website = Websites.objects.get(domain=domainName)
527525
externalApp = website.externalApp
@@ -568,7 +566,11 @@ def installWordPress(self):
568566
statusFile.writelines('Downloading WordPress Core,30')
569567
statusFile.close()
570568

571-
command = "wp core download --allow-root --path=" + finalPath
569+
try:
570+
command = "wp core download --allow-root --path=%s --version=%s" % (finalPath, self.extraArgs['version'])
571+
except BaseException as msg:
572+
command = "wp core download --allow-root --path=" + finalPath
573+
572574
ProcessUtilities.executioner(command, externalApp)
573575

574576
##
@@ -620,18 +622,10 @@ def installWordPress(self):
620622

621623
except BaseException as msg:
622624
# remove the downloaded files
623-
FNULL = open(os.devnull, 'w')
624-
625-
homeDir = "/home/" + domainName + "/public_html"
626-
627-
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
628-
groupName = 'nobody'
629-
else:
630-
groupName = 'nogroup'
631625

632-
if not os.path.exists(homeDir):
633-
command = "chown " + externalApp + ":" + groupName + " " + homeDir
634-
ProcessUtilities.executioner(command, externalApp)
626+
from filemanager.filemanager import FileManager
627+
fm = FileManager(None, None)
628+
fm.fixPermissions(self.masterDomain)
635629

636630
try:
637631
mysqlUtilities.deleteDatabase(dbName, dbUser)
@@ -640,10 +634,6 @@ def installWordPress(self):
640634
except:
641635
pass
642636

643-
command = 'chmod 750 %s' % (self.permPath)
644-
ProcessUtilities.executioner(command)
645-
646-
647637
statusFile = open(self.tempStatusPath, 'w')
648638
statusFile.writelines(str(msg) + " [404]")
649639
statusFile.close()
@@ -1221,10 +1211,45 @@ def installJoomla(self):
12211211

12221212
def DeployWordPress(self):
12231213
try:
1224-
logging.statusWriter(self.extraArgs['tempStatusPath'], 'Checking if MailServer SSL issued..,10')
1214+
logging.statusWriter(self.extraArgs['tempStatusPath'], 'Creating this application..,10')
1215+
1216+
## Create site
1217+
1218+
import re
1219+
from plogical.virtualHostUtilities import virtualHostUtilities
1220+
tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999))
1221+
externalApp = "".join(re.findall("[a-zA-Z]+", self.extraArgs['domain']))[:5] + str(randint(1000, 9999))
1222+
1223+
virtualHostUtilities.createVirtualHost(self.extraArgs['domain'], self.extraArgs['email'], 'PHP 7.4',
1224+
externalApp, 0, 1, 0,
1225+
'admin', 'Default', 0, tempStatusPath,
1226+
0)
1227+
result = open(tempStatusPath, 'r').read()
1228+
if result.find('[404]') > -1:
1229+
logging.statusWriter(self.extraArgs['tempStatusPath'], 'Failed to create application. Error: %s [404]' % (result))
1230+
return 0
12251231

1226-
import time
1227-
time.sleep(5)
1232+
## Install WordPress
1233+
1234+
logging.statusWriter(self.extraArgs['tempStatusPath'], 'Installing WordPress.,50')
1235+
1236+
currentTemp = self.extraArgs['tempStatusPath']
1237+
self.extraArgs['domainName'] = self.extraArgs['domain']
1238+
self.extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
1239+
self.extraArgs['blogTitle'] = self.extraArgs['title']
1240+
self.extraArgs['adminUser'] = self.extraArgs['userName']
1241+
self.extraArgs['adminPassword'] = self.extraArgs['password']
1242+
self.extraArgs['adminEmail'] = self.extraArgs['email']
1243+
1244+
self.installWordPress()
1245+
1246+
result = open(self.extraArgs['tempStatusPath'], 'r').read()
1247+
if result.find('[404]') > -1:
1248+
logging.statusWriter(self.extraArgs['tempStatusPath'],
1249+
'Failed to install WordPress. Error: %s [404]' % (result))
1250+
return 0
1251+
1252+
self.extraArgs['tempStatusPath'] = currentTemp
12281253

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

@@ -1245,6 +1270,7 @@ def main():
12451270
parser.add_argument('--updates', help='')
12461271
parser.add_argument('--userName', help='')
12471272
parser.add_argument('--version', help='')
1273+
parser.add_argument('--path', help='')
12481274

12491275

12501276
args = parser.parse_args()
@@ -1263,6 +1289,13 @@ def main():
12631289
extraArgs['updates'] = args.updates
12641290
extraArgs['userName'] = args.userName
12651291
extraArgs['version'] = args.version
1292+
1293+
try:
1294+
extraArgs['path'] = args.path
1295+
extraArgs['home'] = '0'
1296+
except:
1297+
extraArgs['home'] = '1'
1298+
12661299
ai = ApplicationInstaller(None, extraArgs)
12671300
ai.DeployWordPress()
12681301

0 commit comments

Comments
 (0)