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' ],
@@ -588,6 +591,20 @@ def post_pref(self, apt_packages, packages):
588591 out = ee_amavis )
589592 ee_amavis .close ()
590593
594+ # Amavis ViMbadmin configuration
595+ if os .path .isfile ("/etc/postfix/mysql/virtual_alias_maps.cf" ):
596+ vm_host = os .popen ("grep hosts /etc/postfix/mysql/virtual_"
597+ "alias_maps.cf | awk \' { print $3 }\' |"
598+ " tr -d '\\ n'" ).read ()
599+ vm_pass = os .popen ("grep password /etc/postfix/mysql/"
600+ "virtual_alias_maps.cf | awk \' { print "
601+ "$3 }\' | tr -d '\\ n'" ).read ()
602+
603+ data = dict (host = vm_host , password = vm_pass )
604+ vm_config = open ('/etc/amavis/conf.d/50-user' , 'w' )
605+ self .app .render ((data ), '50-user.mustache' , out = vm_config )
606+ vm_config .close ()
607+
591608 # Amavis postfix configuration
592609 EEShellExec .cmd_exec (self , "postconf -e \" content_filter = "
593610 "smtp-amavis:[127.0.0.1]:10024\" " )
@@ -948,7 +965,8 @@ def install(self, packages=[], apt_packages=[], disp_msg=True):
948965 (not self .app .pargs .php ) and (not self .app .pargs .mysql ) and
949966 (not self .app .pargs .postfix ) and (not self .app .pargs .wpcli ) and
950967 (not self .app .pargs .phpmyadmin ) and
951- (not self .app .pargs .adminer ) and (not self .app .pargs .utils )):
968+ (not self .app .pargs .adminer ) and (not self .app .pargs .utils ) and
969+ (not self .app .pargs .mailscanner )):
952970 self .app .pargs .web = True
953971
954972 if self .app .pargs .web :
@@ -975,6 +993,8 @@ def install(self, packages=[], apt_packages=[], disp_msg=True):
975993 self .app .pargs .postfix = True
976994
977995 if not EEAptGet .is_installed (self , 'dovecot-core' ):
996+ check_fqdn (self ,
997+ os .popen ("hostname -f | tr -d '\n '" ).read ())
978998 Log .debug (self , "Setting apt_packages variable for mail" )
979999 apt_packages = apt_packages + EEVariables .ee_mail
9801000 packages = packages + [["https://github.com/opensolutions/"
@@ -990,8 +1010,11 @@ def install(self, packages=[], apt_packages=[], disp_msg=True):
9901010 "Roundcube" ]]
9911011
9921012 if EEVariables .ee_ram > 1024 :
993- apt_packages = (apt_packages +
994- EEVariables .ee_mailscanner )
1013+ self .app .pargs .mailscanner = True
1014+ else :
1015+ Log .info (self , "System RAM is less than 1GB\n Mail "
1016+ "scanner packages are not going to install"
1017+ " automatically" )
9951018 else :
9961019 Log .info (self , "Mail server is already installed" )
9971020
@@ -1050,6 +1073,9 @@ def install(self, packages=[], apt_packages=[], disp_msg=True):
10501073 "htdocs/db/adminer/index.php" ,
10511074 "Adminer" ]]
10521075
1076+ if self .app .pargs .mailscanner :
1077+ apt_packages = (apt_packages + EEVariables .ee_mailscanner )
1078+
10531079 if self .app .pargs .utils :
10541080 Log .debug (self , "Setting packages variable for utils" )
10551081 packages = packages + [["http://phpmemcacheadmin.googlecode"
@@ -1149,6 +1175,9 @@ def remove(self):
11491175 EEMysql .execute (self , "drop database IF EXISTS vimbadmin" )
11501176 EEMysql .execute (self , "drop database IF EXISTS roundcubemail" )
11511177
1178+ if self .app .pargs .mailscanner :
1179+ apt_packages = (apt_packages + EEVariables .ee_mailscanner )
1180+
11521181 if self .app .pargs .nginx :
11531182 Log .debug (self , "Removing apt_packages variable of Nginx" )
11541183 apt_packages = apt_packages + EEVariables .ee_nginx
@@ -1225,6 +1254,9 @@ def purge(self):
12251254 EEMysql .execute (self , "drop database IF EXISTS vimbadmin" )
12261255 EEMysql .execute (self , "drop database IF EXISTS roundcubemail" )
12271256
1257+ if self .app .pargs .mailscanner :
1258+ apt_packages = (apt_packages + EEVariables .ee_mailscanner )
1259+
12281260 if self .app .pargs .nginx :
12291261 Log .debug (self , "Purge apt_packages variable of Nginx" )
12301262 apt_packages = apt_packages + EEVariables .ee_nginx
0 commit comments