Skip to content

Commit

Permalink
cpanel importer
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Jul 3, 2019
1 parent 2615300 commit 5c8e25e
Show file tree
Hide file tree
Showing 15 changed files with 978 additions and 23 deletions.
8 changes: 8 additions & 0 deletions CyberCP/secMiddleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ def __call__(self, request):
for key, value in data.iteritems():
if request.path.find('gitNotify') > -1:
break

# if request.path.find('users') > -1 or request.path.find('firewall') > -1 or request.path.find('servicesAction') > -1 or request.path.find('sslForHostName') > -1:
# logging.writeToFile(request.body)
# final_dic = {'error_message': "Data supplied is not accepted.",
# "errorMessage": "Data supplied is not accepted."}
# final_json = json.dumps(final_dic)
# return HttpResponse(final_json)

if type(value) == str or type(value) == unicode:
pass
else:
Expand Down
2 changes: 1 addition & 1 deletion dns/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class Domains(models.Model):
admin = models.ForeignKey(Administrator,on_delete=models.CASCADE, null=True)
admin = models.ForeignKey(Administrator,on_delete=models.CASCADE, default=1, null=True)
name = models.CharField(unique=True, max_length=255)
master = models.CharField(max_length=128, blank=True, null=True)
last_check = models.IntegerField(blank=True, null=True)
Expand Down
2 changes: 1 addition & 1 deletion install/email-configs-one/dovecot-sql.conf.ext
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
driver = mysql
connect = host=localhost dbname=cyberpanel user=cyberpanel password=1qaz@9xvps
default_pass_scheme = PLAIN
password_query = SELECT email as user, password FROM e_users WHERE email='%u';
user_query = SELECT '5000' as uid, '5000' as gid, mail FROM e_users WHERE email='%u';
25 changes: 22 additions & 3 deletions install/email-configs-one/dovecot.conf
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
protocols = imap pop3
log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_location = maildir:/home/vmail/%d/%n/Maildir
#mail_location = maildir:/home/vmail/%d/%n/Maildir
#mail_location = mdbox:/home/vmail/%d/%n/Mdbox

ssl_cert = <cert.pem
ssl_key = <key.pem

mail_plugins = zlib

mdbox_rotate_size = 2M

namespace {
type = private
separator = .
Expand Down Expand Up @@ -35,10 +40,17 @@ protocol lda {
log_path = /home/vmail/dovecot-deliver.log
auth_socket_path = /var/run/dovecot/auth-master
postmaster_address = postmaster@example.com

mail_plugins = zlib
}

protocol pop3 {
pop3_uidl_format = %08Xu%08Xv
mail_plugins = $mail_plugins zlib
}

protocol imap {
mail_plugins = $mail_plugins zlib imap_zlib
}

passdb {
Expand All @@ -47,6 +59,13 @@ passdb {
}

userdb {
driver = static
args = uid=5000 gid=5000 home=/home/vmail/%d/%n allow_all_users=yes
driver = sql
args = /etc/dovecot/dovecot-sql.conf.ext
}

plugin {

zlib_save = gz
zlib_save_level = 6

}
2 changes: 1 addition & 1 deletion install/email-configs/dovecot-sql.conf.ext
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
driver = mysql
connect = host=127.0.0.1 dbname=cyberpanel user=cyberpanel password=1qaz@9xvps
default_pass_scheme = PLAIN
password_query = SELECT email as user, password FROM e_users WHERE email='%u';
user_query = SELECT '5000' as uid, '5000' as gid, mail FROM e_users WHERE email='%u';
26 changes: 23 additions & 3 deletions install/email-configs/dovecot.conf
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
protocols = imap pop3
log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_location = maildir:/home/vmail/%d/%n/Maildir
#mail_location = maildir:/home/vmail/%d/%n/Maildir
#mail_location = mdbox:/home/vmail/%d/%n/Mdbox

ssl_cert = <cert.pem
ssl_key = <key.pem

mail_plugins = zlib

mdbox_rotate_size = 2M

namespace {
type = private
separator = .
Expand Down Expand Up @@ -35,10 +40,17 @@ protocol lda {
log_path = /home/vmail/dovecot-deliver.log
auth_socket_path = /var/run/dovecot/auth-master
postmaster_address = postmaster@example.com

mail_plugins = zlib
}

protocol pop3 {
pop3_uidl_format = %08Xu%08Xv
mail_plugins = $mail_plugins zlib
}

protocol imap {
mail_plugins = $mail_plugins zlib imap_zlib
}

passdb {
Expand All @@ -47,6 +59,14 @@ passdb {
}

userdb {
driver = static
args = uid=5000 gid=5000 home=/home/vmail/%d/%n allow_all_users=yes
driver = sql
args = /etc/dovecot/dovecot-sql.conf.ext
}


plugin {

zlib_save = gz
zlib_save_level = 6

}
20 changes: 17 additions & 3 deletions install/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ def download_install_CyberPanel(self, mysqlPassword, mysql):

os.chdir(self.path)

command = "wget http://cyberpanel.sh/CyberPanel.1.8.4.tar.gz"
command = "wget http://cyberpanel.sh/CyberPanel.1.8.5.tar.gz"
#command = "wget http://cyberpanel.sh/CyberPanelTemp.tar.gz"
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'CyberPanel Download',
Expand All @@ -923,7 +923,7 @@ def download_install_CyberPanel(self, mysqlPassword, mysql):
##

count = 0
command = "tar zxf CyberPanel.1.8.4.tar.gz"
command = "tar zxf CyberPanel.1.8.5.tar.gz"
#command = "tar zxf CyberPanelTemp.tar.gz"
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'Extract CyberPanel',1, 1, os.EX_OSERR)
Expand Down Expand Up @@ -1168,6 +1168,20 @@ def download_install_phpmyadmin(self):

def install_postfix_davecot(self):
self.stdOut("Install dovecot - first remove postfix")

if self.distro == centos:
path = '/etc/yum.repos.d/dovecot.repo'
content = """[dovecot-2.3-latest]
name=Dovecot 2.3 CentOS $releasever - $basearch
baseurl=http://repo.dovecot.org/ce-2.3-latest/centos/$releasever/RPMS/$basearch
gpgkey=https://repo.dovecot.org/DOVECOT-REPO-GPG
gpgcheck=1
enabled=1"""
writeToFile = open(path, 'w')
writeToFile.write(content)
writeToFile.close()


try:
if self.distro == centos:
command = 'yum remove postfix -y'
Expand Down Expand Up @@ -3620,7 +3634,7 @@ def main():
checks.fix_selinux_issue()
checks.install_psmisc()

if args.postfix != None:
if args.postfix == None:
checks.install_postfix_davecot()
checks.setup_email_Passwords(installCyberPanel.InstallCyberPanel.mysqlPassword, mysql)
checks.setup_postfix_davecot_config(mysql)
Expand Down
2 changes: 1 addition & 1 deletion loginSystem/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def loadLoginPage(request):
firstName="Cyber",lastName="Panel", acl=acl, token=token)
admin.save()

vers = version(currentVersion="1.8", build=4)
vers = version(currentVersion="1.8", build=5)
vers.save()

package = Package(admin=admin, packageName="Default", diskSpace=1000,
Expand Down
14 changes: 9 additions & 5 deletions mailServer/mailserverManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,17 +335,21 @@ def submitPasswordChange(self):
return ACLManager.loadErrorJson('passChangeStatus', 0)

data = json.loads(self.request.body)
domain = data['domain']
email = data['email']
password = data['password']

emailDB = EUsers.objects.get(email=email)
emailDB.delete()

dom = Domains(domain=domain)
CentOSPath = '/etc/redhat-release'
if os.path.exists(CentOSPath):
command = 'doveadm pw -p %s' % (password)
password = ProcessUtilities.outputExecutioner(command).strip('\n')
emailDB.password = password
else:
emailDB.password = password

emailDB.save()

emailAcct = EUsers(emailOwner=dom, email=email, password=password)
emailAcct.save()

data_ret = {'status': 1, 'passChangeStatus': 1, 'error_message': "None"}
json_data = json.dumps(data_ret)
Expand Down
2 changes: 2 additions & 0 deletions mailServer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class EUsers(models.Model):
emailOwner = models.ForeignKey(Domains, on_delete=models.CASCADE)
email = models.CharField(primary_key=True, max_length=80)
password = models.CharField(max_length=200)
mail = models.CharField(max_length=200, default='')


class Meta:
db_table = 'e_users'
Expand Down
4 changes: 3 additions & 1 deletion plogical/CyberCPLogFileWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ def statusWriter(tempStatusPath, mesg, append = None):
statusFile = open(tempStatusPath, 'w')
else:
statusFile = open(tempStatusPath, 'a')
statusFile.writelines(mesg)
statusFile.writelines(mesg + '\n')
statusFile.close()
print(mesg + '\n')
except BaseException, msg:
CyberCPLogFileWriter.writeToFile(str(msg) + ' [statusWriter]')
print str(msg)

2 changes: 1 addition & 1 deletion plogical/adminPass.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def main():
firstName="Cyber", lastName="Panel", acl=acl, token=token)
admin.save()

vers = version(currentVersion="1.8", build=4)
vers = version(currentVersion="1.8", build=5)
vers.save()

package = Package(admin=admin, packageName="Default", diskSpace=1000,
Expand Down
Loading

0 comments on commit 5c8e25e

Please sign in to comment.