Skip to content

Commit 0af4297

Browse files
author
usmannasir
committed
Attach GIT repositories to websites!
1 parent e62c9f7 commit 0af4297

File tree

12 files changed

+743
-12
lines changed

12 files changed

+743
-12
lines changed

README.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,13 @@ Webhosting control panel that uses OpenLiteSpeed as web server.
2323
* PHP 5.6
2424
* PHP 7.0
2525
* PHP 7.1
26-
26+
* PHP 7.2
2727

2828
# Installation Instructions
2929

3030

3131
```
32-
wget http://cyberpanel.net/install.tar.gz
33-
tar zxf install.tar.gz
34-
cd install
35-
chmod +x install.py
36-
python install.py [IP Address]
32+
sh <(curl https://cyberpanel.net/install.sh || wget -O - https://cyberpanel.net/install.sh)
3733
```
3834

3935
# Resources

plogical/applicationInstaller.py

+156
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def run(self):
3131
self.installWordPress()
3232
elif self.installApp == 'joomla':
3333
self.installJoomla()
34+
elif self.installApp == 'git':
35+
self.setupGit()
3436

3537
except BaseException, msg:
3638
logging.writeToFile( str(msg) + ' [ApplicationInstaller.run]')
@@ -50,6 +52,18 @@ def installWPCLI(self):
5052
except BaseException, msg:
5153
logging.writeToFile( str(msg) + ' [ApplicationInstaller.installWPCLI]')
5254

55+
def installGit(self, tempStatusPath):
56+
try:
57+
58+
command = 'sudo yum -y install http://repo.iotti.biz/CentOS/7/noarch/lux-release-7-1.noarch.rpm'
59+
subprocess.call(shlex.split(command))
60+
61+
command = 'sudo yum install git -y'
62+
subprocess.call(shlex.split(command))
63+
64+
except BaseException, msg:
65+
logging.writeToFile( str(msg) + ' [ApplicationInstaller.installGit]')
66+
5367

5468
def installWordPress(self):
5569
try:
@@ -292,6 +306,148 @@ def installWordPress(self):
292306
return 0
293307

294308

309+
def setupGit(self):
310+
try:
311+
admin = self.extraArgs['admin']
312+
domainName = self.extraArgs['domainName']
313+
username = self.extraArgs['username']
314+
reponame = self.extraArgs['reponame']
315+
branch = self.extraArgs['branch']
316+
tempStatusPath = self.extraArgs['tempStatusPath']
317+
318+
statusFile = open(tempStatusPath, 'w')
319+
statusFile.writelines('Checking if GIT installed..,0')
320+
statusFile.close()
321+
322+
finalPath = "/home/" + domainName + "/public_html/"
323+
324+
325+
### Check git
326+
327+
try:
328+
command = 'sudo /usr/local/bin/git --help'
329+
res = subprocess.call(shlex.split(command))
330+
331+
if res == 1:
332+
statusFile = open(tempStatusPath, 'w')
333+
statusFile.writelines('Installing GIT..,0')
334+
statusFile.close()
335+
self.installGit(tempStatusPath)
336+
statusFile = open(tempStatusPath, 'w')
337+
statusFile.writelines('GIT successfully installed,40')
338+
statusFile.close()
339+
except subprocess.CalledProcessError:
340+
statusFile = open(tempStatusPath, 'w')
341+
statusFile.writelines('Installing GIT..,0')
342+
statusFile.close()
343+
self.installGit(tempStatusPath)
344+
statusFile = open(tempStatusPath, 'w')
345+
statusFile.writelines('GIT successfully installed.,40')
346+
statusFile.close()
347+
348+
## Open Status File
349+
350+
statusFile = open(tempStatusPath, 'w')
351+
statusFile.writelines('Setting up directories..,40')
352+
statusFile.close()
353+
354+
try:
355+
website = ChildDomains.objects.get(domain=domainName)
356+
externalApp = website.master.externalApp
357+
358+
if admin.type != 1:
359+
if website.master.admin != admin:
360+
statusFile = open(tempStatusPath, 'w')
361+
statusFile.writelines("You do not own this website." + " [404]")
362+
statusFile.close()
363+
return 0
364+
365+
except:
366+
website = Websites.objects.get(domain=domainName)
367+
externalApp = website.externalApp
368+
369+
if admin.type != 1:
370+
if website.admin != admin:
371+
statusFile = open(tempStatusPath, 'w')
372+
statusFile.writelines("You do not own this website." + " [404]")
373+
statusFile.close()
374+
return 0
375+
376+
## Security Check
377+
378+
if finalPath.find("..") > -1:
379+
statusFile = open(tempStatusPath, 'w')
380+
statusFile.writelines("Specified path must be inside virtual host home." + " [404]")
381+
statusFile.close()
382+
return 0
383+
384+
FNULL = open(os.devnull, 'w')
385+
386+
if not os.path.exists(finalPath):
387+
command = 'sudo mkdir -p ' + finalPath
388+
subprocess.call(shlex.split(command))
389+
390+
## checking for directories/files
391+
392+
dirFiles = os.listdir(finalPath)
393+
394+
if len(dirFiles) == 1:
395+
if dirFiles[0] == ".well-known":
396+
pass
397+
else:
398+
statusFile = open(tempStatusPath, 'w')
399+
statusFile.writelines("Target directory should be empty before installation, otherwise data loss could occur." + " [404]")
400+
statusFile.close()
401+
return 0
402+
elif len(dirFiles) == 0:
403+
pass
404+
else:
405+
statusFile = open(tempStatusPath, 'w')
406+
statusFile.writelines(
407+
"Target directory should be empty before installation, otherwise data loss could occur." + " [404]")
408+
statusFile.close()
409+
return 0
410+
411+
####
412+
413+
statusFile = open(tempStatusPath, 'w')
414+
statusFile.writelines('Cloning the repo..,40')
415+
statusFile.close()
416+
417+
try:
418+
419+
command = 'sudo GIT_SSH_COMMAND="ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no" /usr/local/bin/git clone ' \
420+
'--depth 1 --no-single-branch [email protected]:' + username + '/' + reponame + '.git -b ' + branch + ' ' + finalPath
421+
subprocess.call(shlex.split(command))
422+
423+
except subprocess.CalledProcessError, msg:
424+
statusFile = open(tempStatusPath, 'w')
425+
statusFile.writelines('Failed to clone repository. [404]')
426+
statusFile.close()
427+
return 0
428+
429+
##
430+
431+
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath
432+
cmd = shlex.split(command)
433+
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
434+
435+
vhost.addRewriteRules(domainName)
436+
installUtilities.reStartLiteSpeed()
437+
438+
statusFile = open(tempStatusPath, 'w')
439+
statusFile.writelines("Successfully Installed. [200]")
440+
statusFile.close()
441+
return 0
442+
443+
444+
except BaseException, msg:
445+
statusFile = open(tempStatusPath, 'w')
446+
statusFile.writelines(str(msg) + " [404]")
447+
statusFile.close()
448+
return 0
449+
450+
295451
def installJoomla(self):
296452

297453
try:

plogical/sslUtilities.py

-2
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ def obtainSSLForADomain(virtualHostName,adminEmail,sslpath, aliasDomain = None):
196196
logging.CyberCPLogFileWriter.writeToFile('Failed to obtain SSL, issuing self-signed SSL for: ' + virtualHostName)
197197
return 0
198198

199-
logging.CyberCPLogFileWriter.writeToFile(command)
200-
201199
pathToStoreSSL = sslUtilities.Server_root + "/conf/vhosts/" + "SSL-" + virtualHostName
202200

203201
if not os.path.exists(pathToStoreSSL):

plogical/upgrade.py

+7
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ def setupCLI():
253253
if count == 3:
254254
Upgrade.stdOut(
255255
"Failed to setup CLI! [setupCLI]")
256+
break
256257
else:
257258
Upgrade.stdOut("CLI setup successfull!")
258259
break
@@ -314,14 +315,20 @@ def upgrade():
314315

315316
os.chdir("/usr/local")
316317

318+
319+
317320
## Current Version
318321

319322
Version = version.objects.get(pk=1)
320323

324+
321325
##
322326

323327
versionNumbring = Upgrade.downloadLink()
324328

329+
if os.path.exists('/usr/local/CyberPanel.' + versionNumbring):
330+
os.remove('/usr/local/CyberPanel.' + versionNumbring)
331+
325332
if float(Version.currentVersion) < 1.6:
326333
Upgrade.stdOut('Upgrades works for version 1.6 onwards.')
327334
os._exit(0)

static/images/icons/git-logo.png

1.83 KB
Loading

0 commit comments

Comments
 (0)