From 3802ef87f47972f4217255e326a34bf477154766 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 23 Dec 2014 14:08:30 +0530 Subject: [PATCH] More tweaks to ee stack install --- ee/cli/plugins/stack.py | 11 +++++++++++ ee/cli/templates/auth-sql-conf.mustache | 11 +++++++++++ ee/cli/templates/dovecot-sql-conf.mustache | 12 ++++++++++++ ee/core/variables.py | 14 +++++++++++++- 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 ee/cli/templates/auth-sql-conf.mustache create mode 100644 ee/cli/templates/dovecot-sql-conf.mustache diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index c2f86606..90769bb4 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -182,6 +182,17 @@ class EEStackController(CementBaseController): with open('/etc/mysql/my.cnf', 'w') as configfile: config.write(configfile) + if set(EEVariables.ee_dovecot).issubset(set(apt_packages)): + EEShellExec.cmd_exec("adduser --uid 5000 --home /var/vmail" + "--disabled-password --gecos '' vmail") + EEShellExec.cmd_exec("openssl req -new -x509 -days 3650 -nodes" + "-subj /commonName={HOSTNAME}/emailAddres" + "s={EMAIL} -out /etc/ssl/certs/dovecot." + "pem -keyout /etc/ssl/private/dovecot.pem" + .format(HOSTNAME=EEVariables.ee_fqdn, + EMAIL=EEVariables.ee_email)) + EEShellExec.cmd_exec("chmod 0600 /etc/ssl/private/dovecot.pem") + if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): EEShellExec.cmd_exec("chmod +x /usr/bin/wp") diff --git a/ee/cli/templates/auth-sql-conf.mustache b/ee/cli/templates/auth-sql-conf.mustache new file mode 100644 index 00000000..8854747b --- /dev/null +++ b/ee/cli/templates/auth-sql-conf.mustache @@ -0,0 +1,11 @@ +passdb { + driver = sql + args = /etc/dovecot/dovecot-sql.conf.ext +} +userdb { + driver = prefetch +} +userdb { + driver = sql + args = /etc/dovecot/dovecot-sql.conf.ext +} diff --git a/ee/cli/templates/dovecot-sql-conf.mustache b/ee/cli/templates/dovecot-sql-conf.mustache new file mode 100644 index 00000000..8c76123d --- /dev/null +++ b/ee/cli/templates/dovecot-sql-conf.mustache @@ -0,0 +1,12 @@ +driver = mysql +connect = host=localhost user=vimbadmin password={{password}} dbname=vimbadmin +default_pass_scheme = MD5 +password_query = SELECT username as user, password as password, \ +homedir AS home, maildir AS mail, \ +concat('*:bytes=', quota) as quota_rule, uid, gid \ +FROM mailbox \ +WHERE username = '%Lu' AND active = '1' \ +AND ( access_restriction = 'ALL' OR LOCATE( access_restriction, '%Us' ) > 0 ) +user_query = SELECT homedir AS home, maildir AS mail, \ +concat('*:bytes=', quota) as quota_rule, uid, gid \ +FROM mailbox WHERE username = '%u' diff --git a/ee/core/variables.py b/ee/core/variables.py index 3618388d..71bb0072 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -1,15 +1,27 @@ """EasyEngine core variable module""" import platform +import socket +import confiparser +import os class EEVariables(): """Intialization of core variables""" + config = configparser.ConfigParser() + config.read(os.path.expanduser("~")+'/.gitconfig') # EasyEngine core variables ee_platform_distro = platform.linux_distribution()[0] ee_platform_version = platform.linux_distribution()[1] ee_platform_codename = platform.linux_distribution()[2] + # Get FQDN of system + ee_fqdn = socket.getfqdn() + + # Get git user name and EMail + ee_user = config['user']['name'] + ee_email = config['user']['email'] + # EasyEngine stack installation varibales # Nginx repo and packages if ee_platform_distro == 'Ubuntu': @@ -42,7 +54,7 @@ class EEVariables(): # Dovecot repo and packages ee_dovecot_repo = ("deb http://http.debian.net/debian-backports {codename}" "-backports main".format(codename=ee_platform_codename)) - + ee_dovecot = ["dovecot-core", "dovecot-imapd", "dovecot-pop3d", "dovecot-lmtpd", "dovecot-mysql", "dovecot-sieve", "dovecot-managesieved"]