diff --git a/filemanager/filemanager.py b/filemanager/filemanager.py index a0418f7d2..1417e28e6 100755 --- a/filemanager/filemanager.py +++ b/filemanager/filemanager.py @@ -491,4 +491,30 @@ class FileManager: return HttpResponse(json_data) except BaseException as msg: - return self.ajaxPre(0, str(msg)) \ No newline at end of file + 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) \ No newline at end of file diff --git a/filemanager/views.py b/filemanager/views.py index 838759f91..cf91e7d42 100755 --- a/filemanager/views.py +++ b/filemanager/views.py @@ -44,35 +44,13 @@ def changePermissions(request): else: return ACLManager.loadErrorJson('permissionsChanged', 0) - 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) + fm = FM(request, data) + fm.fixPermissions(domainName) data_ret = {'permissionsChanged': 1, 'error_message': "None"} json_data = json.dumps(data_ret) return HttpResponse(json_data) - except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) data_ret = {'permissionsChanged': 0, 'error_message': str(msg)} diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index 98eb1f90c..8269cd594 100755 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -19,8 +19,6 @@ import shutil from plogical.mailUtilities import mailUtilities from plogical.processUtilities import ProcessUtilities - - class ApplicationInstaller(multi.Thread): def __init__(self, installApp, extraArgs): @@ -142,13 +140,13 @@ class ApplicationInstaller(multi.Thread): def installWPCLI(self): 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) - command = 'sudo chmod +x wp-cli.phar' + command = 'chmod +x wp-cli.phar' ProcessUtilities.executioner(command) - command = 'sudo mv wp-cli.phar /usr/bin/wp' + command = 'mv wp-cli.phar /usr/bin/wp' ProcessUtilities.executioner(command) except BaseException as msg: diff --git a/websiteFunctions/templates/websiteFunctions/manageGIT.html b/websiteFunctions/templates/websiteFunctions/manageGIT.html new file mode 100755 index 000000000..c0debbc16 --- /dev/null +++ b/websiteFunctions/templates/websiteFunctions/manageGIT.html @@ -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 %} + + +
+
+

{% trans "Manage GIT" %}

+

{% trans "Manage and track folders via Git for " %} {{ domainName }}.

+
+ + +
+
+

+ {% trans "Manage and track folders via Git for " %} {{ domainName }}. +

+
+
+
+ +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + +
FolderRemoteBranchStatusManage
+
+
+
+ + +
+ + +{% endblock %} \ No newline at end of file diff --git a/websiteFunctions/templates/websiteFunctions/website.html b/websiteFunctions/templates/websiteFunctions/website.html index c54555cc4..ded7524f3 100755 --- a/websiteFunctions/templates/websiteFunctions/website.html +++ b/websiteFunctions/templates/websiteFunctions/website.html @@ -26,6 +26,9 @@

{% trans "Resource Usage" %} + + {% trans "Manage Git" %} + {% trans "Clone/Staging" %} @@ -33,7 +36,6 @@ href="/websites/{{ domain }}/sshAccess" title="">{% trans "Set up SSH Access" %}

-
@@ -107,6 +109,7 @@
+ diff --git a/websiteFunctions/urls.py b/websiteFunctions/urls.py index fd0979829..4e0b9a62e 100755 --- a/websiteFunctions/urls.py +++ b/websiteFunctions/urls.py @@ -117,6 +117,10 @@ urlpatterns = [ url(r'^detachRepo$', views.detachRepo, name='detachRepo'), url(r'^changeBranch$', views.changeBranch, name='changeBranch'), + ### Manage GIT + + url(r'^(?P(.*))/manageGIT$', views.manageGIT, name='manageGIT'), + ## Catch all for domains url(r'^(?P(.*))/(?P(.*))$', views.launchChild, name='launchChild'), url(r'^(?P(.*))$', views.domain, name='domain'), diff --git a/websiteFunctions/views.py b/websiteFunctions/views.py index 02aeb7b0e..786cbcce3 100755 --- a/websiteFunctions/views.py +++ b/websiteFunctions/views.py @@ -705,5 +705,23 @@ def startSync(request): userID = request.session['userID'] wm = WebsiteManager() return wm.startSync(userID, json.loads(request.body)) + except KeyError: + 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) \ No newline at end of file diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index edf5f9105..847fa3337 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -2869,3 +2869,29 @@ StrictHostKeyChecking no data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) 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))