#!/usr/bin/perl
# cpanel - autofixer/fix_update_never             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'; }

use Cpanel::Config   ();
use Cpanel::LoadFile ();

my $sa_perl = Cpanel::LoadFile::loadfile('/scripts/update_sa_rules');

if ( $sa_perl =~ /SpamAssassinSandBox/ && !-e '/usr/local/cpanel/spamassassin_sandbox' ) {
    my %UPCONF;
    Cpanel::Config::loadConfig( '/etc/cpupdate.conf', \%UPCONF );

    if ( $UPCONF{'CPANEL'} eq 'never' ) {
        $UPCONF{'CPANEL'} = 'release';

        print "Detected /scripts updated without /usr/local/cpanel being updated.  Resetting cPanel update preference to RELEASE so recovery can take place.\n";
        print "You should now run /scripts/upcp --force.\n";

        Cpanel::Config::flushConfig( '/etc/cpupdate.conf', \%UPCONF, '=' );
    }
}

