mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
bug fix: add path to git commands
This commit is contained in:
@@ -5825,6 +5825,7 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
|||||||
$scope.gitEnable = false;
|
$scope.gitEnable = false;
|
||||||
$scope.branches = response.data.finalBranches;
|
$scope.branches = response.data.finalBranches;
|
||||||
$scope.deploymentKey = response.data.deploymentKey;
|
$scope.deploymentKey = response.data.deploymentKey;
|
||||||
|
$scope.remote = response.data.remote;
|
||||||
} else {
|
} else {
|
||||||
$scope.gitTracking = false;
|
$scope.gitTracking = false;
|
||||||
$scope.gitEnable = true;
|
$scope.gitEnable = true;
|
||||||
@@ -5853,6 +5854,61 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.initRepo = function () {
|
||||||
|
|
||||||
|
$scope.cyberpanelLoading = false;
|
||||||
|
|
||||||
|
url = "/websites/initRepo";
|
||||||
|
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
domain: $("#domain").text(),
|
||||||
|
folder: $scope.folder
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
headers: {
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||||
|
|
||||||
|
function ListInitialDatas(response) {
|
||||||
|
$scope.cyberpanelLoading = true;
|
||||||
|
|
||||||
|
if (response.data.status === 1) {
|
||||||
|
new PNotify({
|
||||||
|
title: 'Success',
|
||||||
|
text: 'Repo initiated.',
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
$scope.fetchFolderDetails();
|
||||||
|
} else {
|
||||||
|
new PNotify({
|
||||||
|
title: 'Operation Failed!',
|
||||||
|
text: response.data.error_message,
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function cantLoadInitialDatas(response) {
|
||||||
|
$scope.cyberpanelLoading = true;
|
||||||
|
new PNotify({
|
||||||
|
title: 'Operation Failed!',
|
||||||
|
text: 'Could not connect to server, please refresh this page.',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
function getCreationStatus() {
|
function getCreationStatus() {
|
||||||
|
|
||||||
url = "/websites/installWordpressStatus";
|
url = "/websites/installWordpressStatus";
|
||||||
|
|||||||
@@ -85,7 +85,20 @@
|
|||||||
<select ng-change="fetchFolderDetails()" ng-model="branchName" class="form-control">
|
<select ng-change="fetchFolderDetails()" ng-model="branchName" class="form-control">
|
||||||
<option ng-repeat="branch in branches track by $index">{$ branch $}</option>
|
<option ng-repeat="branch in branches track by $index">{$ branch $}</option>
|
||||||
</select></td>
|
</select></td>
|
||||||
<td></td>
|
<td>
|
||||||
|
<button ng-hide="remote==1" style="margin-left: 2%" type="button"
|
||||||
|
class="btn btn-primary"
|
||||||
|
ng-click="initRepo()">
|
||||||
|
Setup Remote
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button ng-hide="remote==0" style="margin-left: 2%" type="button"
|
||||||
|
class="btn btn-primary"
|
||||||
|
ng-click="initRepo()">
|
||||||
|
View Remote
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ urlpatterns = [
|
|||||||
|
|
||||||
url(r'^(?P<domain>(.*))/manageGIT$', views.manageGIT, name='manageGIT'),
|
url(r'^(?P<domain>(.*))/manageGIT$', views.manageGIT, name='manageGIT'),
|
||||||
url(r'^fetchFolderDetails$', views.fetchFolderDetails, name='fetchFolderDetails'),
|
url(r'^fetchFolderDetails$', views.fetchFolderDetails, name='fetchFolderDetails'),
|
||||||
|
url(r'^initRepo$', views.initRepo, name='initRepo'),
|
||||||
|
|
||||||
## 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'),
|
||||||
|
|||||||
@@ -731,5 +731,13 @@ def fetchFolderDetails(request):
|
|||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
wm = WebsiteManager()
|
wm = WebsiteManager()
|
||||||
return wm.fetchFolderDetails(userID, json.loads(request.body))
|
return wm.fetchFolderDetails(userID, json.loads(request.body))
|
||||||
|
except KeyError:
|
||||||
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
def initRepo(request):
|
||||||
|
try:
|
||||||
|
userID = request.session['userID']
|
||||||
|
wm = WebsiteManager()
|
||||||
|
return wm.initRepo(userID, json.loads(request.body))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
@@ -2947,8 +2947,8 @@ StrictHostKeyChecking no
|
|||||||
|
|
||||||
## Find git branches
|
## Find git branches
|
||||||
|
|
||||||
command = 'git --git-dir=%s/.git branch' % (self.folder)
|
command = 'git -C %s branch' % (self.folder)
|
||||||
branches = ProcessUtilities.outputExecutioner(command).split('\n')
|
branches = ProcessUtilities.outputExecutioner(command).split('\n')[:-1]
|
||||||
|
|
||||||
## Fetch key
|
## Fetch key
|
||||||
|
|
||||||
@@ -2975,7 +2975,59 @@ StrictHostKeyChecking no
|
|||||||
command = 'cat /home/%s/.ssh/%s.pub' % (self.domain, website.externalApp)
|
command = 'cat /home/%s/.ssh/%s.pub' % (self.domain, website.externalApp)
|
||||||
deploymentKey = ProcessUtilities.outputExecutioner(command, website.externalApp)
|
deploymentKey = ProcessUtilities.outputExecutioner(command, website.externalApp)
|
||||||
|
|
||||||
data_ret = {'status': 1, 'repo': 1, 'finalBranches': branches, 'deploymentKey': deploymentKey}
|
if deploymentKey.find('No such file or directory') > -1:
|
||||||
|
command = "ssh-keygen -f /home/%s/.ssh/%s -t rsa -N ''" % (self.domain, website.externalApp)
|
||||||
|
ProcessUtilities.executioner(command, website.externalApp)
|
||||||
|
|
||||||
|
command = 'cat /home/%s/.ssh/%s.pub' % (self.domain, website.externalApp)
|
||||||
|
deploymentKey = ProcessUtilities.outputExecutioner(command, website.externalApp)
|
||||||
|
|
||||||
|
## Find Remote if any
|
||||||
|
|
||||||
|
command = 'git -C %s remote -v' % (self.folder)
|
||||||
|
remoteResult = ProcessUtilities.outputExecutioner(command)
|
||||||
|
|
||||||
|
remote = 1
|
||||||
|
if remoteResult.find('origin') == -1:
|
||||||
|
remote = 0
|
||||||
|
|
||||||
|
data_ret = {'status': 1, 'repo': 1, 'finalBranches': branches, 'deploymentKey': deploymentKey, 'remote': remote, 'remoteResult': remoteResult}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
except BaseException as msg:
|
||||||
|
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
def initRepo(self, userID=None, data=None):
|
||||||
|
try:
|
||||||
|
|
||||||
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
|
||||||
|
self.domain = data['domain']
|
||||||
|
self.folder = data['folder']
|
||||||
|
|
||||||
|
if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return ACLManager.loadErrorJson('status', 0)
|
||||||
|
|
||||||
|
if self.folderCheck():
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return ACLManager.loadErrorJson()
|
||||||
|
|
||||||
|
command = 'git -C %s init' % (self.folder)
|
||||||
|
result = ProcessUtilities.outputExecutioner(command)
|
||||||
|
|
||||||
|
if result.find('Initialized empty Git repository in') > -1:
|
||||||
|
data_ret = {'status': 1}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
else:
|
||||||
|
data_ret = {'status': 0, 'error_message': result}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user