smeserver-dovecot/root/etc/e-smith/events/actions/adjust-dovecot

35 lines
1.1 KiB
Perl

#!/usr/bin/perl -w
# This script just ensure the dovecot service is enabled
# if imap or imaps is enabled
# It will also entirely disable the dovecot service if both imap,
# imaps pop3 and pop3s are disabled
use esmith::ConfigDB;
my $c = esmith::ConfigDB->open() or die "Couldn't open Config DB\n";
my $imap = $c->get('imap');
my $imaps = $c->get('imaps');
my $pop = $c->get('pop3');
my $pops = $c->get('pop3s');
my $dovecot = $c->get('dovecot') || $c->new_record('dovecot',
{ type => 'service',
status => 'enabled'});
my $imapStatus = $imap->prop('status') || 'enabled';
my $imapsStatus = $imaps->prop('status') || 'enabled';
my $popStatus = $pop->prop('status') || 'enabled';
my $popsStatus = $pops->prop('status') || 'enabled';
if ($imapStatus eq 'enabled' or $imapsStatus eq 'enabled' or $popStatus eq 'enabled' or $popsStatus eq 'enabled'){
$dovecot->set_prop('status', 'enabled');
}
else{
$dovecot->set_prop('status', 'disabled');
}
# also if /etc/pam.d/pop3 exists we unlink it, as it was needed by former e-smith-pop3
unlink('/etc/pam.d/pop3');