Projects
Kolab:16:Testing
roundcubemail-selfcontained
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 72
View file
roundcubemail.spec
Changed
@@ -85,6 +85,8 @@ Source200: 2017111400.sql +Source301: migrateconfig.sh + Patch201: default-configuration.patch Patch202: roundcubemail-1.4-beta86-plugin-enigma-homedir.patch Patch203: 0001-On-mysql-5.6-191-bytes-length-is-the-best-we-can-do-.patch @@ -296,6 +298,8 @@ rm -rvf ${dir} done +cp -vf %{SOURCE301} bin/migrateconfig.sh + %if 0%{?plesk} > 0 cp -vf %{SOURCE100} config/config.inc.php.sample cp -vf %{SOURCE101} plugins/managesieve/config.inc.php.dist @@ -587,6 +591,8 @@ --dir %{_datadir}/roundcubemail/plugins/calendar/drivers/kolab/SQL/ \ --package calendar-kolab || : +${php} %{_datadir}/roundcubemail/bin/migrateconfig.sh + exit 0 %files
View file
migrateconfig.sh
Added
@@ -0,0 +1,137 @@ +#!/usr/bin/env php +<?php + +$home = '/etc/roundcubemail/'; + +if (!file_exists("{$home}/config.inc.php")) { + return; +} + +// default_host/default_port -> imap_host +// smtp_server/smtp_port -> smtp_host + +// For Kolab v3 we deal with a different format, so we first have to read the config +$imap_host = null; +$smtp_host = null; + +foreach (file("{$home}/config.inc.php") as $line) { + if (strpos($line, "\$config'imap_host'") !== false) { + // Already migrated + return; + } + + if (preg_match("~\\\$config\\'default_host'\\ = '(^'+)'~", $line, $matches)) { + $imap_host = $matches1; + } elseif (preg_match("~\\\$config\\'default_port'\\ = '?(0-9+)'?~", $line, $matches)) { + $imap_port = trim($matches1, "'"); + } elseif (preg_match("~\\\$config\\'smtp_server'\\ = '(^'+)'~", $line, $matches)) { + $smtp_host = $matches1; + } elseif (preg_match("~\\\$config\\'smtp_port'\\ = '?(0-9+)'?~", $line, $matches)) { + $smtp_port = trim($matches1, "'"); + } +} + +if (!empty($imap_port) && !empty($imap_host)) { + if (strpos($imap_host, ':' . $imap_port) === false) { + $imap_host .= ':' . $imap_port; + } + + if (strpos($imap_host, '://') === false) { + switch ($imap_port) { + case 143: + case 9143: + $imap_host = 'tls://' . $imap_host; + break; + case 993: + case 9993: + $imap_host = 'ssl://' . $imap_host; + break; + } + } +} + +if (!empty($smtp_port) && !empty($smtp_host)) { + if (strpos($smtp_host, ':' . $smtp_port) === false) { + $smtp_host .= ':' . $smtp_port; + } + + if (strpos($smtp_host, '://') === false) { + switch ($smtp_port) { + case 587: + $smtp_host = 'tls://' . $smtp_host; + break; + case 465: + $smtp_host = 'ssl://' . $smtp_host; + break; + } + } +} + +// TODO: removed `port` option from `ldap_public` array (non-standard port can be set via `host`) +// TODO: removed `use_tls` option from `ldap_public` array (use tls:// prefix in `host`) + +// For Kolab v4 we can just replace strings as we have a "constant" content +$replace = + "\$config'default_host' = (getenv('IMAP_TLS') == \"true\" ? \"ssl://\" : \"\") . getenv('IMAP_HOST');" + => "\$config'imap_host' = (getenv('IMAP_TLS') == \"true\" ? \"ssl://\" : \"\") . getenv('IMAP_HOST') . ':' . getenv('IMAP_PORT');", + "\$config'default_port' = getenv('IMAP_PORT');" => '', + "\$config'smtp_server' = \"tls://\" . getenv('SUBMISSION_HOST');" + => "\$config'smtp_host' = \"tls://\" . getenv('SUBMISSION_HOST') . ':' . getenv('SUBMISSION_PORT');", + "\$config'smtp_server' = getenv('SUBMISSION_HOST');" + => "\$config'smtp_host' = getenv('SUBMISSION_HOST') . ':' . getenv('SUBMISSION_PORT');", + "\$config'smtp_port' = getenv('SUBMISSION_PORT');" => '', +; + +$content = ''; +foreach (file("{$home}/config.inc.php") as $line) { + $line = str_replace(array_keys($replace), array_values($replace), $line); + if ($imap_host && strpos($line, "\$config'default_host'") !== false) { + $content .= "\$config'imap_host' = '{$imap_host}';\n"; + } elseif ($smtp_host && strpos($line, "\$config'smtp_server'") !== false) { + $content .= "\$config'smtp_host' = '{$smtp_host}';\n"; + } elseif (!preg_match("~\\\$config\\'(default_port|smtp_port)'\\~", $line)) { + $content .= $line; + } +} + +file_put_contents("{$home}/config.inc.php", $content); + +// managesieve_usetls/managesieve_port + +$sieve_host = null; + +foreach (file("{$home}/managesieve.inc.php") as $line) { + if (preg_match("~\\\$config\\'managesieve_host'\\ = '(^'+)'~", $line, $matches)) { + $sieve_host = $matches1; + } elseif (preg_match("~\\\$config\\'managesieve_port'\\ = '?(0-9+)'?~", $line, $matches)) { + $sieve_port = trim($matches1, "'"); + } elseif (preg_match("~\\\$config\\'managesieve_usetls'\\ = true~", $line, $matches)) { + $sieve_tls = true; + } +} + +if (!empty($sieve_host)) { + if (!empty($sieve_port) && strpos($sieve_host, ":$sieve_port") === false) { + $sieve_host .= ':' . $sieve_port; + } + if (!empty($sieve_tls) && strpos($sieve_host, "://") === false) { + $sieve_host = 'tls://' . $sieve_host; + } +} + +$replace = + "\$config'managesieve_host' = str_replace(\"ssl://\", \"\", getenv('IMAP_HOST'));" + => "\$config'managesieve_host' = str_replace(\"ssl://\", \"\", getenv('IMAP_HOST')) . ':4190';", +; + +$content = ''; +foreach (file("{$home}/managesieve.inc.php") as $line) { + $line = str_replace(array_keys($replace), array_values($replace), $line); + if ($sieve_host && strpos($line, "\$config'managesieve_host' = '") !== false) { + $content .= "\$config'managesieve_host' = '{$sieve_host}';\n"; + } elseif (!preg_match("~\\\$config\\'(managesieve_port|managesieve_usetls)'\\~", $line)) { + $content .= $line; + } +} + +file_put_contents("{$home}/managesieve.inc.php", $content);
View file
plesk.config.inc.php
Changed
@@ -17,12 +17,10 @@ $config'product_name' = "Plesk Premium Email, powered by Kolab"; $config'default_host' = "localhost"; - $config'default_port' = 9143; // CRAM-MD5 and DIGEST-MD5 are not compatible with encrypted passwords in plesk $config'imap_auth_type' = 'PLAIN'; $config'smtp_server' = "localhost"; - $config'smtp_port' = 25; $config'smtp_user' = '%u'; $config'smtp_pass' = '%p'; $config'smtp_helo_host' = $_SERVER"HTTP_HOST" ?? "";
View file
plesk.managesieve.inc.php
Changed
@@ -1,10 +1,8 @@ <?php - $config'managesieve_port' = 4190; - $config'managesieve_host' = '%h'; +$config'managesieve_host' = 'tls://%h:4190'; $config'managesieve_auth_type' = 'PLAIN'; $config'managesieve_auth_cid' = null; $config'managesieve_auth_pw' = null; - $config'managesieve_usetls' = true; $config'managesieve_default' = '/etc/dovecot/sieve/global'; $config'managesieve_mbox_encoding' = 'UTF-8'; $config'managesieve_replace_delimiter' = '';
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.