diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html index 0b59ee3f8..e4c97e231 100755 --- a/baseTemplate/templates/baseTemplate/index.html +++ b/baseTemplate/templates/baseTemplate/index.html @@ -41,6 +41,7 @@ + diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index a56136cc9..c60d23f84 100644 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -313,6 +313,7 @@ class ApplicationInstaller(multi.Thread): reponame = self.extraArgs['reponame'] branch = self.extraArgs['branch'] tempStatusPath = self.extraArgs['tempStatusPath'] + defaultProvider = self.extraArgs['defaultProvider'] statusFile = open(tempStatusPath, 'w') statusFile.writelines('Checking if GIT installed..,0') @@ -416,7 +417,7 @@ class ApplicationInstaller(multi.Thread): try: command = 'sudo GIT_SSH_COMMAND="ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no" git clone ' \ - '--depth 1 --no-single-branch git@github.com:' + username + '/' + reponame + '.git -b ' + branch + ' ' + finalPath + '--depth 1 --no-single-branch git@' + defaultProvider +'.com:' + username + '/' + reponame + '.git -b ' + branch + ' ' + finalPath result = subprocess.check_output(shlex.split(command)) except subprocess.CalledProcessError, msg: diff --git a/static/websiteFunctions/websiteFunctions.js b/static/websiteFunctions/websiteFunctions.js index 58eb5d8d7..3bf3ce938 100644 --- a/static/websiteFunctions/websiteFunctions.js +++ b/static/websiteFunctions/websiteFunctions.js @@ -4247,6 +4247,12 @@ app.controller('setupGit', function($scope, $http, $timeout) { $scope.installProg = true; $scope.goBackDisable = true; + var defaultProvider = 'github'; + + $scope.setProvider = function (provider) { + defaultProvider = provider; + }; + var statusFile; var domain = $("#domainNamePage").text(); @@ -4284,7 +4290,7 @@ app.controller('setupGit', function($scope, $http, $timeout) { $scope.installationSuccessfull = false; $scope.couldNotConnect = true; $scope.gitLoading = true; - $scope.goBackDisable = false; + $scope.goBackDisable = true; $scope.installationURL = domain; @@ -4355,7 +4361,8 @@ app.controller('setupGit', function($scope, $http, $timeout) { domain: domain, username: $scope.githubUserName, reponame: $scope.githubRepo, - branch: $scope.githubBranch + branch: $scope.githubBranch, + defaultProvider: defaultProvider }; var config = { diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js index f571456f0..3bf3ce938 100644 --- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js +++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js @@ -4247,6 +4247,12 @@ app.controller('setupGit', function($scope, $http, $timeout) { $scope.installProg = true; $scope.goBackDisable = true; + var defaultProvider = 'github'; + + $scope.setProvider = function (provider) { + defaultProvider = provider; + }; + var statusFile; var domain = $("#domainNamePage").text(); @@ -4355,7 +4361,8 @@ app.controller('setupGit', function($scope, $http, $timeout) { domain: domain, username: $scope.githubUserName, reponame: $scope.githubRepo, - branch: $scope.githubBranch + branch: $scope.githubBranch, + defaultProvider: defaultProvider }; var config = { diff --git a/websiteFunctions/templates/websiteFunctions/setupGit.html b/websiteFunctions/templates/websiteFunctions/setupGit.html index 0b30fe638..2badea094 100644 --- a/websiteFunctions/templates/websiteFunctions/setupGit.html +++ b/websiteFunctions/templates/websiteFunctions/setupGit.html @@ -13,7 +13,9 @@

{% trans "Attach git to your website" %}

-
+ {% if not installed %} + +

{{ domainName }} - {% trans "Attach Git" %} @@ -24,7 +26,7 @@
  • - {% trans "Github" %} + {% trans "Providers" %}
  • @@ -42,6 +44,23 @@
    + +
    @@ -49,7 +68,7 @@
    - +
    @@ -173,6 +192,102 @@
    + {% else %} + +
    +
    +

    + {{ domainName }} +

    + +
    + +
    +
    + +
    +

    {% trans 'Webhook URL' %}

    +

    {% trans "Add this URL to Webhooks section of your Git respository, if you've used hostname SSL then replace IP with your hostname. Otherwise use IP and disable SSL check while configuring webhook. This will initiate a pull from your resposity as soon as you commit some changes."%} {{ webhookURL }}

    +
    +
    + + + +
    + + + +
    + +
    + +
    + +
    + + +
    + +
    + + +
    +
    + +
    + +
    + +
    +

    {% trans "Error message:" %} {$ errorMessage $}

    +
    + +
    +

    {% trans "Branch successfully changed." %}

    +
    + + + +
    +

    {% trans "Could not connect to server. Please refresh this page." %}

    +
    + +
    +
    + + + + +
    +
    +
    +
    +
    + + {% endif %} +
    diff --git a/websiteFunctions/views.py b/websiteFunctions/views.py index 0a43cfee5..5f2aa1250 100644 --- a/websiteFunctions/views.py +++ b/websiteFunctions/views.py @@ -2511,10 +2511,24 @@ def setupGit(request, domain): if website.admin != admin: raise BaseException('You do not own this website.') - command = 'sudo cat /root/.ssh/cyberpanel.pub' - deploymentKey = subprocess.check_output(shlex.split(command)).strip('\n') - return render(request, 'websiteFunctions/setupGit.html', {'domainName' : domain, 'deploymentKey': deploymentKey}) + path = '/home/cyberpanel/' + domain + '.git' + + if os.path.exists(path): + + ipFile = "/etc/cyberpanel/machineIP" + f = open(ipFile) + ipData = f.read() + ipAddress = ipData.split('\n', 1)[0] + + webhookURL = 'https://' + ipAddress + ':8090/websites/' + domain + '/gitNotify' + return render(request, 'websiteFunctions/setupGit.html', + {'domainName': domain, 'installed': 1, 'webhookURL': webhookURL}) + else: + command = 'sudo cat /root/.ssh/cyberpanel.pub' + deploymentKey = subprocess.check_output(shlex.split(command)).strip('\n') + + return render(request, 'websiteFunctions/setupGit.html', {'domainName' : domain, 'deploymentKey': deploymentKey, 'installed': 0}) except BaseException, msg: logging.CyberCPLogFileWriter.writeToFile(str(msg)) return HttpResponse(str(msg)) @@ -2539,6 +2553,7 @@ def setupGitRepo(request): extraArgs['reponame'] = data['reponame'] extraArgs['branch'] = data['branch'] extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999)) + extraArgs['defaultProvider'] = data['defaultProvider'] background = ApplicationInstaller('git', extraArgs)