@@ -1825,33 +1825,48 @@ public function configure_rspamd() {
18251825 fclose ($ fps );
18261826 unset($ dkim_domains );
18271827
1828- # local.d templates with template tags
1829- $ tpl = new tpl ();
1830- $ tpl ->newTemplate ('rspamd_dkim_signing.conf.master ' );
1831- $ tpl ->setVar ('dkim_path ' , $ mail_config ['dkim_path ' ]);
1832- wf ('/etc/rspamd/local.d/dkim_signing.conf ' , $ tpl ->grab ());
1833-
1834- $ tpl = new tpl ();
1835- $ tpl ->newTemplate ('rspamd_options.inc.master ' );
1836-
1828+ # look up values for use in template tags
18371829 $ local_addrs = array ();
18381830 $ ips = $ this ->db ->queryAllRecords ('SELECT `ip_address`, `ip_type` FROM ?? WHERE `server_id` = ? ' , $ conf ['mysql ' ]['database ' ].'.server_ip ' , $ conf ['server_id ' ]);
18391831 if (is_array ($ ips ) && !empty ($ ips )){
18401832 foreach ($ ips as $ ip ){
1841- $ local_addrs [] = array ('quoted_ip ' => "\"" .$ ip ['ip_address ' ]."\", \n" );
1833+ $ local_addrs [] = array (
1834+ 'ip ' => $ ip ['ip_address ' ],
1835+ 'quoted_ip ' => "\"" .$ ip ['ip_address ' ]."\", \n"
1836+ );
18421837 }
18431838 }
1844- $ tpl ->setLoop ('local_addrs ' , $ local_addrs );
1845- wf ('/etc/rspamd/local.d/options.inc ' , $ tpl ->grab ());
1839+
1840+ # local.d templates with template tags
1841+ # note: ensure these template files are in server/conf/ and symlinked in install/tpl/
1842+ $ local_d = array (
1843+ 'dkim_signing.conf ' ,
1844+ 'options.inc ' ,
1845+ 'redis.conf ' ,
1846+ 'classifier-bayes.conf ' ,
1847+ );
1848+ foreach ($ local_d as $ f ) {
1849+ $ tpl = new tpl ();
1850+ $ tpl ->newTemplate ("rspamd_ $ {f}.master " );
1851+
1852+ $ tpl ->setVar ('dkim_path ' , $ mail_config ['dkim_path ' ]);
1853+ $ tpl ->setVar ('rspamd_redis_servers ' , $ mail_config ['rspamd_redis_servers ' ]);
1854+ $ tpl ->setVar ('rspamd_redis_password ' , $ mail_config ['rspamd_redis_password ' ]);
1855+ $ tpl ->setVar ('rspamd_redis_bayes_servers ' , $ mail_config ['rspamd_redis_bayes_servers ' ]);
1856+ $ tpl ->setVar ('rspamd_redis_bayes_password ' , $ mail_config ['rspamd_redis_bayes_password ' ]);
1857+ if (count ($ local_addrs ) > 0 ) {
1858+ $ tpl ->setLoop ('local_addrs ' , $ local_addrs );
1859+ }
1860+
1861+ wf ("/etc/rspamd/local.d/ $ {f}" , $ tpl ->grab ());
1862+ }
1863+
18461864
18471865 # local.d templates without template tags
18481866 $ local_d = array (
18491867 'groups.conf ' ,
18501868 'antivirus.conf ' ,
1851- 'classifier-bayes.conf ' ,
1852- 'greylist.conf ' ,
18531869 'mx_check.conf ' ,
1854- 'redis.conf ' ,
18551870 'milter_headers.conf ' ,
18561871 'neural.conf ' ,
18571872 'neural_group.conf ' ,
@@ -1894,6 +1909,11 @@ public function configure_rspamd() {
18941909 }
18951910 }
18961911
1912+ # rename rspamd templates we no longer use
1913+ if (file_exists ("/etc/rspamd/local.d/greylist.conf " )) {
1914+ rename ("/etc/rspamd/local.d/greylist.conf " , "/etc/rspamd/local.d/greylist.old " );
1915+ }
1916+
18971917
18981918 exec ('chmod a+r /etc/rspamd/local.d/* /etc/rspamd/local.d/maps.d/* /etc/rspamd/override.d/* ' );
18991919
0 commit comments