mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-06 21:35:55 +01:00
git manager initial
This commit is contained in:
@@ -492,3 +492,29 @@ class FileManager:
|
|||||||
|
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
return self.ajaxPre(0, str(msg))
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def fixPermissions(self, domainName):
|
||||||
|
|
||||||
|
website = Websites.objects.get(domain=domainName)
|
||||||
|
externalApp = website.externalApp
|
||||||
|
|
||||||
|
command = 'chown -R %s:%s /home/%s/public_html/*' % (externalApp, externalApp, domainName)
|
||||||
|
ProcessUtilities.popenExecutioner(command)
|
||||||
|
|
||||||
|
command = 'chown -R %s:%s /home/%s/public_html/.[^.]*' % (externalApp, externalApp, domainName)
|
||||||
|
ProcessUtilities.popenExecutioner(command)
|
||||||
|
|
||||||
|
command = "chown root:nobody /home/" + domainName + "/logs"
|
||||||
|
ProcessUtilities.popenExecutioner(command)
|
||||||
|
|
||||||
|
command = "find %s -type d -exec chmod 0755 {} \;" % ("/home/" + domainName + "/public_html")
|
||||||
|
ProcessUtilities.popenExecutioner(command)
|
||||||
|
|
||||||
|
command = "find %s -type f -exec chmod 0644 {} \;" % ("/home/" + domainName + "/public_html")
|
||||||
|
ProcessUtilities.popenExecutioner(command)
|
||||||
|
|
||||||
|
command = 'chown %s:nobody /home/%s/public_html' % (externalApp, domainName)
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
|
command = 'chmod 750 /home/%s/public_html' % (domainName)
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
@@ -44,35 +44,13 @@ def changePermissions(request):
|
|||||||
else:
|
else:
|
||||||
return ACLManager.loadErrorJson('permissionsChanged', 0)
|
return ACLManager.loadErrorJson('permissionsChanged', 0)
|
||||||
|
|
||||||
website = Websites.objects.get(domain=domainName)
|
fm = FM(request, data)
|
||||||
externalApp = website.externalApp
|
fm.fixPermissions(domainName)
|
||||||
|
|
||||||
command = 'chown -R %s:%s /home/%s/public_html/*' % (externalApp, externalApp, domainName)
|
|
||||||
ProcessUtilities.popenExecutioner(command)
|
|
||||||
|
|
||||||
command = 'chown -R %s:%s /home/%s/public_html/.[^.]*' % (externalApp, externalApp, domainName)
|
|
||||||
ProcessUtilities.popenExecutioner(command)
|
|
||||||
|
|
||||||
command = "chown root:nobody /home/" + domainName+"/logs"
|
|
||||||
ProcessUtilities.popenExecutioner(command)
|
|
||||||
|
|
||||||
command = "find %s -type d -exec chmod 0755 {} \;" % ("/home/" + domainName + "/public_html")
|
|
||||||
ProcessUtilities.popenExecutioner(command)
|
|
||||||
|
|
||||||
command = "find %s -type f -exec chmod 0644 {} \;" % ("/home/" + domainName + "/public_html")
|
|
||||||
ProcessUtilities.popenExecutioner(command)
|
|
||||||
|
|
||||||
command = 'chown %s:nobody /home/%s/public_html' % (externalApp, domainName)
|
|
||||||
ProcessUtilities.executioner(command)
|
|
||||||
|
|
||||||
command = 'chmod 750 /home/%s/public_html' % (domainName)
|
|
||||||
ProcessUtilities.executioner(command)
|
|
||||||
|
|
||||||
data_ret = {'permissionsChanged': 1, 'error_message': "None"}
|
data_ret = {'permissionsChanged': 1, 'error_message': "None"}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||||
data_ret = {'permissionsChanged': 0, 'error_message': str(msg)}
|
data_ret = {'permissionsChanged': 0, 'error_message': str(msg)}
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ import shutil
|
|||||||
from plogical.mailUtilities import mailUtilities
|
from plogical.mailUtilities import mailUtilities
|
||||||
from plogical.processUtilities import ProcessUtilities
|
from plogical.processUtilities import ProcessUtilities
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ApplicationInstaller(multi.Thread):
|
class ApplicationInstaller(multi.Thread):
|
||||||
|
|
||||||
def __init__(self, installApp, extraArgs):
|
def __init__(self, installApp, extraArgs):
|
||||||
@@ -142,13 +140,13 @@ class ApplicationInstaller(multi.Thread):
|
|||||||
|
|
||||||
def installWPCLI(self):
|
def installWPCLI(self):
|
||||||
try:
|
try:
|
||||||
command = 'sudo wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar'
|
command = 'wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar'
|
||||||
ProcessUtilities.executioner(command)
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
command = 'sudo chmod +x wp-cli.phar'
|
command = 'chmod +x wp-cli.phar'
|
||||||
ProcessUtilities.executioner(command)
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
command = 'sudo mv wp-cli.phar /usr/bin/wp'
|
command = 'mv wp-cli.phar /usr/bin/wp'
|
||||||
ProcessUtilities.executioner(command)
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
|
|||||||
64
websiteFunctions/templates/websiteFunctions/manageGIT.html
Executable file
64
websiteFunctions/templates/websiteFunctions/manageGIT.html
Executable file
@@ -0,0 +1,64 @@
|
|||||||
|
{% extends "baseTemplate/index.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% block title %}{% trans "Manage Git - CyberPanel" %}{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% load static %}
|
||||||
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
|
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div id="page-title">
|
||||||
|
<h2>{% trans "Manage GIT" %}</h2>
|
||||||
|
<p>{% trans "Manage and track folders via Git for " %} {{ domainName }}.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div ng-controller="sshAccess" class="panel">
|
||||||
|
<div class="panel-body">
|
||||||
|
<h3 class="title-hero">
|
||||||
|
{% trans "Manage and track folders via Git for " %} {{ domainName }}.</span> <img
|
||||||
|
ng-hide="wpInstallLoading" src="{% static 'images/loading.gif' %}">
|
||||||
|
</h3>
|
||||||
|
<div class="example-box-wrapper">
|
||||||
|
<form action="/" class="form-horizontal bordered-row">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Select Website" %} </label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<select ng-change="showFTPDetails()" ng-model="ftpDomain" class="form-control">
|
||||||
|
{% for item in folders %}
|
||||||
|
<option>{{ item }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Folder</th>
|
||||||
|
<th>Remote</th>
|
||||||
|
<th>Branch</th>
|
||||||
|
<th>Status</th>
|
||||||
|
<th>Manage</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr ng-repeat="record in records | filter:logSearch">
|
||||||
|
<td ng-bind="record.domain"></td>
|
||||||
|
<td ng-bind="record.ipAddress"></td>
|
||||||
|
<td ng-bind="record.time"></td>
|
||||||
|
<td ng-bind="record.resource"></td>
|
||||||
|
<td ng-bind="record.size"></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -26,6 +26,9 @@
|
|||||||
|
|
||||||
<h3 class="content-box-header">
|
<h3 class="content-box-header">
|
||||||
{% trans "Resource Usage" %} <img ng-hide="domainLoading" src="/static/images/loading.gif">
|
{% trans "Resource Usage" %} <img ng-hide="domainLoading" src="/static/images/loading.gif">
|
||||||
|
|
||||||
|
<a style="float: right; margin-left: 2%" class="btn btn-border btn-alt border-orange btn-link font-orange" href="/websites/{{ domain }}/manageGIT" title="Manage Git"><span>{% trans "Manage Git" %}</span></a>
|
||||||
|
|
||||||
<a style="float: right; margin-left: 2%"
|
<a style="float: right; margin-left: 2%"
|
||||||
class="btn btn-border btn-alt border-azure btn-link font-azure"
|
class="btn btn-border btn-alt border-azure btn-link font-azure"
|
||||||
href="/websites/{{ domain }}/setupStaging" title=""><span>{% trans "Clone/Staging" %}</span></a>
|
href="/websites/{{ domain }}/setupStaging" title=""><span>{% trans "Clone/Staging" %}</span></a>
|
||||||
@@ -33,7 +36,6 @@
|
|||||||
href="/websites/{{ domain }}/sshAccess" title=""><span>{% trans "Set up SSH Access" %}</span></a>
|
href="/websites/{{ domain }}/sshAccess" title=""><span>{% trans "Set up SSH Access" %}</span></a>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
|
|
||||||
<div class="content-box-wrapper">
|
<div class="content-box-wrapper">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
@@ -107,6 +109,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,10 @@ urlpatterns = [
|
|||||||
url(r'^detachRepo$', views.detachRepo, name='detachRepo'),
|
url(r'^detachRepo$', views.detachRepo, name='detachRepo'),
|
||||||
url(r'^changeBranch$', views.changeBranch, name='changeBranch'),
|
url(r'^changeBranch$', views.changeBranch, name='changeBranch'),
|
||||||
|
|
||||||
|
### Manage GIT
|
||||||
|
|
||||||
|
url(r'^(?P<domain>(.*))/manageGIT$', views.manageGIT, name='manageGIT'),
|
||||||
|
|
||||||
## Catch all for domains
|
## Catch all for domains
|
||||||
url(r'^(?P<domain>(.*))/(?P<childDomain>(.*))$', views.launchChild, name='launchChild'),
|
url(r'^(?P<domain>(.*))/(?P<childDomain>(.*))$', views.launchChild, name='launchChild'),
|
||||||
url(r'^(?P<domain>(.*))$', views.domain, name='domain'),
|
url(r'^(?P<domain>(.*))$', views.domain, name='domain'),
|
||||||
|
|||||||
@@ -707,3 +707,21 @@ def startSync(request):
|
|||||||
return wm.startSync(userID, json.loads(request.body))
|
return wm.startSync(userID, json.loads(request.body))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
|
### Manage GIT
|
||||||
|
|
||||||
|
def manageGIT(request, domain):
|
||||||
|
try:
|
||||||
|
|
||||||
|
if not request.GET._mutable:
|
||||||
|
request.GET._mutable = True
|
||||||
|
|
||||||
|
request.GET['domain'] = domain
|
||||||
|
|
||||||
|
userID = request.session['userID']
|
||||||
|
wm = WebsiteManager(domain)
|
||||||
|
return wm.manageGIT(request, userID)
|
||||||
|
|
||||||
|
except KeyError:
|
||||||
|
return redirect(loadLoginPage)
|
||||||
@@ -2869,3 +2869,29 @@ StrictHostKeyChecking no
|
|||||||
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
def manageGIT(self, request=None, userID=None, data=None):
|
||||||
|
try:
|
||||||
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
|
||||||
|
if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return ACLManager.loadError()
|
||||||
|
|
||||||
|
website = Websites.objects.get(domain=self.domain)
|
||||||
|
externalApp = website.externalApp
|
||||||
|
|
||||||
|
folders = ['/home/%s' % (self.domain), '/home/vmail/%s' % (self.domain)]
|
||||||
|
|
||||||
|
databases = website.databases_set.all()
|
||||||
|
|
||||||
|
for database in databases:
|
||||||
|
basePath = '/var/lib/mysql/'
|
||||||
|
folders.append('%s%s' % (basePath, database.dbName))
|
||||||
|
|
||||||
|
return render(request, 'websiteFunctions/manageGIT.html',
|
||||||
|
{'domainName': self.domain, 'folders': folders})
|
||||||
|
except BaseException as msg:
|
||||||
|
return HttpResponse(str(msg))
|
||||||
|
|||||||
Reference in New Issue
Block a user