mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-02 19:35:49 +01:00
Minor bug fixes
This commit is contained in:
@@ -2052,6 +2052,10 @@ class preFlightsChecks:
|
||||
cmd = shlex.split(command)
|
||||
subprocess.call(cmd)
|
||||
|
||||
command = 'systemctl restart systemd-logind'
|
||||
cmd = shlex.split(command)
|
||||
subprocess.call(cmd)
|
||||
|
||||
|
||||
count = 0
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@ class ApplicationInstaller(multi.Thread):
|
||||
self.setupGit()
|
||||
elif self.installApp == 'pull':
|
||||
self.gitPull()
|
||||
elif self.installApp == 'detach':
|
||||
self.detachRepo()
|
||||
elif self.installApp == 'changeBranch':
|
||||
self.changeBranch()
|
||||
|
||||
except BaseException, msg:
|
||||
logging.writeToFile( str(msg) + ' [ApplicationInstaller.run]')
|
||||
@@ -480,6 +484,36 @@ class ApplicationInstaller(multi.Thread):
|
||||
logging.writeToFile(str(msg)+ " [ApplicationInstaller.gitPull]")
|
||||
return 0
|
||||
|
||||
def detachRepo(self):
|
||||
try:
|
||||
domain = self.extraArgs['domainName']
|
||||
|
||||
command = 'sudo rm -rf /home/' + domain + '/public_html'
|
||||
subprocess.check_output(shlex.split(command))
|
||||
|
||||
command = 'sudo mkdir /home/' + domain + '/public_html'
|
||||
subprocess.check_output(shlex.split(command))
|
||||
|
||||
website = Websites.objects.get(domain=domain)
|
||||
externalApp = website.externalApp
|
||||
|
||||
##
|
||||
|
||||
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + '/home/' + domain + '/public_html'
|
||||
cmd = shlex.split(command)
|
||||
subprocess.call(cmd)
|
||||
|
||||
gitPath = '/home/cyberpanel/' + domain + '.git'
|
||||
|
||||
os.remove(gitPath)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
except BaseException, msg:
|
||||
logging.writeToFile(str(msg)+ " [ApplicationInstaller.gitPull]")
|
||||
return 0
|
||||
|
||||
def installJoomla(self):
|
||||
|
||||
try:
|
||||
@@ -666,3 +700,25 @@ class ApplicationInstaller(multi.Thread):
|
||||
statusFile.writelines(str(msg) + " [404]")
|
||||
statusFile.close()
|
||||
return 0
|
||||
|
||||
def changeBranch(self):
|
||||
try:
|
||||
domainName = self.extraArgs['domainName']
|
||||
githubBranch = self.extraArgs['githubBranch']
|
||||
|
||||
try:
|
||||
command = 'sudo GIT_SSH_COMMAND="ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no" git -C /home/' + domainName + '/public_html/ checkout -b' + githubBranch
|
||||
subprocess.check_output(shlex.split(command))
|
||||
|
||||
except subprocess.CalledProcessError, msg:
|
||||
logging.writeToFile('Failed to change branch: ' + str(msg))
|
||||
return 0
|
||||
|
||||
##
|
||||
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
except BaseException, msg:
|
||||
return 0
|
||||
|
||||
@@ -4235,7 +4235,7 @@ app.controller('installJoomlaCTRL', function($scope, $http, $timeout) {
|
||||
});
|
||||
|
||||
|
||||
app.controller('setupGit', function($scope, $http, $timeout) {
|
||||
app.controller('setupGit', function($scope, $http, $timeout, $window) {
|
||||
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
@@ -4298,6 +4298,7 @@ app.controller('setupGit', function($scope, $http, $timeout) {
|
||||
$scope.installPercentage = "100";
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout.cancel();
|
||||
$timeout(function() { $window.location.reload(); }, 3000);
|
||||
|
||||
}
|
||||
else{
|
||||
@@ -4405,7 +4406,6 @@ app.controller('setupGit', function($scope, $http, $timeout) {
|
||||
|
||||
};
|
||||
|
||||
|
||||
$scope.goBack = function () {
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
@@ -4418,5 +4418,133 @@ app.controller('setupGit', function($scope, $http, $timeout) {
|
||||
$("#installProgress").css("width", "0%");
|
||||
};
|
||||
|
||||
/// Detach Repo
|
||||
|
||||
$scope.failedMesg = true;
|
||||
$scope.successMessage = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.gitLoading = true;
|
||||
$scope.successMessageBranch = true;
|
||||
|
||||
$scope.detachRepo = function(){
|
||||
|
||||
$scope.failedMesg = true;
|
||||
$scope.successMessage = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.gitLoading = false;
|
||||
$scope.successMessageBranch = true;
|
||||
|
||||
url = "/websites/detachRepo";
|
||||
|
||||
var data = {
|
||||
domain: domain
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
$scope.gitLoading = true;
|
||||
|
||||
if (response.data.status === 1)
|
||||
{
|
||||
$scope.failedMesg = true;
|
||||
$scope.successMessage = false;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.successMessageBranch = true;
|
||||
|
||||
$timeout(function() { $window.location.reload(); }, 3000);
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
$scope.failedMesg = false;
|
||||
$scope.successMessage = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.successMessageBranch = true;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.failedMesg = true;
|
||||
$scope.successMessage = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.gitLoading = true;
|
||||
$scope.successMessageBranch = true;
|
||||
}
|
||||
|
||||
};
|
||||
$scope.changeBranch = function(){
|
||||
|
||||
$scope.failedMesg = true;
|
||||
$scope.successMessage = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.gitLoading = false;
|
||||
$scope.successMessageBranch = true;
|
||||
|
||||
url = "/websites/changeBranch";
|
||||
|
||||
var data = {
|
||||
domain: domain,
|
||||
githubBranch: $scope.githubBranch
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
$scope.gitLoading = true;
|
||||
|
||||
if (response.data.status === 1)
|
||||
{
|
||||
$scope.failedMesg = true;
|
||||
$scope.successMessage = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.successMessageBranch = false;
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
$scope.failedMesg = false;
|
||||
$scope.successMessage = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.successMessageBranch = true;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.failedMesg = true;
|
||||
$scope.successMessage = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.gitLoading = true;
|
||||
$scope.successMessageBranch = true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
@@ -4235,7 +4235,7 @@ app.controller('installJoomlaCTRL', function($scope, $http, $timeout) {
|
||||
});
|
||||
|
||||
|
||||
app.controller('setupGit', function($scope, $http, $timeout) {
|
||||
app.controller('setupGit', function($scope, $http, $timeout, $window) {
|
||||
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
@@ -4298,6 +4298,7 @@ app.controller('setupGit', function($scope, $http, $timeout) {
|
||||
$scope.installPercentage = "100";
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout.cancel();
|
||||
$timeout(function() { $window.location.reload(); }, 3000);
|
||||
|
||||
}
|
||||
else{
|
||||
@@ -4405,7 +4406,6 @@ app.controller('setupGit', function($scope, $http, $timeout) {
|
||||
|
||||
};
|
||||
|
||||
|
||||
$scope.goBack = function () {
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
@@ -4418,5 +4418,133 @@ app.controller('setupGit', function($scope, $http, $timeout) {
|
||||
$("#installProgress").css("width", "0%");
|
||||
};
|
||||
|
||||
/// Detach Repo
|
||||
|
||||
$scope.failedMesg = true;
|
||||
$scope.successMessage = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.gitLoading = true;
|
||||
$scope.successMessageBranch = true;
|
||||
|
||||
$scope.detachRepo = function(){
|
||||
|
||||
$scope.failedMesg = true;
|
||||
$scope.successMessage = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.gitLoading = false;
|
||||
$scope.successMessageBranch = true;
|
||||
|
||||
url = "/websites/detachRepo";
|
||||
|
||||
var data = {
|
||||
domain: domain
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
$scope.gitLoading = true;
|
||||
|
||||
if (response.data.status === 1)
|
||||
{
|
||||
$scope.failedMesg = true;
|
||||
$scope.successMessage = false;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.successMessageBranch = true;
|
||||
|
||||
$timeout(function() { $window.location.reload(); }, 3000);
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
$scope.failedMesg = false;
|
||||
$scope.successMessage = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.successMessageBranch = true;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.failedMesg = true;
|
||||
$scope.successMessage = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.gitLoading = true;
|
||||
$scope.successMessageBranch = true;
|
||||
}
|
||||
|
||||
};
|
||||
$scope.changeBranch = function(){
|
||||
|
||||
$scope.failedMesg = true;
|
||||
$scope.successMessage = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.gitLoading = false;
|
||||
$scope.successMessageBranch = true;
|
||||
|
||||
url = "/websites/changeBranch";
|
||||
|
||||
var data = {
|
||||
domain: domain,
|
||||
githubBranch: $scope.githubBranch
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
$scope.gitLoading = true;
|
||||
|
||||
if (response.data.status === 1)
|
||||
{
|
||||
$scope.failedMesg = true;
|
||||
$scope.successMessage = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.successMessageBranch = false;
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
$scope.failedMesg = false;
|
||||
$scope.successMessage = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.successMessageBranch = true;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.failedMesg = true;
|
||||
$scope.successMessage = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.gitLoading = true;
|
||||
$scope.successMessageBranch = true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
@@ -1,21 +1,21 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Attach Git - CyberPanel" %}{% endblock %}
|
||||
{% block title %}{% trans "Git Management - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
<div class="container">
|
||||
<div ng-controller="setupGit" class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Attach Git" %}</h2>
|
||||
<p>{% trans "Attach git to your website" %}</p>
|
||||
<h2>{% trans "Git Management" %}</h2>
|
||||
<p>{% trans "Attach git to your websites." %}</p>
|
||||
</div>
|
||||
|
||||
{% if not installed %}
|
||||
|
||||
<div ng-controller="setupGit" class="panel">
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
<span id="domainNamePage">{{ domainName }}</span> - {% trans "Attach Git" %} <img ng-hide="gitLoading" src="{% static 'images/loading.gif' %}">
|
||||
@@ -120,7 +120,7 @@
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationSuccessfull" class="alert alert-success">
|
||||
<p>{% trans "GIT Successfully attached. Visit:" %} {$ installationURL $}</p>
|
||||
<p>{% trans "GIT Successfully attached, refreshing page in 3 seconds... Visit:" %} {$ installationURL $}</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@
|
||||
|
||||
{% else %}
|
||||
|
||||
<div ng-controller="setupGit" class="panel">
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
<span id="domainNamePage">{{ domainName }}</span> <img ng-hide="gitLoading" src="{% static 'images/loading.gif' %}">
|
||||
@@ -220,9 +220,9 @@
|
||||
<div class="tab-pane fade active in" id="tab-example-1">
|
||||
<ul class="list-group row">
|
||||
<li class="col-md-3">
|
||||
<a href="" ng-click="setProvider('github')" class="list-group-item">
|
||||
<a href="" ng-click="detachRepo()" class="list-group-item">
|
||||
<i class="fa fa-github" aria-hidden="true"></i>
|
||||
Detach Repo
|
||||
{% trans 'Detach Repo' %}
|
||||
<i class="glyph-icon icon-chevron-right"></i>
|
||||
</a>
|
||||
</li>
|
||||
@@ -231,6 +231,28 @@
|
||||
<h4 class="alert-title">{% trans 'Webhook URL' %}</h4>
|
||||
<p>{% 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."%} <code>{{ webhookURL }}</code></p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="" class="form-group">
|
||||
<label class="col-sm-2 control-label"></label>
|
||||
<div class="col-sm-7">
|
||||
|
||||
<div ng-hide="failedMesg" class="alert alert-danger">
|
||||
<p>{% trans "Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="successMessage" class="alert alert-success">
|
||||
<p>{% trans "Repo successfully detached, refreshing in 3 seconds.." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div ng-hide="couldNotConnect" class="alert alert-danger">
|
||||
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -251,7 +273,7 @@
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="attachRepo()" class="btn btn-primary btn-lg btn-block">{% trans "Change Branch" %}</button>
|
||||
<button type="button" ng-click="changeBranch()" class="btn btn-primary btn-lg btn-block">{% trans "Change Branch" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -264,7 +286,7 @@
|
||||
<p>{% trans "Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="successMessage" class="alert alert-success">
|
||||
<div ng-hide="successMessageBranch" class="alert alert-success">
|
||||
<p>{% trans "Branch successfully changed." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -94,7 +94,8 @@ urlpatterns = [
|
||||
url(r'^setupGitRepo$', views.setupGitRepo, name='setupGitRepo'),
|
||||
|
||||
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/gitNotify$', views.gitNotify, name='gitNotify'),
|
||||
|
||||
url(r'^detachRepo$', views.detachRepo, name='detachRepo'),
|
||||
url(r'^changeBranch$', views.changeBranch, name='changeBranch'),
|
||||
|
||||
|
||||
]
|
||||
@@ -2603,3 +2603,77 @@ def gitNotify(request, domain):
|
||||
data_ret = {"pulled":0,"error":str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def detachRepo(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
data = json.loads(request.body)
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
extraArgs = {}
|
||||
extraArgs['domainName'] = data['domain']
|
||||
|
||||
|
||||
background = ApplicationInstaller('detach', extraArgs)
|
||||
background.start()
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
data_ret = {'status': 1, 'error_message': 'None'}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except KeyError, msg:
|
||||
status = {"status":0,"error":str(msg)}
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installWordpress]")
|
||||
return HttpResponse("Not Logged in as admin")
|
||||
|
||||
def changeBranch(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
data = json.loads(request.body)
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
extraArgs = {}
|
||||
extraArgs['domainName'] = data['domain']
|
||||
extraArgs['githubBranch'] = data['githubBranch']
|
||||
|
||||
|
||||
background = ApplicationInstaller('changeBranch', extraArgs)
|
||||
background.start()
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
data_ret = {'status': 1, 'error_message': 'None'}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except KeyError, msg:
|
||||
status = {"status":0,"error":str(msg)}
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installWordpress]")
|
||||
return HttpResponse("Not Logged in as admin")
|
||||
Reference in New Issue
Block a user