diff --git a/lib/os/class.ISPConfigBaseOS.inc.php b/lib/os/class.ISPConfigBaseOS.inc.php index 52ac6aeec2782b36fda4c33c034d10f907798305..8d06c441f340c17da21a72228406dd446a69a7fd 100644 --- a/lib/os/class.ISPConfigBaseOS.inc.php +++ b/lib/os/class.ISPConfigBaseOS.inc.php @@ -320,6 +320,70 @@ class ISPConfigBaseOS { return true; } + protected function replaceLine($filename, $search_pattern, $new_line, $strict = false, $append = 1) { + $lines = @file($filename); + $out = ''; + $found = 0; + if(is_array($lines)) { + foreach($lines as $line) { + if($strict === false && preg_match('/^REGEX:(.*)$/', $search_pattern)) { + if(preg_match(substr($search_pattern, 6), $line)) { + $out .= $new_line."\n"; + $found = 1; + } else { + $out .= $line; + } + } elseif($strict === false) { + if(stristr($line, $search_pattern)) { + $out .= $new_line."\n"; + $found = 1; + } else { + $out .= $line; + } + } else { + if(trim($line) == $search_pattern) { + $out .= $new_line."\n"; + $found = 1; + } else { + $out .= $line; + } + } + } + } + + if($found == 0) { + //* add \n if the last line does not end with \n or \r + if(substr($out, -1) != "\n" && substr($out, -1) != "\r" && filesize($filename) > 0) $out .= "\n"; + //* add the new line at the end of the file + if($append == 1) { + $out .= $new_line."\n"; + } + } + file_put_contents($filename, $out); + } + + protected function removeLine($filename, $search_pattern, $strict = 0) { + if($lines = @file($filename)) { + $out = ''; + foreach($lines as $line) { + if($strict == 0 && preg_match('/^REGEX:(.*)$/', $search_pattern)) { + if(!preg_match(substr($search_pattern, 6), $line)) { + $out .= $line; + } + } elseif($strict == 0) { + if(!stristr($line, $search_pattern)) { + $out .= $line; + } + } else { + if(!trim($line) == $search_pattern) { + $out .= $line; + } + } + } + file_put_contents($filename, $out); + } + } + protected function getInstallCommand($packages) { if(is_string($packages)) { $packages = array($packages); diff --git a/lib/os/class.ISPConfigDebian12OS.inc.php b/lib/os/class.ISPConfigDebian12OS.inc.php index dd215577b7dcb0b04c1ed7d159e27768571bb65c..f4383a50213e1a8ed2996799cc57af7cdb420ed9 100644 --- a/lib/os/class.ISPConfigDebian12OS.inc.php +++ b/lib/os/class.ISPConfigDebian12OS.inc.php @@ -30,6 +30,7 @@ class ISPConfigDebian12OS extends ISPConfigDebian11OS { unset($packages[$key]); } $packages[] = 'getmail6'; + $packages[] = 'rsyslog'; } elseif($section === 'mail') { $key = array_search('rar', $packages, true); if($key !== false) { @@ -70,4 +71,9 @@ class ISPConfigDebian12OS extends ISPConfigDebian11OS { protected function getSystemPHPVersion() { return '8.2'; } + + protected function installRoundcube($mysql_root_pw) { + parent::installRoundcube($mysql_root_pw); + $this->replaceLine('/etc/roundcube/config.inc.php', "\$config['smtp_host']", "\$config['smtp_host'] = 'localhost:25';"); + } }