mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-05-07 00:16:16 +02:00
internal bug fix for ubuntu
This commit is contained in:
@@ -562,6 +562,8 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
## checking for directories/files
|
||||
|
||||
logging.writeToFile(finalPath)
|
||||
|
||||
if self.dataLossCheck(finalPath, tempStatusPath) == 0:
|
||||
return 0
|
||||
|
||||
@@ -573,8 +575,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
try:
|
||||
|
||||
command = 'sudo GIT_SSH_COMMAND="ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no" git clone ' \
|
||||
'--depth 1 --no-single-branch git@' + defaultProvider +'.com:' + username + '/' + reponame + '.git -b ' + branch + ' ' + finalPath
|
||||
command = 'sudo git clone https://' + defaultProvider +'.com/' + username + '/' + reponame + ' -b ' + branch + ' ' + finalPath
|
||||
subprocess.check_output(shlex.split(command))
|
||||
except subprocess.CalledProcessError, msg:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
@@ -605,9 +606,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
|
||||
except BaseException, msg:
|
||||
|
||||
os.remove('/home/cyberpanel/' + domainName + '.git')
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines(str(msg) + " [404]")
|
||||
statusFile.close()
|
||||
@@ -630,14 +629,14 @@ class ApplicationInstaller(multi.Thread):
|
||||
logging.writeToFile('Git is not setup for this website.')
|
||||
return 0
|
||||
|
||||
command = 'sudo GIT_SSH_COMMAND="ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no" git -C ' + finalPath + ' pull'
|
||||
command = 'sudo git --git-dir=' + finalPath + '.git --work-tree=' + finalPath +' pull'
|
||||
subprocess.check_output(shlex.split(command))
|
||||
|
||||
##
|
||||
|
||||
website = Websites.objects.get(domain=domain)
|
||||
externalApp = website.externalApp
|
||||
|
||||
##
|
||||
|
||||
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath
|
||||
cmd = shlex.split(command)
|
||||
subprocess.call(cmd)
|
||||
|
||||
@@ -22,146 +22,6 @@ from datetime import datetime
|
||||
class FTPUtilities:
|
||||
|
||||
|
||||
# This function will only install FTP
|
||||
@staticmethod
|
||||
def installProFTPD():
|
||||
try:
|
||||
cmd = []
|
||||
|
||||
|
||||
cmd.append("yum")
|
||||
cmd.append("-y")
|
||||
cmd.append("install")
|
||||
cmd.append("proftpd-mysql")
|
||||
res = subprocess.call(cmd)
|
||||
if res == 1:
|
||||
print("###############################################")
|
||||
print(" Could not install ProFTPD ")
|
||||
print("###############################################")
|
||||
sys.exit()
|
||||
else:
|
||||
print("###############################################")
|
||||
print(" ProFTPD Installed ")
|
||||
print("###############################################")
|
||||
except OSError,msg:
|
||||
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installProFTPD]")
|
||||
return 0
|
||||
except ValueError,msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [installProFTPD]")
|
||||
return 0
|
||||
|
||||
return 1
|
||||
|
||||
@staticmethod
|
||||
def createFTPDataBaseinMariaDB(username,password):
|
||||
try:
|
||||
|
||||
#Create DB
|
||||
#sql.mysqlUtilities.createDatabase("1qaz@9xvps", "ftp", username, password)
|
||||
|
||||
#Add group
|
||||
cmd = []
|
||||
|
||||
cmd.append("groupadd")
|
||||
cmd.append("-g")
|
||||
cmd.append("2001")
|
||||
cmd.append("ftpgroup")
|
||||
|
||||
res = subprocess.call(cmd)
|
||||
if res == 1:
|
||||
print "Group adding failed"
|
||||
else:
|
||||
print "Group added"
|
||||
|
||||
#Add user to group
|
||||
|
||||
cmd = []
|
||||
|
||||
cmd.append("useradd")
|
||||
cmd.append("-u")
|
||||
cmd.append("2001")
|
||||
cmd.append("-s")
|
||||
cmd.append("/bin/false")
|
||||
cmd.append("-d")
|
||||
cmd.append("/bin/null")
|
||||
cmd.append("-c")
|
||||
cmd.append("\"proftpd user\"")
|
||||
cmd.append("-g")
|
||||
cmd.append("ftpgroup")
|
||||
cmd.append("ftpuser")
|
||||
|
||||
res = subprocess.call(cmd)
|
||||
if res == 1:
|
||||
print "User adding failed"
|
||||
else:
|
||||
print "User added"
|
||||
|
||||
#query = "CREATE TABLE ftp_ftpuser (id int(10) unsigned NOT NULL auto_increment,userid varchar(32) NOT NULL default '',passwd varchar(32) NOT NULL default '',uid smallint(6) NOT NULL default '2001',gid smallint(6) NOT NULL default '2001',homedir varchar(255) NOT NULL default '',shell varchar(16) NOT NULL default '/sbin/nologin',count int(11) NOT NULL default '0',accessed datetime NOT NULL default '0000-00-00 00:00:00',modified datetime NOT NULL default '0000-00-00 00:00:00',PRIMARY KEY (id),UNIQUE KEY userid (userid)) ENGINE=MyISAM COMMENT='ProFTP user table';"
|
||||
#sql.mysqlUtilities.SendQuery(username,password,"ftp", query)
|
||||
|
||||
#query = "CREATE TABLE ftpgroup (groupname varchar(16) NOT NULL default '',gid smallint(6) NOT NULL default '2001',members varchar(16) NOT NULL default '',KEY groupname (groupname)) ENGINE=MyISAM COMMENT='ProFTP group table';"
|
||||
#sql.mysqlUtilities.SendQuery(username, password, "ftp", query)
|
||||
|
||||
#query = "INSERT INTO ftpgroup (groupname, gid, members) VALUES ('ftpgroup', '2001', 'ftp_ftpuser');"
|
||||
#sql.mysqlUtilities.SendQuery(username, password, "ftp", query)
|
||||
|
||||
# File Write
|
||||
lines = open("/etc/proftpd.conf").readlines()
|
||||
data = open("/etc/proftpd.conf", "w")
|
||||
|
||||
line1 = "\nLoadModule mod_sql.c\n"
|
||||
line2 = "LoadModule mod_sql_mysql.c\n\n"
|
||||
|
||||
line3 = "SQLAuthTypes Plaintext Crypt\n"
|
||||
line4 = "SQLAuthenticate users groups\n\n"
|
||||
|
||||
line5 = "SQLConnectInfo cybercp@localhost "+username+" "+password+"\n"
|
||||
line6 = "SQLUserInfo ftp_ftp_ftpuser userid passwd uid gid homedir shell\n"
|
||||
line7 = "SQLGroupInfo ftp_ftpgroup groupname gid members\n\n"
|
||||
|
||||
line8 = "SQLLog PASS updatecount\n"
|
||||
line9 = "SQLNamedQuery updatecount UPDATE \"count=count+1, accessed=now() WHERE userid='%u'\" ftp_ftpuser\n\n"
|
||||
|
||||
line10 = "SQLLog STOR,DELE modified\n"
|
||||
line11 = "SQLNamedQuery modified UPDATE \"modified=now() WHERE userid='%u'\" ftp_ftpuser"
|
||||
|
||||
Auth0 = "\n#AuthPAMConfig\n"
|
||||
Auth1 = "#AuthOrder\n"
|
||||
for items in lines:
|
||||
if ((items.find("AuthPAMConfig") > -1)):
|
||||
data.writelines(Auth0)
|
||||
continue
|
||||
|
||||
if ((items.find("AuthOrder") > -1)):
|
||||
data.writelines(Auth1)
|
||||
continue
|
||||
|
||||
data.writelines(items)
|
||||
|
||||
|
||||
data.writelines(line1)
|
||||
data.writelines(line2)
|
||||
data.writelines(line3)
|
||||
data.writelines(line4)
|
||||
data.writelines(line5)
|
||||
data.writelines(line6)
|
||||
data.writelines(line7)
|
||||
data.writelines(line8)
|
||||
data.writelines(line9)
|
||||
data.writelines(line10)
|
||||
data.writelines(line11)
|
||||
|
||||
data.close()
|
||||
|
||||
#File Write End
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [IO Error with proftpd config file [createFTPDataBaseinMariaDB]]")
|
||||
return 0
|
||||
return 1
|
||||
|
||||
@staticmethod
|
||||
def createNewFTPAccount(udb,upass,username,password,path):
|
||||
try:
|
||||
|
||||
@@ -12,6 +12,7 @@ import shlex
|
||||
from mailServer.models import Domains,EUsers
|
||||
from emailPremium.models import DomainLimits, EmailLimits
|
||||
from websiteFunctions.models import Websites
|
||||
from processUtilities import ProcessUtilities
|
||||
|
||||
|
||||
class mailUtilities:
|
||||
@@ -372,7 +373,10 @@ milter_default_action = accept
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
command = 'sudo yum install spamassassin -y'
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
command = 'sudo yum install spamassassin -y'
|
||||
else:
|
||||
command = 'sudo apt-get install spamassassin spamc -y'
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import installUtilities
|
||||
import argparse
|
||||
import os
|
||||
from mailUtilities import mailUtilities
|
||||
from processUtilities import ProcessUtilities
|
||||
|
||||
class phpUtilities:
|
||||
|
||||
@@ -17,7 +18,10 @@ class phpUtilities:
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
command = 'sudo yum install '+extension +' -y'
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
command = 'sudo yum install ' + extension + ' -y'
|
||||
else:
|
||||
command = 'sudo apt-get install ' + extension + ' -y'
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
@@ -45,7 +49,10 @@ class phpUtilities:
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
command = 'sudo rpm --nodeps -e ' + extension + ' -v'
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
command = 'sudo rpm --nodeps -e ' + extension + ' -v'
|
||||
else:
|
||||
command = 'sudo apt-get remove -y ' + extension
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ from CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
import subprocess
|
||||
import shlex
|
||||
import os
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
|
||||
class ProcessUtilities:
|
||||
litespeedProcess = "litespeed"
|
||||
@@ -74,7 +73,7 @@ class ProcessUtilities:
|
||||
try:
|
||||
res = subprocess.call(shlex.split(command))
|
||||
if res == 1:
|
||||
raise 0
|
||||
return 0
|
||||
else:
|
||||
return 1
|
||||
except BaseException, msg:
|
||||
@@ -115,18 +114,5 @@ class ProcessUtilities:
|
||||
else:
|
||||
return ProcessUtilities.centos
|
||||
|
||||
@staticmethod
|
||||
def executioner(command, statusFile):
|
||||
try:
|
||||
res = subprocess.call(shlex.split(command), stdout=statusFile, stderr=statusFile)
|
||||
if res == 1:
|
||||
raise 0
|
||||
else:
|
||||
return 1
|
||||
|
||||
except BaseException, msg:
|
||||
logging.writeToFile(str(msg))
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ class vhost:
|
||||
accessControlEnds = " }\n"
|
||||
|
||||
rewriteInherit = """ rewrite {
|
||||
inherit 0
|
||||
inherit 1
|
||||
|
||||
}
|
||||
"""
|
||||
|
||||
@@ -31,6 +31,7 @@ import hashlib
|
||||
from mysqlUtilities import mysqlUtilities
|
||||
from plogical import hashPassword
|
||||
from emailMarketing.emACL import emACL
|
||||
from processUtilities import ProcessUtilities
|
||||
|
||||
class WebsiteManager:
|
||||
def __init__(self, domain = None, childDomain = None):
|
||||
@@ -1253,18 +1254,23 @@ class WebsiteManager:
|
||||
|
||||
website = Websites.objects.get(domain=self.domain)
|
||||
|
||||
try:
|
||||
subprocess.call(('sudo', 'crontab', '-u', website.externalApp, '-'))
|
||||
except:
|
||||
pass
|
||||
|
||||
output = subprocess.check_output(["sudo", "/usr/bin/crontab", "-u", website.externalApp, "-l"])
|
||||
|
||||
if "no crontab for" in output:
|
||||
echo = subprocess.Popen(('echo'), stdout=subprocess.PIPE)
|
||||
output = subprocess.call(('sudo', 'crontab', '-u', website.externalApp, '-'), stdin=echo.stdout)
|
||||
echo = subprocess.Popen((['cat', '/dev/null']), stdout=subprocess.PIPE)
|
||||
subprocess.call(('sudo', 'crontab', '-u', website.externalApp, '-'), stdin=echo.stdout)
|
||||
echo.wait()
|
||||
echo.stdout.close()
|
||||
|
||||
if "no crontab for" in output:
|
||||
data_ret = {'addNewCron': 0, 'error_message': 'Unable to initialise crontab file for user'}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
output = subprocess.check_output(["sudo", "/usr/bin/crontab", "-u", website.externalApp, "-l"])
|
||||
if "no crontab for" in output:
|
||||
data_ret = {'addNewCron': 0, 'error_message': 'Unable to initialise crontab file for user'}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
tempPath = "/home/cyberpanel/" + website.externalApp + str(randint(10000, 99999)) + ".cron.tmp"
|
||||
|
||||
@@ -1732,7 +1738,10 @@ class WebsiteManager:
|
||||
return render(request, 'websiteFunctions/setupGit.html',
|
||||
{'domainName': self.domain, 'installed': 1, 'webhookURL': webhookURL})
|
||||
else:
|
||||
command = 'sudo cat /root/.ssh/cyberpanel.pub'
|
||||
command = "sudo ssh-keygen -f /root/.ssh/" + self.domain + " -t rsa -N ''"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'sudo cat /root/.ssh/' + self.domain + '.pub'
|
||||
deploymentKey = subprocess.check_output(shlex.split(command)).strip('\n')
|
||||
|
||||
return render(request, 'websiteFunctions/setupGit.html',
|
||||
|
||||
Reference in New Issue
Block a user