Skip to content

Commit cf81922

Browse files
committed
Merge branch 'python' of github.com:rtCamp/easyengine into python
2 parents 4c4ac49 + cb04cda commit cf81922

File tree

4 files changed

+60
-4
lines changed

4 files changed

+60
-4
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ before_install:
1313
- rm -rf ~/.gnupg
1414

1515
before_script:
16+
- sudo bash -c 'echo example.com > /etc/hostname'
17+
- sudo service hostname restart
1618
- sudo apt-get -qq purge mysql* graphviz*
1719
- sudo apt-get -qq autoremove
1820

ee/cli/plugins/stack.py

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from ee.core.mysql import EEMysql
1313
from ee.core.addswap import EESwap
1414
from ee.core.git import EEGit
15+
from ee.core.checkfqdn import check_fqdn
1516
from pynginxconfig import NginxConfig
1617
from ee.core.services import EEService
1718
import random
@@ -44,6 +45,8 @@ class Meta:
4445
dict(help='Install admin tools stack', action='store_true')),
4546
(['--mail'],
4647
dict(help='Install mail server stack', action='store_true')),
48+
(['--mailscanner'],
49+
dict(help='Install mail scanner stack', action='store_true')),
4750
(['--nginx'],
4851
dict(help='Install Nginx stack', action='store_true')),
4952
(['--php'],
@@ -589,6 +592,20 @@ def post_pref(self, apt_packages, packages):
589592
out=ee_amavis)
590593
ee_amavis.close()
591594

595+
# Amavis ViMbadmin configuration
596+
if os.path.isfile("/etc/postfix/mysql/virtual_alias_maps.cf"):
597+
vm_host = os.popen("grep hosts /etc/postfix/mysql/virtual_"
598+
"alias_maps.cf | awk \'{ print $3 }\' |"
599+
" tr -d '\\n'").read()
600+
vm_pass = os.popen("grep password /etc/postfix/mysql/"
601+
"virtual_alias_maps.cf | awk \'{ print "
602+
"$3 }\' | tr -d '\\n'").read()
603+
604+
data = dict(host=vm_host, password=vm_pass)
605+
vm_config = open('/etc/amavis/conf.d/50-user', 'w')
606+
self.app.render((data), '50-user.mustache', out=vm_config)
607+
vm_config.close()
608+
592609
# Amavis postfix configuration
593610
EEShellExec.cmd_exec(self, "postconf -e \"content_filter = "
594611
"smtp-amavis:[127.0.0.1]:10024\"")
@@ -949,7 +966,8 @@ def install(self, packages=[], apt_packages=[], disp_msg=True):
949966
(not self.app.pargs.php) and (not self.app.pargs.mysql) and
950967
(not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and
951968
(not self.app.pargs.phpmyadmin) and
952-
(not self.app.pargs.adminer) and (not self.app.pargs.utils)):
969+
(not self.app.pargs.adminer) and (not self.app.pargs.utils) and
970+
(not self.app.pargs.mailscanner)):
953971
self.app.pargs.web = True
954972

955973
if self.app.pargs.web:
@@ -976,6 +994,8 @@ def install(self, packages=[], apt_packages=[], disp_msg=True):
976994
self.app.pargs.postfix = True
977995

978996
if not EEAptGet.is_installed(self, 'dovecot-core'):
997+
check_fqdn(self,
998+
os.popen("hostname -f | tr -d '\n'").read())
979999
Log.debug(self, "Setting apt_packages variable for mail")
9801000
apt_packages = apt_packages + EEVariables.ee_mail
9811001
packages = packages + [["https://github.com/opensolutions/"
@@ -991,8 +1011,11 @@ def install(self, packages=[], apt_packages=[], disp_msg=True):
9911011
"Roundcube"]]
9921012

9931013
if EEVariables.ee_ram > 1024:
994-
apt_packages = (apt_packages +
995-
EEVariables.ee_mailscanner)
1014+
self.app.pargs.mailscanner = True
1015+
else:
1016+
Log.info(self, "System RAM is less than 1GB\nMail "
1017+
"scanner packages are not going to install"
1018+
" automatically")
9961019
else:
9971020
Log.info(self, "Mail server is already installed")
9981021

@@ -1051,6 +1074,9 @@ def install(self, packages=[], apt_packages=[], disp_msg=True):
10511074
"htdocs/db/adminer/index.php",
10521075
"Adminer"]]
10531076

1077+
if self.app.pargs.mailscanner:
1078+
apt_packages = (apt_packages + EEVariables.ee_mailscanner)
1079+
10541080
if self.app.pargs.utils:
10551081
Log.debug(self, "Setting packages variable for utils")
10561082
packages = packages + [["http://phpmemcacheadmin.googlecode"
@@ -1150,6 +1176,9 @@ def remove(self):
11501176
EEMysql.execute(self, "drop database IF EXISTS vimbadmin")
11511177
EEMysql.execute(self, "drop database IF EXISTS roundcubemail")
11521178

1179+
if self.app.pargs.mailscanner:
1180+
apt_packages = (apt_packages + EEVariables.ee_mailscanner)
1181+
11531182
if self.app.pargs.nginx:
11541183
Log.debug(self, "Removing apt_packages variable of Nginx")
11551184
apt_packages = apt_packages + EEVariables.ee_nginx
@@ -1226,6 +1255,9 @@ def purge(self):
12261255
EEMysql.execute(self, "drop database IF EXISTS vimbadmin")
12271256
EEMysql.execute(self, "drop database IF EXISTS roundcubemail")
12281257

1258+
if self.app.pargs.mailscanner:
1259+
apt_packages = (apt_packages + EEVariables.ee_mailscanner)
1260+
12291261
if self.app.pargs.nginx:
12301262
Log.debug(self, "Purge apt_packages variable of Nginx")
12311263
apt_packages = apt_packages + EEVariables.ee_nginx

ee/cli/templates/50-user.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ $final_spam_destiny = D_PASS;
88

99
# We need to provide list of domains for which filtering need to be done
1010
@lookup_sql_dsn = (
11-
['DBI:mysql:database=vimbadmin;host=127.0.0.1;port=3306',
11+
['DBI:mysql:database=vimbadmin;host={{host}};port=3306',
1212
'vimbadmin',
1313
'{{password}}']);
1414

ee/core/checkfqdn.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from ee.core.shellexec import EEShellExec
2+
from ee.core.variables import EEVariables
3+
import os
4+
5+
6+
def check_fqdn(self, ee_host):
7+
#ee_host=os.popen("hostname -f | tr -d '\n'").read()
8+
if '.' in ee_host:
9+
EEVariables.ee_fqdn = ee_host
10+
with open('/etc/hostname', 'w') as hostfile:
11+
hostfile.write(ee_host)
12+
13+
EEShellExec.cmd_exec(self, "sed -i \"1i\\127.0.0.1 {0}\" /etc/hosts"
14+
.format(ee_host))
15+
if EEVariables.ee_platform_distro == 'debian':
16+
EEShellExec.cmd_exec(self, "/etc/init.d/hostname.sh start")
17+
else:
18+
EEShellExec.cmd_exec(self, "service hostname restart")
19+
20+
else:
21+
ee_host = input("Enter hostname [fqdn]:")
22+
check_fqdn(self, ee_host)

0 commit comments

Comments
 (0)