#!/usr/bin/perl
# cpanel - autofixer2/remove_sendmail_rpm         Copyright(c) 2015 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

# Exit if the customer doesn't want this.
exit if -e '/var/cpanel/dont_remove_sendmail_rpm';

# Exit if the sendmail RPM is not installed.
my $check_sendmail = `/bin/rpm -q sendmail 2>&1`;
exit if $?;

print "The sendmail RPM should not be installed but is. This breaks exim: $check_sendmail";

system(qw{/bin/rpm -e --nodeps sendmail});
system(qw{/bin/rpm -e sendmail-cf});
system(qw{/bin/rpm -e sendmail-doc});
system(qw{/bin/rpm -e sendmail-devel});
system(qw{/bin/rpm -e sendmail-milter});

# Prior to 11.36, we need to run /scripts/eximup.
if ( -e '/usr/local/cpanel/scripts/check_cpanel_rpms' ) {
    system(qw{/usr/local/cpanel/scripts/check_cpanel_rpms --fix --long-list --targets exim });
}
else {
    system(qw{/usr/local/cpanel/scripts/eximup --force});
}

