diff --git a/README.md b/README.md index ebe4719f7..11b3c2ecf 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index f4b189b76..4e0ea33ff 100644 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -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: diff --git a/plogical/sslUtilities.py b/plogical/sslUtilities.py index 2f222c246..84062460c 100644 --- a/plogical/sslUtilities.py +++ b/plogical/sslUtilities.py @@ -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): diff --git a/plogical/upgrade.py b/plogical/upgrade.py index 88e32e3d6..d53785f84 100644 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -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) diff --git a/static/images/icons/git-logo.png b/static/images/icons/git-logo.png new file mode 100644 index 000000000..72dee99e1 Binary files /dev/null and b/static/images/icons/git-logo.png differ diff --git a/static/websiteFunctions/websiteFunctions.js b/static/websiteFunctions/websiteFunctions.js index 8a4172522..44702490b 100644 --- a/static/websiteFunctions/websiteFunctions.js +++ b/static/websiteFunctions/websiteFunctions.js @@ -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) { + + + } }; diff --git a/websiteFunctions/static/images/icons/git-logo.png b/websiteFunctions/static/images/icons/git-logo.png new file mode 100644 index 000000000..72dee99e1 Binary files /dev/null and b/websiteFunctions/static/images/icons/git-logo.png differ diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js index 8a4172522..44702490b 100644 --- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js +++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js @@ -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) { + + + } }; diff --git a/websiteFunctions/templates/websiteFunctions/setupGit.html b/websiteFunctions/templates/websiteFunctions/setupGit.html new file mode 100644 index 000000000..aeca2bddf --- /dev/null +++ b/websiteFunctions/templates/websiteFunctions/setupGit.html @@ -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 %} + + +
{% trans "Attach git to your website" %}
+
+