1212from ee .core .mysql import EEMysql
1313from ee .core .addswap import EESwap
1414from ee .core .git import EEGit
15+ from ee .core .checkfqdn import check_fqdn
1516from pynginxconfig import NginxConfig
1617from ee .core .services import EEService
1718import 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\n Mail "
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
0 commit comments