Skip to content

Commit

Permalink
fix git attach
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Feb 22, 2020
1 parent f15619d commit e2021a6
Showing 1 changed file with 73 additions and 27 deletions.
100 changes: 73 additions & 27 deletions plogical/applicationInstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,10 @@ def installWPCLI(self):
except BaseException as msg:
logging.writeToFile(str(msg) + ' [ApplicationInstaller.installWPCLI]')

def dataLossCheck(self, finalPath, externalApp):
return 1
def dataLossCheck(self, finalPath, tempStatusPath):
dirFiles = os.listdir(finalPath)

command = 'ls -la %s' % (finalPath)
output = ProcessUtilities.outputExecutioner(command, 'nobody').splitlines()

logging.writeToFile(str(output))

if len(output) <= 3:
if len(dirFiles) <= 3:
return 1
else:
return 0
Expand All @@ -173,10 +168,10 @@ def installGit(self):
command = 'apt -y install git'
ProcessUtilities.executioner(command)
else:
command = 'sudo yum -y install http://repo.iotti.biz/CentOS/7/noarch/lux-release-7-1.noarch.rpm'
command = 'yum -y install http://repo.iotti.biz/CentOS/7/noarch/lux-release-7-1.noarch.rpm'
ProcessUtilities.executioner(command)

command = 'sudo yum install git -y'
command = 'yum install git -y'
ProcessUtilities.executioner(command)

except BaseException as msg:
Expand Down Expand Up @@ -302,6 +297,10 @@ def installWordPress(self):

## Security Check

permPath = '/home/%s/public_html' % (domainName)
command = 'chmod 755 %s' % (permPath)
ProcessUtilities.executioner(command)

if finalPath.find("..") > -1:
statusFile = open(tempStatusPath, 'w')
statusFile.writelines("Specified path must be inside virtual host home." + " [404]")
Expand All @@ -315,7 +314,7 @@ def installWordPress(self):
## checking for directories/files

if self.dataLossCheck(finalPath, tempStatusPath) == 0:
return 0
raise BaseException('Directory is not empty.')

####

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

permPath = '/home/%s/public_html' % (domainName)
command = 'chmod 750 %s' % (permPath)
ProcessUtilities.executioner(command)

statusFile = open(tempStatusPath, 'w')
statusFile.writelines("Successfully Installed. [200]")
statusFile.close()
Expand All @@ -388,6 +391,10 @@ def installWordPress(self):
except:
pass

permPath = '/home/%s/public_html' % (domainName)
command = 'chmod 750 %s' % (permPath)
ProcessUtilities.executioner(command)

statusFile = open(tempStatusPath, 'w')
statusFile.writelines(str(msg) + " [404]")
statusFile.close()
Expand Down Expand Up @@ -469,20 +476,24 @@ def installPrestaShop(self):

## Security Check

permPath = '/home/%s/public_html' % (domainName)
command = 'chmod 755 %s' % (permPath)
ProcessUtilities.executioner(command)

if finalPath.find("..") > -1:
statusFile = open(tempStatusPath, 'w')
statusFile.writelines("Specified path must be inside virtual host home." + " [404]")
statusFile.close()
return 0
raise BaseException('Specified path must be inside virtual host home.')

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

## checking for directories/files

if self.dataLossCheck(finalPath, tempStatusPath) == 0:
return 0
raise BaseException('Directory is not empty.')

####

Expand Down Expand Up @@ -517,7 +528,7 @@ def installPrestaShop(self):
statusFile.writelines('Installing and configuring PrestaShop..,60')
statusFile.close()

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

permPath = '/home/%s/public_html' % (domainName)
command = 'chmod 750 %s' % (permPath)
ProcessUtilities.executioner(command)

statusFile = open(tempStatusPath, 'w')
statusFile.writelines("Successfully Installed. [200]")
statusFile.close()
Expand All @@ -558,6 +573,10 @@ def installPrestaShop(self):
except:
pass

permPath = '/home/%s/public_html' % (domainName)
command = 'chmod 750 %s' % (permPath)
ProcessUtilities.executioner(command)

statusFile = open(tempStatusPath, 'w')
statusFile.writelines(str(msg) + " [404]")
statusFile.close()
Expand All @@ -580,7 +599,7 @@ def setupGit(self):
### Check git

try:
command = 'sudo git --help'
command = 'git --help'
output = ProcessUtilities.outputExecutioner(command)

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

command = 'sudo mkdir -p ' + finalPath
permPath = '/home/%s/public_html' % (domainName)
command = 'chmod 755 %s' % (permPath)
ProcessUtilities.executioner(command)

command = 'mkdir -p ' + finalPath
ProcessUtilities.executioner(command, externalApp)

## checking for directories/files

if self.dataLossCheck(finalPath, tempStatusPath) == 0:
return 0
raise BaseException('Directory is not empty.')

####

Expand Down Expand Up @@ -668,14 +691,25 @@ def setupGit(self):
writeToFile.write(username + ':' + reponame)
writeToFile.close()

permPath = '/home/%s/public_html' % (domainName)
command = 'chmod 750 %s' % (permPath)
ProcessUtilities.executioner(command)

statusFile = open(tempStatusPath, 'w')
statusFile.writelines("GIT Repository successfully attached. [200]")
statusFile.close()
return 0


except BaseException as msg:
os.remove('/home/cyberpanel/' + domainName + '.git')
try:
os.remove('/home/cyberpanel/' + domainName + '.git')
except:
pass

permPath = '/home/%s/public_html' % (domainName)
command = 'chmod 750 %s' % (permPath)
ProcessUtilities.executioner(command)
statusFile = open(tempStatusPath, 'w')
statusFile.writelines(str(msg) + " [404]")
statusFile.close()
Expand Down Expand Up @@ -932,7 +966,7 @@ def installJoomla(self):
pass

permPath = '/home/%s/public_html' % (domainName)
command = 'chmod 755 %s' % (permPath)
command = 'chmod 750 %s' % (permPath)
ProcessUtilities.executioner(command)

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

try:
command = 'sudo git --git-dir=' + finalPath + '/.git checkout -b ' + githubBranch
command = 'git --git-dir=' + finalPath + '/.git checkout -b ' + githubBranch
ProcessUtilities.executioner(command, externalApp)
except:
try:
command = 'sudo git --git-dir=' + finalPath + '/.git checkout ' + githubBranch
command = 'git --git-dir=' + finalPath + '/.git checkout ' + githubBranch
ProcessUtilities.executioner(command, externalApp)
except subprocess.CalledProcessError as msg:
logging.writeToFile('Failed to change branch: ' + str(msg))
Expand Down Expand Up @@ -1052,14 +1086,18 @@ def installMagento(self):
statusFile.close()
return 0

permPath = '/home/%s/public_html' % (domainName)
command = 'chmod 755 %s' % (permPath)
ProcessUtilities.executioner(command)

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

## checking for directories/files

if self.dataLossCheck(finalPath, tempStatusPath) == 0:
return 0
raise BaseException('Directory not empty.')

####

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

if sampleData:
command = "sudo wget http://cyberpanelsh.b-cdn.net/latest-sample.tar.gz -P %s" % (finalPath)
command = "wget http://cyberpanelsh.b-cdn.net/latest-sample.tar.gz -P %s" % (finalPath)
else:
command = "sudo wget http://cyberpanelsh.b-cdn.net/latest.tar.gz -P %s" % (finalPath)
command = "wget http://cyberpanelsh.b-cdn.net/latest.tar.gz -P %s" % (finalPath)

ProcessUtilities.executioner(command, externalApp)

Expand Down Expand Up @@ -1122,6 +1160,10 @@ def installMagento(self):

installUtilities.reStartLiteSpeed()

permPath = '/home/%s/public_html' % (domainName)
command = 'chmod 750 %s' % (permPath)
ProcessUtilities.executioner(command)

statusFile = open(tempStatusPath, 'w')
statusFile.writelines("Successfully Installed. [200]")
statusFile.close()
Expand All @@ -1144,6 +1186,10 @@ def installMagento(self):
except:
pass

permPath = '/home/%s/public_html' % (domainName)
command = 'chmod 750 %s' % (permPath)
ProcessUtilities.executioner(command)

statusFile = open(tempStatusPath, 'w')
statusFile.writelines(str(msg) + " [404]")
statusFile.close()
Expand Down

0 comments on commit e2021a6

Please sign in to comment.