@@ -766,71 +766,64 @@ def install_postfix_davecot(self):
766766
767767 command = 'dnf install --enablerepo=gf-plus postfix3 postfix3-mysql -y'
768768 else :
769- command = 'apt-get -y debconf-utils'
770- preFlightsChecks .call (command , self .distro , command , command , 1 , 0 , os .EX_OSERR )
771- file_name = self .cwd + '/pf.unattend.text'
772- pf = open (file_name , 'w' )
773- pf .write ('postfix postfix/mailname string ' + str (socket .getfqdn () + '\n ' ))
774- pf .write ('postfix postfix/main_mailer_type string "Internet Site"\n ' )
775- pf .close ()
776- command = 'debconf-set-selections ' + file_name
777- preFlightsChecks .call (command , self .distro , command , command , 1 , 0 , os .EX_OSERR )
778-
779- command = 'apt-get -y install postfix'
769+ # command = 'apt-get -y debconf-utils'
770+ # preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
771+ # file_name = self.cwd + '/pf.unattend.text'
772+ # pf = open(file_name, 'w')
773+ # pf.write('postfix postfix/mailname string ' + str(socket.getfqdn() + '\n'))
774+ # pf.write('postfix postfix/main_mailer_type string "Internet Site"\n')
775+ # pf.close()
776+ # command = 'debconf-set-selections ' + file_name
777+ # preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
778+
779+ command = 'apt-get -y install postfix postfix-mysql '
780780 # os.remove(file_name)
781781
782782 preFlightsChecks .call (command , self .distro , command , command , 1 , 1 , os .EX_OSERR )
783783
784- if self .distro == centos or self .distro == cent8 :
785- pass
786- else :
787- command = 'apt-get -y install dovecot-imapd dovecot-pop3d postfix-mysql'
788-
789- preFlightsChecks .call (command , self .distro , command , command , 1 , 1 , os .EX_OSERR )
790-
791784 ##
792785
793786 if self .distro == centos :
794787 command = 'yum --enablerepo=gf-plus -y install dovecot23 dovecot23-mysql'
795788 elif self .distro == cent8 :
796789 command = 'dnf install --enablerepo=gf-plus dovecot23 dovecot23-mysql -y'
797790 else :
798- command = 'apt-get -y install dovecot-mysql'
791+ command = 'apt-get -y install dovecot-mysql dovecot-imapd dovecot-pop3d '
799792
800793 preFlightsChecks .call (command , self .distro , command , command , 1 , 1 , os .EX_OSERR )
801794
802- if self .distro != centos :
803- command = 'curl https://repo.dovecot.org/DOVECOT-REPO-GPG | gpg --import'
804- subprocess .call (command , shell = True )
805-
806- command = 'gpg --export ED409DA1 > /etc/apt/trusted.gpg.d/dovecot.gpg'
807- subprocess .call (command , shell = True )
808-
809- debPath = '/etc/apt/sources.list.d/dovecot.list'
810- writeToFile = open (debPath , 'w' )
811- writeToFile .write ('deb https://repo.dovecot.org/ce-2.3-latest/ubuntu/bionic bionic main\n ' )
812- writeToFile .close ()
813-
814- try :
815- command = 'apt update -y'
816- subprocess .call (command , shell = True )
817- except :
818- pass
819-
820- try :
821- command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
822- subprocess .call (command , shell = True )
823-
824- command = 'dpkg --configure -a'
825- subprocess .call (command , shell = True )
826-
827- command = 'apt --fix-broken install -y'
828- subprocess .call (command , shell = True )
829-
830- command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
831- subprocess .call (command , shell = True )
832- except :
833- pass
795+ # if self.distro != centos:
796+ # command = 'curl https://repo.dovecot.org/DOVECOT-REPO-GPG | gpg --import'
797+ # subprocess.call(command, shell=True)
798+ #
799+ # command = 'gpg --export ED409DA1 > /etc/apt/trusted.gpg.d/dovecot.gpg'
800+ # subprocess.call(command, shell=True)
801+ #
802+ # debPath = '/etc/apt/sources.list.d/dovecot.list'
803+ # writeToFile = open(debPath, 'w')
804+ # writeToFile.write('deb https://repo.dovecot.org/ce-2.3-latest/ubuntu/bionic bionic main\n')
805+ # writeToFile.close()
806+ #
807+ # try:
808+ # command = 'apt update -y'
809+ # subprocess.call(command, shell=True)
810+ # except:
811+ # pass
812+ #
813+ # try:
814+ # command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
815+ # subprocess.call(command, shell=True)
816+ #
817+ # command = 'dpkg --configure -a'
818+ # subprocess.call(command, shell=True)
819+ #
820+ # command = 'apt --fix-broken install -y'
821+ # subprocess.call(command, shell=True)
822+ #
823+ # command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
824+ # subprocess.call(command, shell=True)
825+ # except:
826+ # pass
834827
835828 except BaseException as msg :
836829 logging .InstallLog .writeToFile ('[ERROR] ' + str (msg ) + " [install_postfix_davecot]" )
@@ -845,20 +838,14 @@ def setup_email_Passwords(self, mysqlPassword, mysql):
845838
846839 os .chdir (self .cwd )
847840
848- if mysql == 'Two' :
849- mysql_virtual_domains = "email-configs/mysql-virtual_domains.cf"
850- mysql_virtual_forwardings = "email-configs/mysql-virtual_forwardings.cf"
851- mysql_virtual_mailboxes = "email-configs/mysql-virtual_mailboxes.cf"
852- mysql_virtual_email2email = "email-configs/mysql-virtual_email2email.cf"
853- davecotmysql = "email-configs/dovecot-sql.conf.ext"
854- else :
855- mysql_virtual_domains = "email-configs-one/mysql-virtual_domains.cf"
856- mysql_virtual_forwardings = "email-configs-one/mysql-virtual_forwardings.cf"
857- mysql_virtual_mailboxes = "email-configs-one/mysql-virtual_mailboxes.cf"
858- mysql_virtual_email2email = "email-configs-one/mysql-virtual_email2email.cf"
859- davecotmysql = "email-configs-one/dovecot-sql.conf.ext"
841+ mysql_virtual_domains = "email-configs-one/mysql-virtual_domains.cf"
842+ mysql_virtual_forwardings = "email-configs-one/mysql-virtual_forwardings.cf"
843+ mysql_virtual_mailboxes = "email-configs-one/mysql-virtual_mailboxes.cf"
844+ mysql_virtual_email2email = "email-configs-one/mysql-virtual_email2email.cf"
845+ davecotmysql = "email-configs-one/dovecot-sql.conf.ext"
860846
861- ### update password:
847+
848+ ### update password:
862849
863850 data = open (davecotmysql , "r" ).readlines ()
864851
@@ -875,8 +862,6 @@ def setup_email_Passwords(self, mysqlPassword, mysql):
875862 else :
876863 writeDataToFile .writelines (items )
877864
878- # if self.distro == ubuntu:
879- # os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
880865
881866 writeDataToFile .close ()
882867
@@ -894,9 +879,6 @@ def setup_email_Passwords(self, mysqlPassword, mysql):
894879 else :
895880 writeDataToFile .writelines (items )
896881
897- # if self.distro == ubuntu:
898- # os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
899-
900882 writeDataToFile .close ()
901883
902884 ### update password:
@@ -913,9 +895,6 @@ def setup_email_Passwords(self, mysqlPassword, mysql):
913895 else :
914896 writeDataToFile .writelines (items )
915897
916- # if self.distro == ubuntu:
917- # os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
918-
919898 writeDataToFile .close ()
920899
921900 ### update password:
@@ -932,9 +911,6 @@ def setup_email_Passwords(self, mysqlPassword, mysql):
932911 else :
933912 writeDataToFile .writelines (items )
934913
935- # if self.distro == ubuntu:
936- # os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
937-
938914 writeDataToFile .close ()
939915
940916 ### update password:
@@ -951,9 +927,6 @@ def setup_email_Passwords(self, mysqlPassword, mysql):
951927 else :
952928 writeDataToFile .writelines (items )
953929
954- # if self.distro == ubuntu:
955- # os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
956-
957930 writeDataToFile .close ()
958931
959932
@@ -1060,37 +1033,24 @@ def setup_postfix_davecot_config(self, mysql):
10601033 # Cleanup config files for ubuntu
10611034 if self .distro == ubuntu :
10621035 preFlightsChecks .stdOut ("Cleanup postfix/dovecot config files" , 1 )
1063- if mysql == 'Two' :
1064- self .centos_lib_dir_to_ubuntu ("email-configs/master.cf" , "/usr/libexec/" , "/usr/lib/" )
1065- self .centos_lib_dir_to_ubuntu ("email-configs/main.cf" , "/usr/libexec/postfix" ,
1066- "/usr/lib/postfix/sbin" )
1067- else :
1068- self .centos_lib_dir_to_ubuntu ("email-configs-one/master.cf" , "/usr/libexec/" , "/usr/lib/" )
1069- self .centos_lib_dir_to_ubuntu ("email-configs-one/main.cf" , "/usr/libexec/postfix" ,
1070- "/usr/lib/postfix/sbin" )
1036+
1037+ self .centos_lib_dir_to_ubuntu ("email-configs-one/master.cf" , "/usr/libexec/" , "/usr/lib/" )
1038+ self .centos_lib_dir_to_ubuntu ("email-configs-one/main.cf" , "/usr/libexec/postfix" ,
1039+ "/usr/lib/postfix/sbin" )
10711040
10721041 ########### Copy config files
10731042
1074- if mysql == 'Two' :
1075- shutil .copy ("email-configs/mysql-virtual_domains.cf" , "/etc/postfix/mysql-virtual_domains.cf" )
1076- shutil .copy ("email-configs/mysql-virtual_forwardings.cf" , "/etc/postfix/mysql-virtual_forwardings.cf" )
1077- shutil .copy ("email-configs/mysql-virtual_mailboxes.cf" , "/etc/postfix/mysql-virtual_mailboxes.cf" )
1078- shutil .copy ("email-configs/mysql-virtual_email2email.cf" , "/etc/postfix/mysql-virtual_email2email.cf" )
1079- shutil .copy ("email-configs/main.cf" , main )
1080- shutil .copy ("email-configs/master.cf" , master )
1081- shutil .copy ("email-configs/dovecot.conf" , davecot )
1082- shutil .copy ("email-configs/dovecot-sql.conf.ext" , davecotmysql )
1083- else :
1084- shutil .copy ("email-configs-one/mysql-virtual_domains.cf" , "/etc/postfix/mysql-virtual_domains.cf" )
1085- shutil .copy ("email-configs-one/mysql-virtual_forwardings.cf" ,
1086- "/etc/postfix/mysql-virtual_forwardings.cf" )
1087- shutil .copy ("email-configs-one/mysql-virtual_mailboxes.cf" , "/etc/postfix/mysql-virtual_mailboxes.cf" )
1088- shutil .copy ("email-configs-one/mysql-virtual_email2email.cf" ,
1089- "/etc/postfix/mysql-virtual_email2email.cf" )
1090- shutil .copy ("email-configs-one/main.cf" , main )
1091- shutil .copy ("email-configs-one/master.cf" , master )
1092- shutil .copy ("email-configs-one/dovecot.conf" , davecot )
1093- shutil .copy ("email-configs-one/dovecot-sql.conf.ext" , davecotmysql )
1043+ shutil .copy ("email-configs-one/mysql-virtual_domains.cf" , "/etc/postfix/mysql-virtual_domains.cf" )
1044+ shutil .copy ("email-configs-one/mysql-virtual_forwardings.cf" ,
1045+ "/etc/postfix/mysql-virtual_forwardings.cf" )
1046+ shutil .copy ("email-configs-one/mysql-virtual_mailboxes.cf" , "/etc/postfix/mysql-virtual_mailboxes.cf" )
1047+ shutil .copy ("email-configs-one/mysql-virtual_email2email.cf" ,
1048+ "/etc/postfix/mysql-virtual_email2email.cf" )
1049+ shutil .copy ("email-configs-one/main.cf" , main )
1050+ shutil .copy ("email-configs-one/master.cf" , master )
1051+ shutil .copy ("email-configs-one/dovecot.conf" , davecot )
1052+ shutil .copy ("email-configs-one/dovecot-sql.conf.ext" , davecotmysql )
1053+
10941054
10951055 ######################################## Permissions
10961056
0 commit comments