Skip to content

Commit

Permalink
Fixed: Disable Dovecot systemd socket activation unit if any (not nee…
Browse files Browse the repository at this point in the history
…ded for Dovecot as configured by i-MSCP)

Fixed: systemd[1]: [/lib/systemd/system/dovecot.socket:8] Failed to parse address value, ignoring: [::]:143 (on IPv4 only boxes)
Fixed systemd[1]: [/lib/systemd/system/dovecot.socket:10] Failed to parse address value, ignoring: [::]:993 (on IPv4 only boxes)
[ci skip]
  • Loading branch information
nuxwin committed May 5, 2016
1 parent 816a763 commit 44959a9
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -108,6 +108,7 @@ INSTALLER
Added: onBuildPackageList event (Allows to override default distribution packages file)
Fixed: '_' and '%' wildcards must be escaped in GRANT statements
Fixed: Debug and verbose modes must be set early
Fixed: Disable Dovecot systemd socket activation unit if any (not needed for Dovecot as configured by i-MSCP)
Fixed: Don't die on misconfigured server hostname. Just ask for a valid hostname instead
Fixed: Invalid regexes for SQL user/password (Package::PhpMyAdmin::Installer)
Fixed: libmariadbclient18 package not provided in Debian Stretch (testing) repository
Expand Down
77 changes: 74 additions & 3 deletions engine/PerlLib/Servers/po/dovecot.pm
Expand Up @@ -76,7 +76,28 @@ sub preinstall
my $self = shift;

my $rs = $self->{'eventManager'}->trigger( 'beforePoPreinstall', 'dovecot' );
$rs ||= $self->{'eventManager'}->trigger( 'afterPoPreinstall', 'dovecot' );
$rs ||= $self->stop();
return $rs if $rs;

local $@;
eval {
my $serviceMngr = iMSCP::Service->getInstance();

# Disable dovecot.socket unit if any
# Dovecot as configured by i-MSCP doesn't rely on systemd activation socket
# This also solve problem on boxes where IPv6 is not available (default dovecot.socket unit file make
# assumption that IPv6 is available without further checks)
if($serviceMngr->isSystemd() && $serviceMngr->hasService('dovecot.socket')) {
$serviceMngr->stop('dovecot.socket');
$serviceMngr->disable('dovecot.socket');
}
};
if ($@) {
error( $@ );
return 1;
}

$self->{'eventManager'}->trigger( 'afterPoPreinstall', 'dovecot' );
}

=item install()
Expand All @@ -92,7 +113,7 @@ sub install
my $self = shift;

my $rs = $self->{'eventManager'}->trigger( 'beforePoInstall', 'dovecot' );
$rs ||= Servers::po::dovecot::installer->getInstance()->install();;
$rs ||= Servers::po::dovecot::installer->getInstance()->install();
$rs ||= $self->{'eventManager'}->trigger( 'afterPoInstall', 'dovecot' );
}

Expand Down Expand Up @@ -220,9 +241,59 @@ sub uninstall
$rs ||= $self->{'eventManager'}->trigger( 'afterPoUninstall', 'dovecot' );
}

=item start()
Start Dovecot
Return int 0 on success, other on failure
=cut

sub start
{
my $self = shift;

my $rs = $self->{'eventManager'}->trigger( 'beforePoStart' );
return $rs if $rs;

local $@;
eval { iMSCP::Service->getInstance()->start( $self->{'config'}->{'DOVECOT_SNAME'} ); };
if ($@) {
error( $@ );
return 1;
}

$self->{'eventManager'}->trigger( 'afterPoStart' );
}

=item stop()
Stop Dovecot
Return int 0 on success, other on failure
=cut

sub stop
{
my $self = shift;

my $rs = $self->{'eventManager'}->trigger( 'beforePoStop' );
return $rs if $rs;

local $@;
eval { iMSCP::Service->getInstance()->stop( $self->{'config'}->{'DOVECOT_SNAME'} ); };
if ($@) {
error( $@ );
return 1;
}

$self->{'eventManager'}->trigger( 'afterPoStop' );
}

=item restart()
Restart dovecot
Restart Dovecot
Return int 0 on success, other on failure
Expand Down

0 comments on commit 44959a9

Please sign in to comment.