summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2013-06-28 22:27:59 +0200
committerThomas Bruederli <thomas@roundcube.net>2013-06-28 22:27:59 +0200
commit9bacb2cd3f7e8f96a29f651460954965c400aac6 (patch)
tree73ce71706da010ef337b23fd53afc296e4675f17
parent0f39b4f4cdd60f4af5f85d656ed08698e86287ea (diff)
Prepare config migration:
- Show warning in installer and hints how to migrate - Let update.sh create the new config file if legacy config is detected - Provide a sample config file for manual configuration - Define a list of options which always should be written to local config
-rw-r--r--INSTALL11
-rwxr-xr-xbin/update.sh30
-rw-r--r--config/config.inc.php.sample85
-rw-r--r--config/defaults.inc.php12
-rw-r--r--installer/config.php13
-rw-r--r--installer/index.php12
-rw-r--r--installer/rcube_install.php7
7 files changed, 144 insertions, 26 deletions
diff --git a/INSTALL b/INSTALL
index 4573c55af..b80d3323b 100644
--- a/INSTALL
+++ b/INSTALL
@@ -141,10 +141,13 @@ Best solution is to install a cronjob running this script daily.
MANUAL CONFIGURATION
====================
-First of all, rename the files config/*.inc.php.dist to config/*.inc.php.
-You can then change these files according to your environment and your needs.
-Details about the config parameters can be found in the config files.
-See http://trac.roundcube.net/wiki/Howto_Install for even more guidance.
+First of all, copy the sample configuration file config/config.inc.php.sample
+to config/config.inc.php and make the necessary adjustments according to your
+environment and your needs. More configuration options can be copied from the
+config/defaults.inc.php file into your local config.inc.php file as needed.
+Read the comments above the individual configuration options to find out what
+they do or read http://trac.roundcube.net/wiki/Howto_Install for even more
+guidance.
You can also modify the default .htaccess file. This is necessary to
increase the allowed size of file attachments, for example:
diff --git a/bin/update.sh b/bin/update.sh
index 1a6fbd32d..b5000bbe5 100755
--- a/bin/update.sh
+++ b/bin/update.sh
@@ -36,17 +36,17 @@ if (!$opts['version']) {
$opts['version'] = RCMAIL_VERSION;
}
-if ($opts['version'] && version_compare(version_parse($opts['version']), version_parse(RCMAIL_VERSION), '>='))
- die("Nothing to be done here. Bye!\n");
-
-
$RCI = rcube_install::get_instance();
$RCI->load_config();
+if ($opts['version'] && version_compare(version_parse($opts['version']), version_parse(RCMAIL_VERSION), '>=') && !$RCI->legacy_config)
+ die("Nothing to be done here. Bye!\n");
+
+
if ($RCI->configured) {
$success = true;
- if ($messages = $RCI->check_config()) {
+ if (($messages = $RCI->check_config()) || $RCI->legacy_config) {
$success = false;
$err = 0;
@@ -74,6 +74,12 @@ if ($RCI->configured) {
echo "\n";
}
+ if (!$err && $RCI->legacy_config) {
+ echo "WARNING: Your configuration needs to be migrated!\n";
+ echo "We changed the configuration files structure and your two config files main.inc.php and db.inc.php have to be merged into one single file.\n";
+ $err++;
+ }
+
// ask user to update config files
if ($err) {
echo "Do you want me to fix your local configuration? (y/N)\n";
@@ -81,13 +87,13 @@ if ($RCI->configured) {
// positive: let's merge the local config with the defaults
if (strtolower($input) == 'y') {
- $error = $writed = false;
+ $error = $written = false;
// backup current config
echo ". backing up the current config file(s)...\n";
foreach (array('config', 'main', 'db') as $file) {
- if (file_exists(RCMAIL_CONFIG_DIR . '/' . $file . '.inc.php'))
+ if (file_exists(RCMAIL_CONFIG_DIR . '/' . $file . '.inc.php')) {
if (!copy(RCMAIL_CONFIG_DIR . '/' . $file . '.inc.php', RCMAIL_CONFIG_DIR . '/' . $file . '.old.php')) {
$error = true;
}
@@ -97,11 +103,11 @@ if ($RCI->configured) {
if (!$error) {
$RCI->merge_config();
echo ". writing " . RCMAIL_CONFIG_DIR . "/config.inc.php...\n";
- $writed = file_put_contents(RCMAIL_CONFIG_DIR . '/config.inc.php', $RCI->create_config());
+ $written = file_put_contents(RCMAIL_CONFIG_DIR . '/config.inc.php', $RCI->create_config());
}
// Success!
- if ($writed) {
+ if ($written) {
echo "Done.\n";
echo "Your configuration files are now up-to-date!\n";
@@ -110,6 +116,12 @@ if ($RCI->configured) {
foreach ($messages['missing'] as $msg)
echo "- '" . $msg['prop'] . ($msg['name'] ? "': " . $msg['name'] : "'") . "\n";
}
+
+ if ($RCI->legacy_config) {
+ foreach (array('main', 'db') as $file) {
+ @unlink(RCMAIL_CONFIG_DIR . '/' . $file . '.inc.php');
+ }
+ }
}
else {
echo "Failed to write config file(s)!\n";
diff --git a/config/config.inc.php.sample b/config/config.inc.php.sample
new file mode 100644
index 000000000..22a269460
--- /dev/null
+++ b/config/config.inc.php.sample
@@ -0,0 +1,85 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | Local configuration for the Roundcube Webmail installation. |
+ | |
+ | This is a sample configuration file only containing the minumum |
+ | setup required for a functional installation. Copy more config |
+ | from defaults.inc.php to this file to override the defaults. |
+ | |
+ | This file is part of the Roundcube Webmail client |
+ | Copyright (C) 2005-2013, The Roundcube Dev Team |
+ | |
+ | Licensed under the GNU General Public License version 3 or |
+ | any later version with exceptions for skins & plugins. |
+ | See the README file for a full license statement. |
+ +-----------------------------------------------------------------------+
+*/
+
+$config = array();
+
+// Database connection string (DSN) for read+write operations
+// Format (compatible with PEAR MDB2): db_provider://user:password@host/database
+// Currently supported db_providers: mysql, pgsql, sqlite, mssql or sqlsrv
+// For examples see http://pear.php.net/manual/en/package.database.mdb2.intro-dsn.php
+// NOTE: for SQLite use absolute path: 'sqlite:////full/path/to/sqlite.db?mode=0646'
+$config['db_dsnw'] = 'mysql://roundcube:pass@localhost/roundcubemail';
+
+// The mail host chosen to perform the log-in.
+// Leave blank to show a textbox at login, give a list of hosts
+// to display a pulldown menu or set one host as string.
+// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
+// Supported replacement variables:
+// %n - hostname ($_SERVER['SERVER_NAME'])
+// %t - hostname without the first part
+// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
+// %s - domain name after the '@' from e-mail address provided at login screen
+// For example %n = mail.domain.tld, %t = domain.tld
+$config['default_host'] = 'localhost';
+
+// SMTP server host (for sending mails).
+// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
+// If left blank, the PHP mail() function is used
+// Supported replacement variables:
+// %h - user's IMAP hostname
+// %n - hostname ($_SERVER['SERVER_NAME'])
+// %t - hostname without the first part
+// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
+// %z - IMAP domain (IMAP hostname without the first part)
+// For example %n = mail.domain.tld, %t = domain.tld
+$config['smtp_server'] = '';
+
+// SMTP port (default is 25; use 587 for STARTTLS or 465 for the
+// deprecated SSL over SMTP (aka SMTPS))
+$config['smtp_port'] = 25;
+
+// SMTP username (if required) if you use %u as the username Roundcube
+// will use the current username for login
+$config['smtp_user'] = '';
+
+// SMTP password (if required) if you use %p as the password Roundcube
+// will use the current user's password for login
+$config['smtp_pass'] = '';
+
+// provide an URL where a user can get support for this Roundcube installation
+// PLEASE DO NOT LINK TO THE ROUNDCUBE.NET WEBSITE HERE!
+$config['support_url'] = '';
+
+// Name your service. This is displayed on the login screen and in the window title
+$config['product_name'] = 'Roundcube Webmail';
+
+// this key is used to encrypt the users imap password which is stored
+// in the session record (and the client cookie if remember password is enabled).
+// please provide a string of exactly 24 chars.
+// YOUR KEY MUST BE DIFFERENT THAN THE SAMPLE VALUE FOR SECURITY REASONS
+$config['des_key'] = 'rcmail-!24ByteDESkey*Str';
+
+// List of active plugins (in plugins/ directory)
+$config['plugins'] = array(
+ 'archive',
+ 'zipdownload',
+);
+
+// skin name: folder from skins/
+$config['skin'] = 'larry';
diff --git a/config/defaults.inc.php b/config/defaults.inc.php
index 707c1934c..a796e168c 100644
--- a/config/defaults.inc.php
+++ b/config/defaults.inc.php
@@ -24,7 +24,7 @@ $config = array();
// Currently supported db_providers: mysql, pgsql, sqlite, mssql or sqlsrv
// For examples see http://pear.php.net/manual/en/package.database.mdb2.intro-dsn.php
// NOTE: for SQLite use absolute path: 'sqlite:////full/path/to/sqlite.db?mode=0646'
-$config['db_dsnw'] = 'mysql://roundcube:pass@localhost/roundcubemail';
+$config['db_dsnw'] = 'mysql://roundcube:@localhost/roundcubemail';
// Database DSN for read-only operations (if empty write database will be used)
// useful for database replication
@@ -97,7 +97,7 @@ $config['smtp_debug'] = false;
// For example %n = mail.domain.tld, %t = domain.tld
// WARNING: After hostname change update of mail_host column in users table is
// required to match old user data records with the new host.
-$config['default_host'] = '';
+$config['default_host'] = 'localhost';
// TCP port used for IMAP connections
$config['default_port'] = 143;
@@ -349,12 +349,12 @@ $config['max_recipients'] = 0;
// If 'max_recipients' is set this value should be less or equal
$config['max_group_members'] = 0;
-// add this user-agent to message headers when sending
-$config['useragent'] = 'Roundcube Webmail/'.RCMAIL_VERSION;
-
-// use this name to compose page titles
+// Name your service. This is displayed on the login screen and in the window title
$config['product_name'] = 'Roundcube Webmail';
+// Add this user-agent to message headers when sending
+$config['useragent'] = 'Roundcube Webmail/'.RCMAIL_VERSION;
+
// try to load host-specific configuration
// see http://trac.roundcube.net/wiki/Howto_Config for more details
$config['include_host_config'] = false;
diff --git a/installer/config.php b/installer/config.php
index acdd4ffd1..f990fc23f 100644
--- a/installer/config.php
+++ b/installer/config.php
@@ -24,10 +24,15 @@ $RCI->bool_config_props = array(
$_SESSION['allowinstaller'] = true;
if (!empty($_POST['submit'])) {
- echo '<p class="notice">Copy or download the following configuration and save';
- echo ' as <tt><b>config.inc.php</b></tt> within the <tt>'.RCMAIL_CONFIG_DIR.'</tt> directory of your Roundcube installation.<br/>';
+ echo '<p class="notice">Copy or download the following configuration and save it';
+ echo ' as <tt><b>config.inc.php</b></tt> within the <tt>'.RCUBE_CONFIG_DIR.'</tt> directory of your Roundcube installation.<br/>';
echo ' Make sure that there are no characters outside the <tt>&lt;?php ?&gt;</tt> brackets when saving the file.';
- echo '&nbsp;<input type="button" onclick="location.href=\'index.php?_getconfig=1\'" value="Download" /></p>';
+ echo '&nbsp;<input type="button" onclick="location.href=\'index.php?_getconfig=1\'" value="Download" />';
+ if ($RCI->legacy_config) {
+ echo '<br/><br/>Afterwards, please <b>remove</b> the old configuration files <tt>main.inc.php</tt> and <tt>db.inc.php</tt>';
+ echo ' from the config directory.';
+ }
+ echo '</p>';
$textbox = new html_textarea(array('rows' => 16, 'cols' => 60, 'class' => "configfile"));
echo $textbox->show(($_SESSION['config'] = $RCI->create_config()));
@@ -640,7 +645,7 @@ $select_param_folding->add('Full RFC 2231 (Roundcube, Thunderbird)', '0');
$select_param_folding->add('RFC 2047/2231 (MS Outlook, OE)', '1');
$select_param_folding->add('Full RFC 2047 (deprecated)', '2');
-echo $select_param_folding->show(intval($RCI->getprop('mime_param_folding')));
+echo $select_param_folding->show(strval($RCI->getprop('mime_param_folding')));
?>
<div>How to encode attachment long/non-ascii names</div>
diff --git a/installer/index.php b/installer/index.php
index 4e4a04326..dc4c0a43f 100644
--- a/installer/index.php
+++ b/installer/index.php
@@ -121,8 +121,16 @@ if ($RCI->configured && empty($_REQUEST['_step'])) {
// exit if installation is complete
if ($RCI->configured && !$RCI->getprop('enable_installer') && !$_SESSION['allowinstaller']) {
// header("HTTP/1.0 404 Not Found");
- echo '<h2 class="error">The installer is disabled!</h2>';
- echo '<p>To enable it again, set <tt>$rcmail_config[\'enable_installer\'] = true;</tt> in RCUBE_CONFIG_DIR/config.inc.php</p>';
+ if ($RCI->configured && $RCI->legacy_config) {
+ echo '<h2 class="error">Your configuration needs to be migrated!</h2>';
+ echo '<p>We changed the configuration files structure and your installation needs to be updated accordingly.</p>';
+ echo '<p>Please run the <tt>bin/update.sh</tt> script from the command line or set <p>&nbsp; <tt>$rcmail_config[\'enable_installer\'] = true;</tt></p>';
+ echo ' in your RCUBE_CONFIG_DIR/main.inc.php to let the installer help you migrating it.</p>';
+ }
+ else {
+ echo '<h2 class="error">The installer is disabled!</h2>';
+ echo '<p>To enable it again, set <tt>$rcmail_config[\'enable_installer\'] = true;</tt> in RCUBE_CONFIG_DIR/config.inc.php</p>';
+ }
echo '</div></body></html>';
exit;
}
diff --git a/installer/rcube_install.php b/installer/rcube_install.php
index 5d766f4d0..06622de4d 100644
--- a/installer/rcube_install.php
+++ b/installer/rcube_install.php
@@ -28,10 +28,12 @@ class rcube_install
var $failures = 0;
var $config = array();
var $configured = false;
+ var $legacy_config = false;
var $last_error = null;
var $email_pattern = '([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9])';
var $bool_config_props = array();
+ var $local_config = array('db_dsnw', 'default_host', 'support_url', 'des_key', 'plugins');
var $obsolete_config = array('db_backend', 'double_auth');
var $replaced_config = array(
'skin_path' => 'skin',
@@ -157,6 +159,9 @@ class rcube_install
$is_default = !isset($_POST["_$prop"]);
$value = !$is_default || $this->bool_config_props[$prop] ? $_POST["_$prop"] : $default;
+ if ($prop == 'enable_installer')
+ $value = false;
+
// convert some form data
if ($prop == 'debug_level' && !$is_default) {
if (is_array($value)) {
@@ -211,7 +216,7 @@ class rcube_install
}
// skip this property
- if (!array_key_exists($prop, $this->defaults) || ($value == $this->defaults[$prop])) {
+ if ((!array_key_exists($prop, $this->defaults) || ($value == $this->defaults[$prop])) && !in_array($prop, $this->local_config)) {
continue;
}