????

Your IP : 18.119.130.185


Current Path : /proc/326615/root/scripts/
Upload File :
Current File : //proc/326615/root/scripts/checkup2date

#!/usr/local/cpanel/3rdparty/bin/perl

# cpanel - scripts/checkup2date                    Copyright 2020 cPanel, L.L.C.
#                                                           All rights reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

use strict;
use Cpanel::SafeFile;
use Cpanel::Logger ();

exit if ( !-e '/etc/sysconfig/rhn/up2date' );

my $logger = Cpanel::Logger->new();

my $goodfile         = 0;
my $pkgskiplist_seen = 0;

my $filelock = Cpanel::SafeFile::safeopen( \*UPDATE, '<', '/etc/sysconfig/rhn/up2date' );
if ( !$filelock ) {
    $logger->die("Could not read from /etc/sysconfig/rhn/up2date");
}
open( UPDATEW, '>', '/etc/sysconfig/rhn/up2date.merged' ) or die;
while (<UPDATE>) {
    if (/^pkgSkipList=(\S+)/) {
        $pkgskiplist_seen = 1;
        my $pkgs = $1;
        chomp $pkgs;
        if (   $pkgs =~ /mysql/
            && $pkgs =~ /courier/
            && $pkgs =~ /ruby/
            && $pkgs =~ /dovecot/
            && $pkgs =~ /nsd/
            && $pkgs =~ /mydns/
            && $pkgs =~ /httpd/
            && $pkgs =~ /perl/
            && $pkgs =~ /php/
            && $pkgs =~ /mod_ssl/
            && $pkgs =~ /spamassassin/
            && $pkgs =~ /exim/
            && $pkgs =~ /proftpd/
            && $pkgs =~ /pure-ftpd/
            && $pkgs =~ /kernel/ ) {
            $goodfile = 1;
            last;
        }

        $pkgs = update_pkgskiplist($pkgs);

        print UPDATEW 'pkgSkipList=' . $pkgs . ";\n";
    }
    else {
        print UPDATEW;
    }
}

if ( !$pkgskiplist_seen ) {
    my $pkgs = update_pkgskiplist();
    print UPDATEW 'pkgSkipList=' . $pkgs . ";\n";
}

Cpanel::SafeFile::safeclose( \*UPDATE, $filelock );

exit if $goodfile;

rename '/etc/sysconfig/rhn/up2date', '/etc/sysconfig/rhn/up2date.backup';

if ( !rename '/etc/sysconfig/rhn/up2date.merged', '/etc/sysconfig/rhn/up2date' ) {
    rename '/etc/sysconfig/rhn/up2date.backup', '/etc/sysconfig/rhn/up2date';
}

sub update_pkgskiplist {
    my $pkgs = shift || '';

    my @PKGS = split( /;/, $pkgs );

    if ( $pkgs !~ /courier/ )      { push( @PKGS, 'courier*' ); }
    if ( $pkgs !~ /ruby/ )         { push( @PKGS, 'ruby*' ); }
    if ( $pkgs !~ /dovecot/ )      { push( @PKGS, 'dovecot*' ); }
    if ( $pkgs !~ /nsd/ )          { push( @PKGS, 'nsd*' ); }
    if ( $pkgs !~ /mydns/ )        { push( @PKGS, 'mydns*' ); }
    if ( $pkgs !~ /spamassassin/ ) { push( @PKGS, 'spamassassin*' ); }
    if ( $pkgs !~ /httpd/ )        { push( @PKGS, 'httpd*' ); }
    if ( $pkgs !~ /perl/ )         { push( @PKGS, 'perl' ); }
    if ( $pkgs !~ /mysql/ )        { push( @PKGS, 'mysql*' ); }
    if ( $pkgs !~ /php/ )          { push( @PKGS, 'php*' ); }
    if ( $pkgs !~ /mod_ssl/ )      { push( @PKGS, 'mod_ssl*' ); }
    if ( $pkgs !~ /kernel/ )       { push( @PKGS, "kernel*" ); }
    if ( $pkgs !~ /exim/ )         { push( @PKGS, "exim*" ); }
    if ( $pkgs !~ /proftpd/ )      { push( @PKGS, "proftpd*" ); }
    if ( $pkgs !~ /pure-ftpd/ )    { push( @PKGS, "pure-ftpd*" ); }

    @PKGS = grep( !m/^\s*$/, @PKGS );

    $pkgs = join( ';', @PKGS );

    return $pkgs;
}