Handle different dovecot config locations on CentOS 6

This commit is contained in:
Jamie Cameron
2011-08-11 12:47:15 -07:00
parent bee379adbd
commit f67d331030
6 changed files with 18 additions and 6 deletions

View File

@@ -21,3 +21,5 @@ Added fields to the SSL page for an optional CA certificate file and private key
Added support for Dovecot 2.0, which renames many configuration directives and splits up the config using include files.
---- Changes since 1.550 ----
The Edit Config Files page can now be used to edit any of the Dovecot configuration files, for the case where there are many included configs.
---- Changes since 1.560 ----
Fixed support for CentOS 6 and related distributions, which move the Dovecot config to /etc/dovecot/dovecot.conf.

View File

@@ -1,4 +1,4 @@
dovecot=/usr/sbin/dovecot
dovecot_config=/etc/dovecot.conf
dovecot_config=/etc/dovecot/dovecot.conf /etc/dovecot.conf
init_script=dovecot
pid_file=/var/run/dovecot/master.pid

View File

@@ -9,12 +9,22 @@ use WebminCore;
@mail_envs = ( undef, "maildir:~/Maildir", "mbox:~/mail/:INBOX=/var/mail/%u",
"maildir:~/Maildir:mbox:~/mail/" );
# get_config_file()
# Returns the full path to the first valid config file
sub get_config_file
{
foreach my $f (split(/\s+/, $config{'dovecot_config'})) {
return $f if (-r $f);
}
return undef;
}
# get_config()
# Returns a list of dovecot config entries
sub get_config
{
if (!scalar(@get_config_cache)) {
@get_config_cache = &read_config_file($config{'dovecot_config'});
@get_config_cache = &read_config_file(&get_config_file());
}
return \@get_config_cache;
}
@@ -201,7 +211,7 @@ elsif (!$dir && defined($value)) {
}
else {
# Need to put at end of main config
local $lref = &read_file_lines($config{'dovecot_config'});
local $lref = &read_file_lines(&get_config_file());
push(@$lref, $newline);
push(@$conf, { 'name' => $name,
'value' => $value,

View File

@@ -4,7 +4,7 @@
require './dovecot-lib.pl';
&ui_print_header(undef, $text{'manual_title'}, "");
&ReadParse();
$file = $in{'file'} || $config{'dovecot_config'};
$file = $in{'file'} || &get_config_file();
$conf = &get_config();
@files = &unique(map { $_->{'file'} } @$conf);
&indexof($file, @files) >= 0 || &error($text{'manual_efile'});

View File

@@ -24,7 +24,7 @@ if (!&has_command($config{'dovecot'})) {
}
# Check for config file
if (!-r $config{'dovecot_config'}) {
if (!&get_config_file()) {
print &ui_config_link('index_econf',
[ "<tt>$config{'dovecot_config'}</tt>", undef ]),"<p>\n";
&ui_print_footer("/", $text{'index'});

View File

@@ -9,7 +9,7 @@ do 'dovecot-lib.pl';
sub is_installed
{
return 0 if (!&has_command($config{'dovecot'}) ||
!-r $config{'dovecot_config'});
!&get_config_file());
return $_[0] ? 2 : 1;
}