File: //proc/self/root/proc/self/root/scripts.20110531.215904.25158/checkswup
#!/usr/bin/perl
# cpanel - checkswup 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::SafeFile;
use Cpanel::Logger ();
exit if !-e '/etc/swup/swup.conf';
my $logger = Cpanel::Logger->new();
print "checkswup version 1.0\n";
my $goodex = 0;
my (@UP);
my $la = Cpanel::SafeFile::safeopen( \*YC, "<", "/etc/swup/swup.conf" );
if( !$la ) {
$logger->die("Could not read from /etc/swup/swup.conf");
}
while (<YC>) {
push( @UP, $_ );
if (/^exclude_pkg_regexp\s*=/i) {
if ( /mod_ssl/ && /apache/ && /httpd/ && /mysql/ && /perl/ && /php/ && /exim/ && /ruby/ && /courier/ && /dovecot/ && /nsd/ ) {
$goodex = 1;
}
}
}
Cpanel::SafeFile::safeclose( \*YC, $la );
if ($goodex) { exit(); }
my $lb = Cpanel::SafeFile::safeopen( \*UPDATEW, ">", "/etc/swup/swup.conf" );
if( !$lb ) {
$logger->die("Could not write to /etc/swup/swup.conf");
}
foreach (@UP) {
if (/^exclude_pkg_regexp\s*=\s*(.*)/) {
$pkgs = $1;
chomp($pkgs);
$pkgs =~ s/^\"|\"$//g;
@PKGS = split( / /, $pkgs );
if ( $pkgs !~ /apache/ ) { push( @PKGS, "apache*" ); }
if ( $pkgs !~ /httpd/ ) { push( @PKGS, "httpd*" ); }
if ( $pkgs !~ /mod_ssl/ ) { push( @PKGS, "mod_ssl*" ); }
if ( $pkgs !~ /perl/ ) { push( @PKGS, "perl" ); }
if ( $pkgs !~ /mysql/ ) { push( @PKGS, "mysql*" ); }
if ( $pkgs !~ /exim/ ) { push( @PKGS, "exim*" ); }
if ( $pkgs !~ /dovecot/ ) { push( @PKGS, "dovecot*" ); }
if ( $pkgs !~ /nsd/ ) { push( @PKGS, "nsd*" ); }
if ( $pkgs !~ /courier/ ) { push( @PKGS, "courier*" ); }
if ( $pkgs !~ /ruby/ ) { push( @PKGS, "ruby*" ); }
if ( $pkgs !~ /php/ ) { push( @PKGS, "php*" ); }
if ( $PKGS[$#PKGS] eq "" ) { pop(@PKGS); }
$pkgs = join( "|", @PKGS );
print UPDATEW "exclude_pkg_regexp = \"${pkgs}\"\n";
}
else {
print UPDATEW;
}
}
Cpanel::SafeFile::safeclose( \*UPDATEW, $lb );