File: //proc/self/root/scripts.20110531.215904.25158/sa-update_wrapper
#!/usr/bin/perl
# cpanel - sa-update_wrapper Copyright(c) 2010 cPanel, Inc.
# All rights Reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
BEGIN { unshift @INC, '/usr/local/cpanel'; }
alarm(3600);
use Cpanel::FindBin ();
use Cpanel::SafeRun::Errors ();
my $saupdate = Cpanel::FindBin::findbin('sa-update');
if ( !$saupdate || !-e $saupdate || !-x $saupdate ) {
die "$app: 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 "Running sa-update ($saupdate).....";
system( $saupdate, $gpg_option, grep( /-Q/i, @ARGV ) ? () : ('-D') );
print "Done\n";
}
run_saupdate();
print "Checking update....";
my $spamassassin_bin = Cpanel::FindBin::findbin( 'spamassassin', 'path' => [ '/usr/sbin', '/usr/local/sbin', '/usr/bin', '/usr/local/bin' ] );
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";
}