28EB20DD993533690415CA4 :Wˆl–Ãa¾”ËmJm@=q±\”Å£Û ƒ}À½Úa–ß=¿JJj"Tâ€zàpM)‹FÿÙ%’W#!/usr/local/cpanel/3rdparty/bin/perl # Copyright 2025 WebPros International, LLC # All rights reserved. # copyright@cpanel.net http://cpanel.net # This code is subject to the cPanel license. Unauthorized copying is prohibited. use strict; use warnings; use Cpanel::Config::LoadCpConf (); use Cpanel::Config::CpConfGuard (); use Cpanel::Chkservd::Manage (); use Cpanel::RPM::Versions::Directory (); use Cpanel::RPM::Versions::File (); use Cpanel::SSLCerts (); use Cpanel::Usage (); use Cpanel::PID (); use Cpanel::Init (); use Cpanel::MailUtils::SNI (); use Cpanel::AdvConfig::dovecot::utils (); use Cpanel::SafeRun::Object (); use Cpanel::Dovecot::Service (); use Cpanel::Server::Type (); use Cpanel::ServerTasks (); our $DOVECOT_CONF_PATH = '/etc/dovecot/dovecot.conf'; my $help = 0; my $man = 0; my $force = 0; my $current = 0; $| = 1; delete $ENV{'cp_security_token'}; delete $ENV{'HTTP_REFERER'}; # Argument processing my %opts = ( 'force' => \$force, 'current' => \$current, ); Cpanel::Usage::wrap_options( \@ARGV, \&usage, \%opts ); @ARGV = ( grep( !/^--/, @ARGV ) ); my $selected_mailserver = shift; usage() unless ( $selected_mailserver || $current ); my $cpconf_ref = Cpanel::Config::LoadCpConf::loadcpconf(); my $current_mailserver = 'dovecot'; if ($current) { print "Current mailserver type: ${current_mailserver}\n"; print "Current storage format: maildir or mdbox\n"; exit 0; } if ( $> != 0 ) { die "You must perform the conversion process as the root user."; } if ( $selected_mailserver ne 'disabled' && $selected_mailserver ne 'dovecot' ) { print "You specified an unknown mailserver type.\nThe valid mailserver types are: “dovecotâ€� and “disabledâ€�.\nTry the $0 --help command.\n"; exit 1; } if ( !$force && $selected_mailserver ne 'disabled' ) { my $dir = Cpanel::RPM::Versions::Directory->new( { 'dont_set_legacy' => 1 } ); my $target_state = $dir->fetch( { 'section' => 'target_settings', 'key' => 'exim' } ); if ( $target_state && $target_state =~ m/^(uninstalled|unmanaged)$/ ) { print "WARNING: You attempted to enable the dovecot mailserver, but exim is explicitly set to $target_state in the /var/cpanel/rpm.versions.d/ file.\n"; print "This means that cPanel & WHM does not manage the mailserver's packages." if ( $target_state eq 'unmanaged' ); print "This means that cPanel & WHM has explicitly blocked the mailserver's packages from installation. " if ( $target_state eq 'uninstalled' ); print "If this was unintentional, run the following command to remove this flag, \nand then run the setupmailserver script.\n"; print "\n /usr/local/cpanel/scripts/update_local_rpm_versions --del target_settings.exim\n\n"; print "If this was intentional, run the setupmailserver script with the --force flag.\n\n"; exit 2; } } if ( !-e '/etc/dovecot/ssl/dovecot.crt' ) { require Cpanel::SSLCerts; Cpanel::SSLCerts::createDefaultSSLFiles( 'service' => 'dovecot' ); } $selected_mailserver = 'disabled' if Cpanel::Server::Type::is_dnsonly(); my $pid_obj = Cpanel::PID->new( { 'pid_file' => '/var/run/setupmailserver.pid' } ); unless ( $pid_obj->create_pid_file() > 0 ) { print "The setupmailserver script is running already.\n"; print "Wait for this conversion process to finish before you attempt another.\n"; exit 1; } my $installed = install_cpanel_rpms(); my $changed_enabled_protocols; my $disabled_mailserver_text = ''; if ( $selected_mailserver eq 'disabled' ) { $changed_enabled_protocols = disable_imap_and_pop3(); # Dovecot must always be enabled