MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
File: //proc/self/root/scripts.20110531.215904.25158/distupgrade
#!/usr/bin/perl
# cpanel - distupgrade                            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, '/scripts', '/usr/local/cpanel'; }

print "Don't use this script if you care about your system.. its for testing only\n";

$|=1;

use cPanelRPM;

mkdir("/home/distupgrade",0700);
chdir("/home/distupgrade");

system("/scripts/checkoldrpm");

my $rpmbin = "rpm";

if (! -e $rpmbin && 0) {
	unlink("${rpmbin}.gz");
	print "Downloading rpm 4.1...";
	cPanelRPM::httpreq('httpupdate.cpanel.net',"/rpm/rpm-4.1-static.gz","${rpmbin}.gz");
	system("gzip","-vdf","${rpmbin}.gz");
	chmod(0755,"${rpmbin}");
	if (! -e "${rpmbin}") {
		die "Unable to download static rpm 4.1";
	}
	print "Done\n";
}

print "This script will live upgrade your server's version of redhat to a newer version, or verify the current version.\n";

print "Using /home/distupgrade for rpm downloads.\n";

#this script upgrades redhat to the newer version

@KNOWNVERSIONS=("6.2","7.0","7.1","7.2","7.3","8.0","9");
my($curversion);

if (-e "/etc/redhat-release") {
   $distro = 'redhat';
   ($curversion) = cPanelRPM::getversionfromfile('/etc/redhat-release');
} else {
   die "distupgrade can only upgrade redhat";
}


print "Current RedHat Version: $curversion\n\n";

$up=0;
print "Valid Upgrade Targets: ";
foreach my $vers (@KNOWNVERSIONS) {
   if ($vers >= $curversion) {
      $up++;
      print "$vers ";
   }
}
print "\n";

if ($up == 0) {
   print "No Valid Upgrade Target.  Are you running the latest redhat?\n";
   exit;
}
print "Please enter the version of redhat you would like to upgrade to? ";
my $newversion;
chomp($newversion = <STDIN>);
my $goodver = 0;
foreach my $vers (@KNOWNVERSIONS) {
   if ($vers eq $newversion) {
      $goodver = 1;
   }
}

if ( $hassigint ) {
   exit;
}

if (!$goodver) {
   print "Sorry, I don't know how to upgrade to $newversion\n";
   exit;
}

if ($newversion < $version) {
   print "Sorry, you cannot downgrade to $newversion\n";
   exit;
}
if ($newversion == $version) {
   print "Current Version Specified, deps will be verified+solved.\n";
}

print "We are upgrading to version $newversion...\n";

if ($newversion >= 8) {
        system("rpm -e ucd-snmp ucd-snmp-devel ucd-snmp-utils 2>/dev/null");
}
if ($newversion >= 9) {
        system("rpm -e tix --nodeps 2>/dev/null");
}
                            
print "Rebuilding RPM Database...";                                                                                                
system("rpm","--rebuilddb");
print "Done\n";

my $rpm = cPanelRPM->new('redhat',$newversion,1,"/home/distupgrade/rpm-4.1-static"); 

$rpm->install("rpm",0,0,"/home/distupgrade",1);
$rpm->install("redhat-release",0,0,"/home/distupgrade",1);

if ($newversion eq "9") {
	$rpm->install("hwdata",0,0,"/home/distupgrade",1);
	$rpm->install("XFree86-truetype-fonts",0,0,"/home/distupgrade",1);
	$rpm->install("XFree86-xfs",0,0,"/home/distupgrade",1);
	$rpm->install("binutils",0,0,"/home/distupgrade",1);
	$rpm->install("ypserv",1,1,"/home/distupgrade",1);
	$rpm->install("quota",1,1,"/home/distupgrade",1);
	$rpm->install("zlib",1,1,"/home/distupgrade",1);
	$rpm->install("zlib-devel",1,1,"/home/distupgrade",1);
	$rpm->install("arpwatch",1,1,"/home/distupgrade",1);
}

@OLDRPMS = split(/\n/,`rpm -qa --qf "%{NAME}|%{VENDOR}\n"`);
foreach my $oldrpm (@OLDRPMS) {
   $oldrpm =~ s/\n//g;
   my($rpmname,$vendor) = split(/\|/, $oldrpm);
   if ($newversion eq "9" && $rpmname eq "arpwatch") { next; }
   if ($newversion eq "9" && $rpmname eq "zlib-devel") { next; }
   if ($newversion eq "9" && $rpmname eq "zlib") { next; }
   if ($newversion eq "9" && $rpmname eq "quota") { next; }
   if ($newversion eq "9" && $rpmname eq "ypserv") { next; }
   if ($newversion eq "9" && $rpmname eq "hwdata") { next; }
   if ($newversion eq "9" && $rpmname eq "binutils") { next; }
   if ($newversion eq "9" && $rpmname eq "XFree86-truetype-fonts") { next; }
   if ($newversion eq "9" && $rpmname eq "XFree86-xfs") { next; }
   if ($vendor =~ /redhat/i || $vendor =~ /red hat/i) {
      $rpm->install($rpmname,0,0,"/home/distupgrade",1);
   }
}

print "System Update Complete..\n";
print "Updating cPanel...\n";
unlink("/usr/local/cpanel/cpanel");
system("/scripts/upcp");