Skip to content

Commit e2021a6

Browse files
committed
fix git attach
1 parent f15619d commit e2021a6

File tree

1 file changed

+73
-27
lines changed

1 file changed

+73
-27
lines changed

plogical/applicationInstaller.py

Lines changed: 73 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,10 @@ def installWPCLI(self):
154154
except BaseException as msg:
155155
logging.writeToFile(str(msg) + ' [ApplicationInstaller.installWPCLI]')
156156

157-
def dataLossCheck(self, finalPath, externalApp):
158-
return 1
157+
def dataLossCheck(self, finalPath, tempStatusPath):
158+
dirFiles = os.listdir(finalPath)
159159

160-
command = 'ls -la %s' % (finalPath)
161-
output = ProcessUtilities.outputExecutioner(command, 'nobody').splitlines()
162-
163-
logging.writeToFile(str(output))
164-
165-
if len(output) <= 3:
160+
if len(dirFiles) <= 3:
166161
return 1
167162
else:
168163
return 0
@@ -173,10 +168,10 @@ def installGit(self):
173168
command = 'apt -y install git'
174169
ProcessUtilities.executioner(command)
175170
else:
176-
command = 'sudo yum -y install http://repo.iotti.biz/CentOS/7/noarch/lux-release-7-1.noarch.rpm'
171+
command = 'yum -y install http://repo.iotti.biz/CentOS/7/noarch/lux-release-7-1.noarch.rpm'
177172
ProcessUtilities.executioner(command)
178173

179-
command = 'sudo yum install git -y'
174+
command = 'yum install git -y'
180175
ProcessUtilities.executioner(command)
181176

182177
except BaseException as msg:
@@ -302,6 +297,10 @@ def installWordPress(self):
302297

303298
## Security Check
304299

300+
permPath = '/home/%s/public_html' % (domainName)
301+
command = 'chmod 755 %s' % (permPath)
302+
ProcessUtilities.executioner(command)
303+
305304
if finalPath.find("..") > -1:
306305
statusFile = open(tempStatusPath, 'w')
307306
statusFile.writelines("Specified path must be inside virtual host home." + " [404]")
@@ -315,7 +314,7 @@ def installWordPress(self):
315314
## checking for directories/files
316315

317316
if self.dataLossCheck(finalPath, tempStatusPath) == 0:
318-
return 0
317+
raise BaseException('Directory is not empty.')
319318

320319
####
321320

@@ -365,6 +364,10 @@ def installWordPress(self):
365364
command = "chown -R " + externalApp + ":" + 'nobody' + " " + finalPath
366365
ProcessUtilities.executioner(command, externalApp)
367366

367+
permPath = '/home/%s/public_html' % (domainName)
368+
command = 'chmod 750 %s' % (permPath)
369+
ProcessUtilities.executioner(command)
370+
368371
statusFile = open(tempStatusPath, 'w')
369372
statusFile.writelines("Successfully Installed. [200]")
370373
statusFile.close()
@@ -388,6 +391,10 @@ def installWordPress(self):
388391
except:
389392
pass
390393

394+
permPath = '/home/%s/public_html' % (domainName)
395+
command = 'chmod 750 %s' % (permPath)
396+
ProcessUtilities.executioner(command)
397+
391398
statusFile = open(tempStatusPath, 'w')
392399
statusFile.writelines(str(msg) + " [404]")
393400
statusFile.close()
@@ -469,20 +476,24 @@ def installPrestaShop(self):
469476

470477
## Security Check
471478

479+
permPath = '/home/%s/public_html' % (domainName)
480+
command = 'chmod 755 %s' % (permPath)
481+
ProcessUtilities.executioner(command)
482+
472483
if finalPath.find("..") > -1:
473484
statusFile = open(tempStatusPath, 'w')
474485
statusFile.writelines("Specified path must be inside virtual host home." + " [404]")
475486
statusFile.close()
476-
return 0
487+
raise BaseException('Specified path must be inside virtual host home.')
477488

478489
if not os.path.exists(finalPath):
479-
command = 'sudo mkdir -p ' + finalPath
490+
command = 'mkdir -p ' + finalPath
480491
ProcessUtilities.executioner(command, externalApp)
481492

482493
## checking for directories/files
483494

484495
if self.dataLossCheck(finalPath, tempStatusPath) == 0:
485-
return 0
496+
raise BaseException('Directory is not empty.')
486497

487498
####
488499

@@ -517,7 +528,7 @@ def installPrestaShop(self):
517528
statusFile.writelines('Installing and configuring PrestaShop..,60')
518529
statusFile.close()
519530

520-
command = "sudo php " + finalPath + "install/index_cli.php --domain=" + finalURL + \
531+
command = "php " + finalPath + "install/index_cli.php --domain=" + finalURL + \
521532
" --db_server=localhost --db_name=" + dbName + " --db_user=" + dbUser + " --db_password=" + dbPassword \
522533
+ " --name='" + shopName + "' --firstname=" + firstName + " --lastname=" + lastName + \
523534
" --email=" + email + " --password=" + password
@@ -536,6 +547,10 @@ def installPrestaShop(self):
536547
command = "rm -f prestashop_1.7.4.2.zip"
537548
ProcessUtilities.executioner(command, externalApp)
538549

550+
permPath = '/home/%s/public_html' % (domainName)
551+
command = 'chmod 750 %s' % (permPath)
552+
ProcessUtilities.executioner(command)
553+
539554
statusFile = open(tempStatusPath, 'w')
540555
statusFile.writelines("Successfully Installed. [200]")
541556
statusFile.close()
@@ -558,6 +573,10 @@ def installPrestaShop(self):
558573
except:
559574
pass
560575

576+
permPath = '/home/%s/public_html' % (domainName)
577+
command = 'chmod 750 %s' % (permPath)
578+
ProcessUtilities.executioner(command)
579+
561580
statusFile = open(tempStatusPath, 'w')
562581
statusFile.writelines(str(msg) + " [404]")
563582
statusFile.close()
@@ -580,7 +599,7 @@ def setupGit(self):
580599
### Check git
581600

582601
try:
583-
command = 'sudo git --help'
602+
command = 'git --help'
584603
output = ProcessUtilities.outputExecutioner(command)
585604

586605
if output.find('command not found') > -1:
@@ -622,15 +641,19 @@ def setupGit(self):
622641
statusFile = open(tempStatusPath, 'w')
623642
statusFile.writelines("Specified path must be inside virtual host home." + " [404]")
624643
statusFile.close()
625-
return 0
644+
raise BaseException('Specified path must be inside virtual host home.')
626645

627-
command = 'sudo mkdir -p ' + finalPath
646+
permPath = '/home/%s/public_html' % (domainName)
647+
command = 'chmod 755 %s' % (permPath)
648+
ProcessUtilities.executioner(command)
649+
650+
command = 'mkdir -p ' + finalPath
628651
ProcessUtilities.executioner(command, externalApp)
629652

630653
## checking for directories/files
631654

632655
if self.dataLossCheck(finalPath, tempStatusPath) == 0:
633-
return 0
656+
raise BaseException('Directory is not empty.')
634657

635658
####
636659

@@ -668,14 +691,25 @@ def setupGit(self):
668691
writeToFile.write(username + ':' + reponame)
669692
writeToFile.close()
670693

694+
permPath = '/home/%s/public_html' % (domainName)
695+
command = 'chmod 750 %s' % (permPath)
696+
ProcessUtilities.executioner(command)
697+
671698
statusFile = open(tempStatusPath, 'w')
672699
statusFile.writelines("GIT Repository successfully attached. [200]")
673700
statusFile.close()
674701
return 0
675702

676703

677704
except BaseException as msg:
678-
os.remove('/home/cyberpanel/' + domainName + '.git')
705+
try:
706+
os.remove('/home/cyberpanel/' + domainName + '.git')
707+
except:
708+
pass
709+
710+
permPath = '/home/%s/public_html' % (domainName)
711+
command = 'chmod 750 %s' % (permPath)
712+
ProcessUtilities.executioner(command)
679713
statusFile = open(tempStatusPath, 'w')
680714
statusFile.writelines(str(msg) + " [404]")
681715
statusFile.close()
@@ -932,7 +966,7 @@ def installJoomla(self):
932966
pass
933967

934968
permPath = '/home/%s/public_html' % (domainName)
935-
command = 'chmod 755 %s' % (permPath)
969+
command = 'chmod 750 %s' % (permPath)
936970
ProcessUtilities.executioner(command)
937971

938972
statusFile = open(tempStatusPath, 'w')
@@ -957,11 +991,11 @@ def changeBranch(self):
957991
externalApp = childDomain.master.externalApp
958992

959993
try:
960-
command = 'sudo git --git-dir=' + finalPath + '/.git checkout -b ' + githubBranch
994+
command = 'git --git-dir=' + finalPath + '/.git checkout -b ' + githubBranch
961995
ProcessUtilities.executioner(command, externalApp)
962996
except:
963997
try:
964-
command = 'sudo git --git-dir=' + finalPath + '/.git checkout ' + githubBranch
998+
command = 'git --git-dir=' + finalPath + '/.git checkout ' + githubBranch
965999
ProcessUtilities.executioner(command, externalApp)
9661000
except subprocess.CalledProcessError as msg:
9671001
logging.writeToFile('Failed to change branch: ' + str(msg))
@@ -1052,14 +1086,18 @@ def installMagento(self):
10521086
statusFile.close()
10531087
return 0
10541088

1089+
permPath = '/home/%s/public_html' % (domainName)
1090+
command = 'chmod 755 %s' % (permPath)
1091+
ProcessUtilities.executioner(command)
1092+
10551093
if not os.path.exists(finalPath):
1056-
command = 'sudo mkdir -p ' + finalPath
1094+
command = 'mkdir -p ' + finalPath
10571095
ProcessUtilities.executioner(command, externalApp)
10581096

10591097
## checking for directories/files
10601098

10611099
if self.dataLossCheck(finalPath, tempStatusPath) == 0:
1062-
return 0
1100+
raise BaseException('Directory not empty.')
10631101

10641102
####
10651103

@@ -1068,9 +1106,9 @@ def installMagento(self):
10681106
statusFile.close()
10691107

10701108
if sampleData:
1071-
command = "sudo wget http://cyberpanelsh.b-cdn.net/latest-sample.tar.gz -P %s" % (finalPath)
1109+
command = "wget http://cyberpanelsh.b-cdn.net/latest-sample.tar.gz -P %s" % (finalPath)
10721110
else:
1073-
command = "sudo wget http://cyberpanelsh.b-cdn.net/latest.tar.gz -P %s" % (finalPath)
1111+
command = "wget http://cyberpanelsh.b-cdn.net/latest.tar.gz -P %s" % (finalPath)
10741112

10751113
ProcessUtilities.executioner(command, externalApp)
10761114

@@ -1122,6 +1160,10 @@ def installMagento(self):
11221160

11231161
installUtilities.reStartLiteSpeed()
11241162

1163+
permPath = '/home/%s/public_html' % (domainName)
1164+
command = 'chmod 750 %s' % (permPath)
1165+
ProcessUtilities.executioner(command)
1166+
11251167
statusFile = open(tempStatusPath, 'w')
11261168
statusFile.writelines("Successfully Installed. [200]")
11271169
statusFile.close()
@@ -1144,6 +1186,10 @@ def installMagento(self):
11441186
except:
11451187
pass
11461188

1189+
permPath = '/home/%s/public_html' % (domainName)
1190+
command = 'chmod 750 %s' % (permPath)
1191+
ProcessUtilities.executioner(command)
1192+
11471193
statusFile = open(tempStatusPath, 'w')
11481194
statusFile.writelines(str(msg) + " [404]")
11491195
statusFile.close()

0 commit comments

Comments
 (0)