@@ -29,7 +29,7 @@ def install(self):
2929
3030 def configure (self ):
3131 configure_remote_units (self .config .mail_domain , self .units )
32- self .need_restart , self .daemon_reload = _configure_dovecot (self .config )
32+ self .need_restart , self .daemon_reload = _configure_dovecot (self , self .config )
3333
3434 def activate (self ):
3535 activate_remote_units (self .units )
@@ -81,38 +81,30 @@ def _install_dovecot_package(package: str, arch: str):
8181 apt .deb (name = f"Install dovecot-{ package } " , src = deb_filename )
8282
8383
84- def _configure_dovecot (config : Config , debug : bool = False ) -> (bool , bool ):
84+
85+ def _configure_dovecot (deployer , config : Config , debug : bool = False ) -> (bool , bool ):
8586 """Configures Dovecot IMAP server."""
86- need_restart = False
87+ deployer . need_restart = False
8788 daemon_reload = False
8889
89- main_config = files .template (
90+ deployer .put_template (
91+ name = "Upload dovecot.conf" ,
9092 src = get_resource ("dovecot/dovecot.conf.j2" ),
9193 dest = "/etc/dovecot/dovecot.conf" ,
92- user = "root" ,
93- group = "root" ,
94- mode = "644" ,
9594 config = config ,
9695 debug = debug ,
9796 disable_ipv6 = config .disable_ipv6 ,
9897 )
99- need_restart |= main_config . changed
100- auth_config = files . put (
98+ deployer . put_file (
99+ name = "Upload auth.conf" ,
101100 src = get_resource ("dovecot/auth.conf" ),
102101 dest = "/etc/dovecot/auth.conf" ,
103- user = "root" ,
104- group = "root" ,
105- mode = "644" ,
106102 )
107- need_restart |= auth_config . changed
108- lua_push_notification_script = files . put (
103+ deployer . put_file (
104+ name = "Upload push_notification.lua" ,
109105 src = get_resource ("dovecot/push_notification.lua" ),
110106 dest = "/etc/dovecot/push_notification.lua" ,
111- user = "root" ,
112- group = "root" ,
113- mode = "644" ,
114107 )
115- need_restart |= lua_push_notification_script .changed
116108
117109 # as per https://doc.dovecot.org/2.3/configuration_manual/os/
118110 # it is recommended to set the following inotify limits
@@ -134,7 +126,7 @@ def _configure_dovecot(config: Config, debug: bool = False) -> (bool, bool):
134126 path = "/etc/environment" ,
135127 line = "TZ=:/etc/localtime" ,
136128 )
137- need_restart |= timezone_env .changed
129+ deployer . need_restart |= timezone_env .changed
138130
139131 restart_conf = files .put (
140132 name = "dovecot: restart automatically on failure" ,
@@ -144,10 +136,10 @@ def _configure_dovecot(config: Config, debug: bool = False) -> (bool, bool):
144136 daemon_reload |= restart_conf .changed
145137
146138 # Validate dovecot configuration before restart
147- if need_restart :
139+ if deployer . need_restart :
148140 server .shell (
149141 name = "Validate dovecot configuration" ,
150142 commands = ["doveconf -n >/dev/null" ],
151143 )
152144
153- return need_restart , daemon_reload
145+ return deployer . need_restart , daemon_reload
0 commit comments