mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-03 03:45:52 +01:00
Attach GIT repositories to websites!
This commit is contained in:
@@ -23,17 +23,13 @@ Webhosting control panel that uses OpenLiteSpeed as web server.
|
||||
* PHP 5.6
|
||||
* PHP 7.0
|
||||
* PHP 7.1
|
||||
|
||||
* PHP 7.2
|
||||
|
||||
# Installation Instructions
|
||||
|
||||
|
||||
```
|
||||
wget http://cyberpanel.net/install.tar.gz
|
||||
tar zxf install.tar.gz
|
||||
cd install
|
||||
chmod +x install.py
|
||||
python install.py [IP Address]
|
||||
sh <(curl https://cyberpanel.net/install.sh || wget -O - https://cyberpanel.net/install.sh)
|
||||
```
|
||||
|
||||
# Resources
|
||||
|
||||
@@ -31,6 +31,8 @@ class ApplicationInstaller(multi.Thread):
|
||||
self.installWordPress()
|
||||
elif self.installApp == 'joomla':
|
||||
self.installJoomla()
|
||||
elif self.installApp == 'git':
|
||||
self.setupGit()
|
||||
|
||||
except BaseException, msg:
|
||||
logging.writeToFile( str(msg) + ' [ApplicationInstaller.run]')
|
||||
@@ -50,6 +52,18 @@ class ApplicationInstaller(multi.Thread):
|
||||
except BaseException, msg:
|
||||
logging.writeToFile( str(msg) + ' [ApplicationInstaller.installWPCLI]')
|
||||
|
||||
def installGit(self, tempStatusPath):
|
||||
try:
|
||||
|
||||
command = 'sudo yum -y install http://repo.iotti.biz/CentOS/7/noarch/lux-release-7-1.noarch.rpm'
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = 'sudo yum install git -y'
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
except BaseException, msg:
|
||||
logging.writeToFile( str(msg) + ' [ApplicationInstaller.installGit]')
|
||||
|
||||
|
||||
def installWordPress(self):
|
||||
try:
|
||||
@@ -292,6 +306,148 @@ class ApplicationInstaller(multi.Thread):
|
||||
return 0
|
||||
|
||||
|
||||
def setupGit(self):
|
||||
try:
|
||||
admin = self.extraArgs['admin']
|
||||
domainName = self.extraArgs['domainName']
|
||||
username = self.extraArgs['username']
|
||||
reponame = self.extraArgs['reponame']
|
||||
branch = self.extraArgs['branch']
|
||||
tempStatusPath = self.extraArgs['tempStatusPath']
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Checking if GIT installed..,0')
|
||||
statusFile.close()
|
||||
|
||||
finalPath = "/home/" + domainName + "/public_html/"
|
||||
|
||||
|
||||
### Check git
|
||||
|
||||
try:
|
||||
command = 'sudo /usr/local/bin/git --help'
|
||||
res = subprocess.call(shlex.split(command))
|
||||
|
||||
if res == 1:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Installing GIT..,0')
|
||||
statusFile.close()
|
||||
self.installGit(tempStatusPath)
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('GIT successfully installed,40')
|
||||
statusFile.close()
|
||||
except subprocess.CalledProcessError:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Installing GIT..,0')
|
||||
statusFile.close()
|
||||
self.installGit(tempStatusPath)
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('GIT successfully installed.,40')
|
||||
statusFile.close()
|
||||
|
||||
## Open Status File
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Setting up directories..,40')
|
||||
statusFile.close()
|
||||
|
||||
try:
|
||||
website = ChildDomains.objects.get(domain=domainName)
|
||||
externalApp = website.master.externalApp
|
||||
|
||||
if admin.type != 1:
|
||||
if website.master.admin != admin:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("You do not own this website." + " [404]")
|
||||
statusFile.close()
|
||||
return 0
|
||||
|
||||
except:
|
||||
website = Websites.objects.get(domain=domainName)
|
||||
externalApp = website.externalApp
|
||||
|
||||
if admin.type != 1:
|
||||
if website.admin != admin:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("You do not own this website." + " [404]")
|
||||
statusFile.close()
|
||||
return 0
|
||||
|
||||
## Security Check
|
||||
|
||||
if finalPath.find("..") > -1:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("Specified path must be inside virtual host home." + " [404]")
|
||||
statusFile.close()
|
||||
return 0
|
||||
|
||||
FNULL = open(os.devnull, 'w')
|
||||
|
||||
if not os.path.exists(finalPath):
|
||||
command = 'sudo mkdir -p ' + finalPath
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
## checking for directories/files
|
||||
|
||||
dirFiles = os.listdir(finalPath)
|
||||
|
||||
if len(dirFiles) == 1:
|
||||
if dirFiles[0] == ".well-known":
|
||||
pass
|
||||
else:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("Target directory should be empty before installation, otherwise data loss could occur." + " [404]")
|
||||
statusFile.close()
|
||||
return 0
|
||||
elif len(dirFiles) == 0:
|
||||
pass
|
||||
else:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines(
|
||||
"Target directory should be empty before installation, otherwise data loss could occur." + " [404]")
|
||||
statusFile.close()
|
||||
return 0
|
||||
|
||||
####
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Cloning the repo..,40')
|
||||
statusFile.close()
|
||||
|
||||
try:
|
||||
|
||||
command = 'sudo GIT_SSH_COMMAND="ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no" /usr/local/bin/git clone ' \
|
||||
'--depth 1 --no-single-branch git@github.com:' + username + '/' + reponame + '.git -b ' + branch + ' ' + finalPath
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
except subprocess.CalledProcessError, msg:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Failed to clone repository. [404]')
|
||||
statusFile.close()
|
||||
return 0
|
||||
|
||||
##
|
||||
|
||||
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath
|
||||
cmd = shlex.split(command)
|
||||
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
vhost.addRewriteRules(domainName)
|
||||
installUtilities.reStartLiteSpeed()
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("Successfully Installed. [200]")
|
||||
statusFile.close()
|
||||
return 0
|
||||
|
||||
|
||||
except BaseException, msg:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines(str(msg) + " [404]")
|
||||
statusFile.close()
|
||||
return 0
|
||||
|
||||
|
||||
def installJoomla(self):
|
||||
|
||||
try:
|
||||
|
||||
@@ -196,8 +196,6 @@ class sslUtilities:
|
||||
logging.CyberCPLogFileWriter.writeToFile('Failed to obtain SSL, issuing self-signed SSL for: ' + virtualHostName)
|
||||
return 0
|
||||
|
||||
logging.CyberCPLogFileWriter.writeToFile(command)
|
||||
|
||||
pathToStoreSSL = sslUtilities.Server_root + "/conf/vhosts/" + "SSL-" + virtualHostName
|
||||
|
||||
if not os.path.exists(pathToStoreSSL):
|
||||
|
||||
@@ -253,6 +253,7 @@ WantedBy=multi-user.target"""
|
||||
if count == 3:
|
||||
Upgrade.stdOut(
|
||||
"Failed to setup CLI! [setupCLI]")
|
||||
break
|
||||
else:
|
||||
Upgrade.stdOut("CLI setup successfull!")
|
||||
break
|
||||
@@ -314,14 +315,20 @@ WantedBy=multi-user.target"""
|
||||
|
||||
os.chdir("/usr/local")
|
||||
|
||||
|
||||
|
||||
## Current Version
|
||||
|
||||
Version = version.objects.get(pk=1)
|
||||
|
||||
|
||||
##
|
||||
|
||||
versionNumbring = Upgrade.downloadLink()
|
||||
|
||||
if os.path.exists('/usr/local/CyberPanel.' + versionNumbring):
|
||||
os.remove('/usr/local/CyberPanel.' + versionNumbring)
|
||||
|
||||
if float(Version.currentVersion) < 1.6:
|
||||
Upgrade.stdOut('Upgrades works for version 1.6 onwards.')
|
||||
os._exit(0)
|
||||
|
||||
BIN
static/images/icons/git-logo.png
Normal file
BIN
static/images/icons/git-logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
@@ -458,6 +458,7 @@ app.controller('websitePages', function($scope,$http) {
|
||||
$scope.fileManagerURL = "/filemanager/"+$("#domainNamePage").text();
|
||||
$scope.wordPressInstallURL = $("#domainNamePage").text() + "/wordpressInstall";
|
||||
$scope.joomlaInstallURL = $("#domainNamePage").text() + "/joomlaInstall";
|
||||
$scope.setupGit = $("#domainNamePage").text() + "/setupGit";
|
||||
$scope.domainAliasURL = "/websites/"+$("#domainNamePage").text()+"/domainAlias";
|
||||
$scope.previewUrl = "/preview/"+$("#domainNamePage").text()+"/";
|
||||
|
||||
@@ -4048,7 +4049,7 @@ app.controller('installJoomlaCTRL', function($scope, $http, $timeout) {
|
||||
$scope.wpInstallLoading = true;
|
||||
$scope.goBackDisable = true;
|
||||
|
||||
$scope.databasePrefix = 'jm_'
|
||||
$scope.databasePrefix = 'jm_';
|
||||
|
||||
var statusFile;
|
||||
var domain = $("#domainNamePage").text();
|
||||
@@ -4226,6 +4227,168 @@ app.controller('installJoomlaCTRL', function($scope, $http, $timeout) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
app.controller('setupGit', function($scope, $http, $timeout) {
|
||||
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
$scope.installationFailed = true;
|
||||
$scope.installationSuccessfull = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.gitLoading = true;
|
||||
$scope.githubBranch = 'master';
|
||||
$scope.installProg = true;
|
||||
|
||||
var statusFile;
|
||||
var domain = $("#domainNamePage").text();
|
||||
|
||||
function getInstallStatus(){
|
||||
|
||||
url = "/websites/installWordpressStatus";
|
||||
|
||||
var data = {
|
||||
statusFile: statusFile,
|
||||
domainName: domain
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if(response.data.abort === 1){
|
||||
|
||||
if(response.data.installStatus === 1){
|
||||
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.installationFailed = true;
|
||||
$scope.installationSuccessfull = false;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.gitLoading = true;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$scope.installationURL = domain;
|
||||
|
||||
$("#installProgress").css("width", "100%");
|
||||
$scope.installPercentage = "100";
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout.cancel();
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.installationFailed = false;
|
||||
$scope.installationSuccessfull = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.gitLoading = true;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
$("#installProgress").css("width", "0%");
|
||||
$scope.installPercentage = "0";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
$("#installProgress").css("width", response.data.installationProgress + "%");
|
||||
$scope.installPercentage = response.data.installationProgress;
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
|
||||
$timeout(getInstallStatus,1000);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.canNotFetch = true;
|
||||
$scope.couldNotConnect = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$scope.attachRepo = function(){
|
||||
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.installationFailed = true;
|
||||
$scope.installationSuccessfull = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.gitLoading = false;
|
||||
$scope.installProg = false;
|
||||
|
||||
$scope.currentStatus = "Starting installation..";
|
||||
|
||||
url = "/websites/setupGitRepo";
|
||||
|
||||
var data = {
|
||||
domain: domain,
|
||||
username: $scope.githubUserName,
|
||||
reponame: $scope.githubRepo,
|
||||
branch: $scope.githubBranch
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
if (response.data.installStatus === 1)
|
||||
{
|
||||
statusFile = response.data.tempStatusPath;
|
||||
getInstallStatus();
|
||||
}
|
||||
else{
|
||||
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.installationFailed = false;
|
||||
$scope.installationSuccessfull = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.gitLoading = true;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
BIN
websiteFunctions/static/images/icons/git-logo.png
Normal file
BIN
websiteFunctions/static/images/icons/git-logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
@@ -458,6 +458,7 @@ app.controller('websitePages', function($scope,$http) {
|
||||
$scope.fileManagerURL = "/filemanager/"+$("#domainNamePage").text();
|
||||
$scope.wordPressInstallURL = $("#domainNamePage").text() + "/wordpressInstall";
|
||||
$scope.joomlaInstallURL = $("#domainNamePage").text() + "/joomlaInstall";
|
||||
$scope.setupGit = $("#domainNamePage").text() + "/setupGit";
|
||||
$scope.domainAliasURL = "/websites/"+$("#domainNamePage").text()+"/domainAlias";
|
||||
$scope.previewUrl = "/preview/"+$("#domainNamePage").text()+"/";
|
||||
|
||||
@@ -4048,7 +4049,7 @@ app.controller('installJoomlaCTRL', function($scope, $http, $timeout) {
|
||||
$scope.wpInstallLoading = true;
|
||||
$scope.goBackDisable = true;
|
||||
|
||||
$scope.databasePrefix = 'jm_'
|
||||
$scope.databasePrefix = 'jm_';
|
||||
|
||||
var statusFile;
|
||||
var domain = $("#domainNamePage").text();
|
||||
@@ -4226,6 +4227,168 @@ app.controller('installJoomlaCTRL', function($scope, $http, $timeout) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
app.controller('setupGit', function($scope, $http, $timeout) {
|
||||
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
$scope.installationFailed = true;
|
||||
$scope.installationSuccessfull = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.gitLoading = true;
|
||||
$scope.githubBranch = 'master';
|
||||
$scope.installProg = true;
|
||||
|
||||
var statusFile;
|
||||
var domain = $("#domainNamePage").text();
|
||||
|
||||
function getInstallStatus(){
|
||||
|
||||
url = "/websites/installWordpressStatus";
|
||||
|
||||
var data = {
|
||||
statusFile: statusFile,
|
||||
domainName: domain
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if(response.data.abort === 1){
|
||||
|
||||
if(response.data.installStatus === 1){
|
||||
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.installationFailed = true;
|
||||
$scope.installationSuccessfull = false;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.gitLoading = true;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$scope.installationURL = domain;
|
||||
|
||||
$("#installProgress").css("width", "100%");
|
||||
$scope.installPercentage = "100";
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout.cancel();
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.installationFailed = false;
|
||||
$scope.installationSuccessfull = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.gitLoading = true;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
$("#installProgress").css("width", "0%");
|
||||
$scope.installPercentage = "0";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
$("#installProgress").css("width", response.data.installationProgress + "%");
|
||||
$scope.installPercentage = response.data.installationProgress;
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
|
||||
$timeout(getInstallStatus,1000);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.canNotFetch = true;
|
||||
$scope.couldNotConnect = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$scope.attachRepo = function(){
|
||||
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.installationFailed = true;
|
||||
$scope.installationSuccessfull = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.gitLoading = false;
|
||||
$scope.installProg = false;
|
||||
|
||||
$scope.currentStatus = "Starting installation..";
|
||||
|
||||
url = "/websites/setupGitRepo";
|
||||
|
||||
var data = {
|
||||
domain: domain,
|
||||
username: $scope.githubUserName,
|
||||
reponame: $scope.githubRepo,
|
||||
branch: $scope.githubBranch
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
if (response.data.installStatus === 1)
|
||||
{
|
||||
statusFile = response.data.tempStatusPath;
|
||||
getInstallStatus();
|
||||
}
|
||||
else{
|
||||
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.installationFailed = false;
|
||||
$scope.installationSuccessfull = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.gitLoading = true;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
171
websiteFunctions/templates/websiteFunctions/setupGit.html
Normal file
171
websiteFunctions/templates/websiteFunctions/setupGit.html
Normal file
@@ -0,0 +1,171 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Attach Git - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Attach Git" %}</h2>
|
||||
<p>{% trans "Attach git to your website" %}</p>
|
||||
</div>
|
||||
|
||||
<div ng-controller="setupGit" 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' %}">
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
<ul class="list-group list-group-separator row list-group-icons">
|
||||
|
||||
<li class="col-md-3 active">
|
||||
<a href="#tab-example-1" data-toggle="tab" class="list-group-item">
|
||||
<i class="glyph-icon icon-dashboard"></i>
|
||||
{% trans "Github" %}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="col-md-3">
|
||||
<a href="#tab-example-3" data-toggle="tab" class="list-group-item">
|
||||
<i class="glyph-icon font-blue-alt icon-globe"></i>
|
||||
{% trans "Deployment Key" %}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade active in" id="tab-example-1">
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<form action="/" class="form-horizontal bordered-row">
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label style="color: green;" class="col-sm-10 control-label">{% trans "Before attaching repo to your website, make sure to place your Development key in your GIT repository." %}</label>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Github Username" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="githubUserName" required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Repository Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="githubRepo" required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Branch" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="githubBranch" required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<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 "Attach Now" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="" class="form-group">
|
||||
<label class="col-sm-2 control-label"></label>
|
||||
<div class="col-sm-7">
|
||||
|
||||
<div ng-hide="installProg" class="alert alert-success text-center">
|
||||
<h2>{$ currentStatus $}</h2>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installProg" class="progress">
|
||||
<div id="installProgress" class="progress-bar" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:0%">
|
||||
<span class="sr-only">70% Complete</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationFailed" class="alert alert-danger">
|
||||
<p>{% trans "Installation failed. Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationSuccessfull" class="alert alert-success">
|
||||
<p>{% trans "Installation successful. Visit:" %} {$ installationURL $}</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>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="tab-pane fade" id="tab-example-3">
|
||||
|
||||
<form action="/" class="form-horizontal bordered-row">
|
||||
|
||||
<!------ List of records --------------->
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
<!------ List of records --------------->
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -962,6 +962,18 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-4" style="margin-bottom: 2%;">
|
||||
|
||||
<a href="{$ setupGit $}" target="_blank" title="{% trans 'Attach Git with this website!' %}">
|
||||
<img src="{% static 'images/icons/git-logo.png' %}">
|
||||
</a>
|
||||
<a href="{$ setupGit $}" target="_blank" title="{% trans 'Attach Git with this website!' %}">
|
||||
<span style='font-size: 21px;font-family: "Times New Roman", Times, serif; padding-left: 2%'>{% trans "Git" %}</span>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="col-md-12">
|
||||
<form action="/" class="form-horizontal bordered-row">
|
||||
|
||||
@@ -89,4 +89,9 @@ urlpatterns = [
|
||||
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/joomlaInstall$', views.joomlaInstall, name='joomlaInstall'),
|
||||
|
||||
|
||||
## Git
|
||||
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/setupGit$', views.setupGit, name='setupGit'),
|
||||
url(r'^setupGitRepo$', views.setupGitRepo, name='setupGitRepo'),
|
||||
|
||||
|
||||
]
|
||||
@@ -2282,7 +2282,6 @@ def installWordpress(request):
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installWordpress]")
|
||||
return HttpResponse("Not Logged in as admin")
|
||||
|
||||
|
||||
def installWordpressStatus(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
@@ -2333,7 +2332,6 @@ def installWordpressStatus(request):
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
|
||||
def joomlaInstall(request, domain):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
@@ -2501,3 +2499,65 @@ def installJoomla(request):
|
||||
status = {"installStatus":0,"error":str(msg)}
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installJoomla]")
|
||||
return HttpResponse("Not Logged in as admin")
|
||||
|
||||
|
||||
def setupGit(request, domain):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
try:
|
||||
if admin.type != 1:
|
||||
website = Websites.objects.get(domain=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})
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return HttpResponse(str(msg))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def setupGitRepo(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['admin'] = admin
|
||||
extraArgs['domainName'] = data['domain']
|
||||
extraArgs['username'] = data['username']
|
||||
extraArgs['reponame'] = data['reponame']
|
||||
extraArgs['branch'] = data['branch']
|
||||
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
|
||||
background = ApplicationInstaller('git', extraArgs)
|
||||
background.start()
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
data_ret = {'installStatus': 1, 'error_message': 'None', 'tempStatusPath': extraArgs['tempStatusPath']}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'installStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except KeyError, msg:
|
||||
status = {"installStatus":0,"error":str(msg)}
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installWordpress]")
|
||||
return HttpResponse("Not Logged in as admin")
|
||||
Reference in New Issue
Block a user