From bd1b59a3f811bc407e581d6edef6937855eba845 Mon Sep 17 00:00:00 2001
From: Florian Schaal <florian@schaal-24.de>
Date: Mon, 20 Nov 2017 17:14:03 +0100
Subject: [PATCH] support conf-custom for tag_as-files for postfix/amavis

---
 install/dist/lib/fedora.lib.php               | 22 +++++++++----------
 install/dist/lib/gentoo.lib.php               | 22 +++++++++----------
 install/dist/lib/opensuse.lib.php             | 22 +++++++++----------
 install/lib/installer_base.lib.php            | 12 ++++++----
 install/tpl/postfix-tag_as_foreign.re.master  |  1 +
 .../tpl/postfix-tag_as_originating.re.master  |  1 +
 6 files changed, 43 insertions(+), 37 deletions(-)
 create mode 100644 install/tpl/postfix-tag_as_foreign.re.master
 create mode 100644 install/tpl/postfix-tag_as_originating.re.master

diff --git a/install/dist/lib/fedora.lib.php b/install/dist/lib/fedora.lib.php
index 9537282f8a..f1c8d67204 100644
--- a/install/dist/lib/fedora.lib.php
+++ b/install/dist/lib/fedora.lib.php
@@ -103,17 +103,17 @@ class installer_dist extends installer_base {
 		$this->process_postfix_config('mysql-virtual_uids.cf');
 
 		//* postfix-dkim
-		$full_file_name=$config_dir.'/tag_as_originating.re';
-		if(is_file($full_file_name)) {
-			copy($full_file_name, $config_dir.$configfile.'~');
-		}
-		wf($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10026');
-
-		$full_file_name=$config_dir.'/tag_as_foreign.re';
-		if(is_file($full_file_name)) {
-			copy($full_file_name, $config_dir.$configfile.'~');
-		}
-		wf($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10024');
+		$filename='tag_as_originating.re';
+		$full_file_name=$config_dir.'/'.$filename;
+		if(is_file($full_file_name)) copy($full_file_name, $full_file_name.'~');
+		$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/postfix-'.$filename.'.master', 'tpl/postfix-'.$filename.'.master');
+		wf($full_file_name, $content);
+
+		$filename='tag_as_foreign.re';
+		$full_file_name=$config_dir.'/'.$filename;
+		if(is_file($full_file_name)) copy($full_file_name, $full_file_name.'~');
+		$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/postfix-'.$filename.'.master', 'tpl/postfix-'.$filename.'.master');
+		wf($full_file_name, $content);
 
 		//* Changing mode and group of the new created config files.
 		caselog('chmod o= '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null',
diff --git a/install/dist/lib/gentoo.lib.php b/install/dist/lib/gentoo.lib.php
index 7fdec46d85..b3cfc20719 100644
--- a/install/dist/lib/gentoo.lib.php
+++ b/install/dist/lib/gentoo.lib.php
@@ -212,17 +212,17 @@ class installer extends installer_base
 		}
 
 		//* postfix-dkim
-		$full_file_name=$config_dir.'/tag_as_originating.re';
-		if(is_file($full_file_name)) {
-			copy($full_file_name, $config_dir.$configfile.'~');
-		}
-		$this->write_config_file($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10026');
-
-		$full_file_name=$config_dir.'/tag_as_foreign.re';
-		if(is_file($full_file_name)) {
-			copy($full_file_name, $config_dir.$configfile.'~');
-		}
-		$this->write_config_file($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10024');
+		$filename='tag_as_originating.re';
+		$full_file_name=$config_dir.'/'.$filename;
+		if(is_file($full_file_name)) copy($full_file_name, $full_file_name.'~');
+		$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/postfix-'.$filename.'.master', 'tpl/postfix-'.$filename.'.master');
+		wf($full_file_name, $content);
+
+		$filename='tag_as_foreign.re';
+		$full_file_name=$config_dir.'/'.$filename;
+		if(is_file($full_file_name)) copy($full_file_name, $full_file_name.'~');
+		$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/postfix-'.$filename.'.master', 'tpl/postfix-'.$filename.'.master');
+		wf($full_file_name, $content);
 
 		//* Chmod and chown the .mailfilter file
 		$command = 'chown -R '.$cf['vmail_username'].':'.$cf['vmail_groupname'].' '.$cf['vmail_mailbox_base'].'/.mailfilter';
diff --git a/install/dist/lib/opensuse.lib.php b/install/dist/lib/opensuse.lib.php
index b9153a021c..f991c77d2b 100644
--- a/install/dist/lib/opensuse.lib.php
+++ b/install/dist/lib/opensuse.lib.php
@@ -100,17 +100,17 @@ class installer_dist extends installer_base {
 		$this->process_postfix_config('mysql-virtual_uids.cf');
 
 		//* postfix-dkim
-		$full_file_name=$config_dir.'/tag_as_originating.re';
-		if(is_file($full_file_name)) {
-			copy($full_file_name, $config_dir.$configfile.'~');
-		}
-		wf($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10026');
-
-		$full_file_name=$config_dir.'/tag_as_foreign.re';
-		if(is_file($full_file_name)) {
-			copy($full_file_name, $config_dir.$configfile.'~');
-		}
-		wf($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10024');
+		$filename='tag_as_originating.re';
+		$full_file_name=$config_dir.'/'.$filename;
+		if(is_file($full_file_name)) copy($full_file_name, $full_file_name.'~');
+		$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/postfix-'.$filename.'.master', 'tpl/postfix-'.$filename.'.master');
+		wf($full_file_name, $content);
+
+		$filename='tag_as_foreign.re';
+		$full_file_name=$config_dir.'/'.$filename;
+		if(is_file($full_file_name)) copy($full_file_name, $full_file_name.'~');
+		$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/postfix-'.$filename.'.master', 'tpl/postfix-'.$filename.'.master');
+		wf($full_file_name, $content);
 
 		//* Changing mode and group of the new created config files.
 		caselog('chmod o= '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null',
diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index d242fe753f..eb078a1e6e 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -901,13 +901,17 @@ class installer_base {
 		$this->process_postfix_config('mysql-virtual_uids.cf');
 
 		//* postfix-dkim
-		$full_file_name=$config_dir.'/tag_as_originating.re';
+		$filename='tag_as_originating.re';
+		$full_file_name=$config_dir.'/'.$filename;
 		if(is_file($full_file_name)) copy($full_file_name, $full_file_name.'~');
-		wf($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10026');
+		$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/postfix-'.$filename.'.master', 'tpl/postfix-'.$filename.'.master');
+		wf($full_file_name, $content);
 
-		$full_file_name=$config_dir.'/tag_as_foreign.re';
+		$filename='tag_as_foreign.re';
+		$full_file_name=$config_dir.'/'.$filename;
 		if(is_file($full_file_name)) copy($full_file_name, $full_file_name.'~');
-		wf($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10024');
+		$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/postfix-'.$filename.'.master', 'tpl/postfix-'.$filename.'.master');
+		wf($full_file_name, $content);
 
 		//* Changing mode and group of the new created config files.
 		caselog('chmod u=rw,g=r,o= '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null',
diff --git a/install/tpl/postfix-tag_as_foreign.re.master b/install/tpl/postfix-tag_as_foreign.re.master
new file mode 100644
index 0000000000..a5920256d5
--- /dev/null
+++ b/install/tpl/postfix-tag_as_foreign.re.master
@@ -0,0 +1 @@
+/^/ FILTER amavis:[127.0.0.1]:10024
diff --git a/install/tpl/postfix-tag_as_originating.re.master b/install/tpl/postfix-tag_as_originating.re.master
new file mode 100644
index 0000000000..a16fc0c644
--- /dev/null
+++ b/install/tpl/postfix-tag_as_originating.re.master
@@ -0,0 +1 @@
+/^/ FILTER amavis:[127.0.0.1]:10026
-- 
GitLab