Edit File: sa-update_wrapper
#!/usr/local/cpanel/3rdparty/bin/perl # cpanel - scripts/sa-update_wrapper Copyright 2012 cPanel, Inc. # All rights Reserved. # copyright@cpanel.net http://cpanel.net # This code is subject to the cPanel license. Unauthorized copying is prohibited alarm(3600); use Cpanel::FindBin (); use Cpanel::SafeRun::Errors (); use Cpanel::Binaries (); my $saupdate_bin = Cpanel::Binaries::get_binary_location('sa-update'); if ( !$saupdate_bin || !-e $saupdate_bin || !-x $saupdate_bin ) { die "$0: sa-update is missing!\n"; } sub run_saupdate { my $gpg_option = shift; if ( !$gpg_option ) { my $gpg_bin = Cpanel::FindBin::findbin('gpg'); $gpg_option = ( !$gpg_bin || !-x $gpg_bin ) ? '--nogpg' : '--gpg'; } print "[*] Cleaning up from previous updates.....\n"; clean_up_updates(); print "[*] Running sa-update ($saupdate_bin).....\n"; print "[*] Please note that 'IO::Socket::IP' and 'Net::Patricia' are not needed by our implementation of SpamAssassin.\n[*] The warnings related to them can be safely ignored.\n\n"; system( $saupdate_bin, $gpg_option, grep( /-Q/i, @ARGV ) ? () : ('-D') ); print "Done\n"; } sub clean_up_updates { my $version = eval { require Mail::SpamAssassin; $Mail::SpamAssassin::VERSION }; return unless defined $version; my $dir = "/var/lib/spamassassin/$version/updates_spamassassin_org"; return unless opendir( my $dh, $dir ); while ( defined( my $file = readdir $dh ) ) { unlink "$dir/$file" if $file =~ /^\d+\.tar\.gz(?:\.(?:asc|sha1))?$/; } closedir($dh); } run_saupdate(); print "Checking update...."; my $spamassassin_bin = Cpanel::Binaries::get_binary_location('spamassassin'); my $has_rules = 1; if ( -x $spamassassin_bin ) { my @testout = Cpanel::SafeRun::Errors::saferunallerrors( $spamassassin_bin, '--lint', '-D' ); if ( grep ( /no rules were found/, @testout ) ) { $has_rules = 0; } } if ( !$has_rules ) { print "update failed...retrying without gpg...\n"; run_saupdate('--nogpg'); } else { print "update ok!\n"; }