mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 22:36:12 +01:00
bug fixes to git manager
This commit is contained in:
@@ -5830,9 +5830,12 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
$scope.remote = response.data.remote;
|
||||
$scope.remoteResult = response.data.remoteResult;
|
||||
$scope.totalCommits = response.data.totalCommits;
|
||||
$scope.home = response.data.home;
|
||||
} else {
|
||||
$scope.gitTracking = false;
|
||||
$scope.gitEnable = true;
|
||||
$scope.home = response.data.home;
|
||||
$scope.deploymentKey = response.data.deploymentKey;
|
||||
}
|
||||
} else {
|
||||
new PNotify({
|
||||
@@ -6256,6 +6259,118 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
}
|
||||
};
|
||||
|
||||
$scope.attachRepoGIT = function () {
|
||||
$scope.cyberpanelLoading = false;
|
||||
$scope.commandStatus = "";
|
||||
$scope.statusBox = false;
|
||||
|
||||
url = "/websites/attachRepoGIT";
|
||||
|
||||
|
||||
var data = {
|
||||
domain: $("#domain").text(),
|
||||
folder: $scope.folder,
|
||||
gitHost: $scope.gitHost,
|
||||
gitUsername: $scope.gitUsername,
|
||||
gitReponame: $scope.gitReponame,
|
||||
overrideData: $scope.overrideData
|
||||
};
|
||||
|
||||
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: 'Changes applied.',
|
||||
type: 'success'
|
||||
});
|
||||
$scope.commandStatus = response.data.commandStatus;
|
||||
$scope.fetchFolderDetails();
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
$scope.commandStatus = response.data.commandStatus;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = false;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page.',
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
$scope.removeTracking = function () {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
url = "/websites/removeTracking";
|
||||
|
||||
|
||||
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: 'Changes applied.',
|
||||
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() {
|
||||
|
||||
url = "/websites/installWordpressStatus";
|
||||
|
||||
@@ -40,7 +40,231 @@
|
||||
Init Repo
|
||||
</button>
|
||||
|
||||
<button data-toggle="modal" data-target="#attachExistingRepo" ng-disabled="home==0"
|
||||
ng-hide="gitTracking" style="margin-left: 2%" type="button" class="btn btn-primary">
|
||||
Attach Existing Repo <img
|
||||
ng-hide="cyberpanelLoading" src="{% static 'images/loading.gif' %}">
|
||||
</button>
|
||||
|
||||
<div id="attachExistingRepo" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×
|
||||
</button>
|
||||
<h4 class="modal-title">{% trans "Attach Existing Repo" %}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<form name="containerSettingsForm" action="/" class="form-horizontal">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Git Host" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input placeholder="Ex. github.com or gitlab.com"
|
||||
name="gitHost" type="text" class="form-control"
|
||||
ng-model="$parent.gitHost" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Username" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="gitUsername" type="text" class="form-control"
|
||||
ng-model="$parent.gitUsername" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Repo Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="gitReponame" type="text" class="form-control"
|
||||
ng-model="$parent.gitReponame" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "" %}</label>
|
||||
<div class="col-sm-9">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input ng-model="$parent.overrideData" type="checkbox" value="">
|
||||
Override Data
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
<div class="col-sm-12">
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Deployment Key" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<textarea rows="5"
|
||||
class="form-control">{$ deploymentKey $}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div ng-hide="statusBox" class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<textarea rows="3"
|
||||
class="form-control">{$ commandStatus $}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary"
|
||||
ng-click="attachRepoGIT()">Attach <img ng-hide="cyberpanelLoading"
|
||||
src="/static/images/loading.gif"
|
||||
style="display: none;">
|
||||
</button>
|
||||
<button type="button" ng-disabled="savingSettings"
|
||||
class="btn btn-default" data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 0px" ng-hide="gitEnable" class="btn-group" data-toggle="buttons">
|
||||
|
||||
<a ng-disabled="home==0" data-toggle="modal" data-target="#attachExistingRepo" href="#"
|
||||
class="btn btn-info">
|
||||
<input name="radio-toggle-1" type="radio">
|
||||
Attach Existing Repo
|
||||
</a>
|
||||
|
||||
<div id="attachExistingRepo" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×
|
||||
</button>
|
||||
<h4 class="modal-title">{% trans "Attach Existing Repo" %}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<form name="containerSettingsForm" action="/" class="form-horizontal">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Git Host" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input placeholder="Ex. github.com or gitlab.com"
|
||||
name="gitHost" type="text" class="form-control"
|
||||
ng-model="$parent.gitHost" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Username" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="gitUsername" type="text" class="form-control"
|
||||
ng-model="$parent.gitUsername" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Repo Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="gitReponame" type="text" class="form-control"
|
||||
ng-model="$parent.gitReponame" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "" %}</label>
|
||||
<div class="col-sm-9">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input ng-model="$parent.overrideData" type="checkbox"
|
||||
value="">
|
||||
Override Data
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
<div class="col-sm-12">
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Deployment Key" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<textarea rows="5"
|
||||
class="form-control">{$ deploymentKey $}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div ng-hide="statusBox" class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<textarea rows="3"
|
||||
class="form-control">{$ commandStatus $}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary"
|
||||
ng-click="attachRepoGIT()">Attach <img ng-hide="cyberpanelLoading"
|
||||
src="/static/images/loading.gif"
|
||||
style="display: none;">
|
||||
</button>
|
||||
<button type="button" ng-disabled="savingSettings"
|
||||
class="btn btn-default" data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a data-toggle="modal" data-target="#createNewBranch" href="#" class="btn btn-info">
|
||||
<input name="radio-toggle-1" type="radio">
|
||||
Create New Branch
|
||||
@@ -83,7 +307,8 @@
|
||||
<div class="modal-footer">
|
||||
<button type="button"
|
||||
class="btn btn-primary"
|
||||
ng-click="createNewBranch()">Create New Branch<img id="cyberpanelLoading"
|
||||
ng-click="createNewBranch()">Create New Branch<img
|
||||
ng-hide="cyberpanelLoading"
|
||||
src="/static/images/loading.gif"
|
||||
style="display: none;">
|
||||
</button>
|
||||
@@ -138,7 +363,7 @@
|
||||
<div class="modal-footer">
|
||||
<button type="button"
|
||||
class="btn btn-primary"
|
||||
ng-click="commitChanges()">Commit<img id="cyberpanelLoading"
|
||||
ng-click="commitChanges()">Commit<img ng-hide="cyberpanelLoading"
|
||||
src="/static/images/loading.gif"
|
||||
style="display: none;">
|
||||
</button>
|
||||
@@ -163,6 +388,45 @@
|
||||
<input name="radio-toggle-1" type="radio">
|
||||
Edit .gitignore
|
||||
</a>
|
||||
<a data-toggle="modal" data-target="#removeGit" href="#" class="btn btn-info">
|
||||
<input name="radio-toggle-1" type="radio">
|
||||
Remove Git
|
||||
</a>
|
||||
|
||||
<div id="removeGit" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×
|
||||
</button>
|
||||
<h4 class="modal-title">{% trans "Remove Git Tracking?" %}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<form name="containerSettingsForm" action="/" class="form-horizontal">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-13 control-label" style="text-align: center;">{% trans "Removing git tracking is not reversible, it will delete all of your commit history, however your files stays there." %}</label>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button"
|
||||
class="btn btn-primary"
|
||||
ng-click="removeTracking()">Remove<img
|
||||
ng-hide="cyberpanelLoading"
|
||||
src="/static/images/loading.gif"
|
||||
style="display: none;" data-dismiss="modal">
|
||||
</button>
|
||||
<button type="button"
|
||||
class="btn btn-default" data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table ng-hide="gitEnable" style="margin-top: 2%" class="table">
|
||||
@@ -290,7 +554,7 @@
|
||||
<div class="modal-footer">
|
||||
<button type="button" ng-disabled="savingSettings"
|
||||
class="btn btn-primary"
|
||||
ng-click="setupRemote()">Save <img id="cyberpanelLoading"
|
||||
ng-click="setupRemote()">Save <img ng-hide="cyberpanelLoading"
|
||||
src="/static/images/loading.gif"
|
||||
style="display: none;">
|
||||
</button>
|
||||
|
||||
@@ -128,6 +128,8 @@ urlpatterns = [
|
||||
url(r'^commitChanges$', views.commitChanges, name='commitChanges'),
|
||||
url(r'^gitPull$', views.gitPull, name='gitPull'),
|
||||
url(r'^gitPush$', views.gitPush, name='gitPush'),
|
||||
url(r'^attachRepoGIT$', views.attachRepoGIT, name='attachRepoGIT'),
|
||||
url(r'^removeTracking$', views.removeTracking, name='removeTracking'),
|
||||
|
||||
|
||||
## Catch all for domains
|
||||
|
||||
@@ -789,3 +789,19 @@ def gitPush(request):
|
||||
return wm.gitPush(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def attachRepoGIT(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
wm = WebsiteManager()
|
||||
return wm.attachRepoGIT(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def removeTracking(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
wm = WebsiteManager()
|
||||
return wm.removeTracking(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
@@ -2880,7 +2880,7 @@ StrictHostKeyChecking no
|
||||
|
||||
website = Websites.objects.get(domain=self.domain)
|
||||
|
||||
folders = ['/home/%s' % (self.domain), '/home/vmail/%s' % (self.domain)]
|
||||
folders = ['/home/%s/public_html' % (self.domain), '/home/vmail/%s' % (self.domain)]
|
||||
|
||||
databases = website.databases_set.all()
|
||||
|
||||
@@ -2894,7 +2894,7 @@ StrictHostKeyChecking no
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
def folderCheck(self):
|
||||
domainPath = '/home/%s' % (self.domain)
|
||||
domainPath = '/home/%s/public_html' % (self.domain)
|
||||
vmailPath = '/home/vmail/%s' % (self.domain)
|
||||
|
||||
if self.folder == domainPath:
|
||||
@@ -2940,7 +2940,22 @@ StrictHostKeyChecking no
|
||||
command = 'ls -la %s' % (gitPath)
|
||||
|
||||
if ProcessUtilities.outputExecutioner(command).find('No such file or directory') > -1:
|
||||
data_ret = {'status': 1, 'repo': 0}
|
||||
|
||||
command = 'cat /home/%s/.ssh/%s.pub' % (self.domain, website.externalApp)
|
||||
deploymentKey = ProcessUtilities.outputExecutioner(command, website.externalApp)
|
||||
|
||||
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)
|
||||
|
||||
home = 0
|
||||
if self.folder == '/home/%s/public_html' % (self.domain):
|
||||
home = 1
|
||||
|
||||
data_ret = {'status': 1, 'repo': 0, 'deploymentKey': deploymentKey, 'home': home}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
@@ -3000,8 +3015,14 @@ StrictHostKeyChecking no
|
||||
if totalCommits.find('fatal') > -1:
|
||||
totalCommits = '0'
|
||||
|
||||
## Check if home
|
||||
|
||||
home = 0
|
||||
if self.folder == '/home/%s' % (self.domain):
|
||||
home = 1
|
||||
|
||||
data_ret = {'status': 1, 'repo': 1, 'finalBranches': branches, 'deploymentKey': deploymentKey,
|
||||
'remote': remote, 'remoteResult': remoteResult, 'totalCommits': totalCommits}
|
||||
'remote': remote, 'remoteResult': remoteResult, 'totalCommits': totalCommits, 'home': home}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
@@ -3170,7 +3191,7 @@ StrictHostKeyChecking no
|
||||
|
||||
## Check if remote exists
|
||||
|
||||
command = 'git -C %s checkout -b %s' % (self.folder, self.newBranchName)
|
||||
command = 'git -C %s checkout -b "%s"' % (self.folder, self.newBranchName)
|
||||
commandStatus = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if commandStatus.find(self.newBranchName) > -1:
|
||||
@@ -3212,7 +3233,7 @@ StrictHostKeyChecking no
|
||||
command = 'git -C %s add -A' % (self.folder)
|
||||
ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
command = 'git -C %s commit -m %s' % (self.folder, self.commitMessage)
|
||||
command = 'git -C %s commit -m "%s"' % (self.folder, self.commitMessage)
|
||||
commandStatus = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if commandStatus.find('nothing to commit') == -1:
|
||||
@@ -3249,6 +3270,14 @@ StrictHostKeyChecking no
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
### set default ssh key
|
||||
|
||||
externalApp = Websites.objects.get(domain=self.domain).externalApp
|
||||
|
||||
command = 'git -C %s config --local core.sshCommand "ssh -i /home/%s/.ssh/%s"' % (
|
||||
self.folder, self.domain, externalApp)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
## Check if remote exists
|
||||
|
||||
command = 'git -C %s pull' % (self.folder)
|
||||
@@ -3288,9 +3317,27 @@ StrictHostKeyChecking no
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
command = 'git -C %s push -u origin master' % (self.folder)
|
||||
### set default ssh key
|
||||
|
||||
externalApp = Websites.objects.get(domain=self.domain).externalApp
|
||||
|
||||
command = 'git -C %s config --local core.sshCommand "ssh -i /home/%s/.ssh/%s"' % (
|
||||
self.folder, self.domain, externalApp)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = 'git -C %s push' % (self.folder)
|
||||
commandStatus = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if commandStatus.find('has no upstream branch') > -1:
|
||||
command = 'git -C %s rev-parse --abbrev-ref HEAD' % (self.folder)
|
||||
currentBranch = ProcessUtilities.outputExecutioner(command).rstrip('\n')
|
||||
|
||||
command = 'git -C %s push --set-upstream origin %s' % (self.folder, currentBranch)
|
||||
commandStatus = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
|
||||
if commandStatus.find('Everything up-to-date') == -1 and commandStatus.find('rejected') == -1:
|
||||
data_ret = {'status': 1, 'commandStatus': commandStatus}
|
||||
json_data = json.dumps(data_ret)
|
||||
@@ -3304,3 +3351,102 @@ StrictHostKeyChecking no
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def attachRepoGIT(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
self.domain = data['domain']
|
||||
self.folder = data['folder']
|
||||
self.gitHost = data['gitHost']
|
||||
self.gitUsername = data['gitUsername']
|
||||
self.gitReponame = data['gitReponame']
|
||||
try:
|
||||
self.overrideData = data['overrideData']
|
||||
except:
|
||||
self.overrideData = False
|
||||
|
||||
|
||||
if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('status', 0)
|
||||
|
||||
if self.folderCheck():
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
|
||||
if self.overrideData:
|
||||
command = 'rm -rf %s' % (self.folder)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
## Set defauly key
|
||||
|
||||
externalApp = Websites.objects.get(domain=self.domain).externalApp
|
||||
|
||||
command = 'git config --global core.sshCommand "ssh -i /home/%s/.ssh/%s"' % (self.domain, externalApp)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = 'git clone git@%s:%s/%s.git %s' % (self.gitHost, self.gitUsername, self.gitReponame, self.folder)
|
||||
commandStatus = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if commandStatus.find('already exists') == -1 and commandStatus.find('Permission denied') == -1:
|
||||
|
||||
command = 'git config --global --unset core.sshCommand'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
data_ret = {'status': 1, 'commandStatus': commandStatus}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
else:
|
||||
|
||||
command = 'git config --global --unset core.sshCommand'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
data_ret = {'status': 0, 'error_message': 'Failed to clone.', 'commandStatus': commandStatus}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def removeTracking(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 = 'rm -rf %s/.git' % (self.folder)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
data_ret = {'status': 1}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
Reference in New Issue
Block a user