@@ -33,7 +33,7 @@ def install(self):
3333
3434 def configure (self ):
3535 configure_remote_units (self .config .mail_domain , self .units )
36- self .need_restart , self .daemon_reload = _configure_dovecot (self .config )
36+ self .need_restart , self .daemon_reload = _configure_dovecot (self , self .config )
3737
3838 def activate (self ):
3939 activate_remote_units (self .units )
@@ -85,38 +85,30 @@ def _install_dovecot_package(package: str, arch: str):
8585 apt .deb (name = f"Install dovecot-{ package } " , src = deb_filename )
8686
8787
88- def _configure_dovecot (config : Config , debug : bool = False ) -> (bool , bool ):
88+
89+ def _configure_dovecot (deployer , config : Config , debug : bool = False ) -> (bool , bool ):
8990 """Configures Dovecot IMAP server."""
90- need_restart = False
91+ deployer . need_restart = False
9192 daemon_reload = False
9293
93- main_config = files .template (
94+ deployer .put_template (
95+ name = "Upload dovecot.conf" ,
9496 src = get_resource ("dovecot/dovecot.conf.j2" ),
9597 dest = "/etc/dovecot/dovecot.conf" ,
96- user = "root" ,
97- group = "root" ,
98- mode = "644" ,
9998 config = config ,
10099 debug = debug ,
101100 disable_ipv6 = config .disable_ipv6 ,
102101 )
103- need_restart |= main_config . changed
104- auth_config = files . put (
102+ deployer . put_file (
103+ name = "Upload auth.conf" ,
105104 src = get_resource ("dovecot/auth.conf" ),
106105 dest = "/etc/dovecot/auth.conf" ,
107- user = "root" ,
108- group = "root" ,
109- mode = "644" ,
110106 )
111- need_restart |= auth_config . changed
112- lua_push_notification_script = files . put (
107+ deployer . put_file (
108+ name = "Upload push_notification.lua" ,
113109 src = get_resource ("dovecot/push_notification.lua" ),
114110 dest = "/etc/dovecot/push_notification.lua" ,
115- user = "root" ,
116- group = "root" ,
117- mode = "644" ,
118111 )
119- need_restart |= lua_push_notification_script .changed
120112
121113 # as per https://doc.dovecot.org/2.3/configuration_manual/os/
122114 # it is recommended to set the following inotify limits
@@ -139,7 +131,7 @@ def _configure_dovecot(config: Config, debug: bool = False) -> (bool, bool):
139131 path = "/etc/environment" ,
140132 line = "TZ=:/etc/localtime" ,
141133 )
142- need_restart |= timezone_env .changed
134+ deployer . need_restart |= timezone_env .changed
143135
144136 restart_conf = files .put (
145137 name = "dovecot: restart automatically on failure" ,
@@ -149,10 +141,10 @@ def _configure_dovecot(config: Config, debug: bool = False) -> (bool, bool):
149141 daemon_reload |= restart_conf .changed
150142
151143 # Validate dovecot configuration before restart
152- if need_restart :
144+ if deployer . need_restart :
153145 server .shell (
154146 name = "Validate dovecot configuration" ,
155147 commands = ["doveconf -n >/dev/null" ],
156148 )
157149
158- return need_restart , daemon_reload
150+ return deployer . need_restart , daemon_reload
0 commit comments