File: //proc/self/root/proc/self/root/scripts.20110531.215904.25158/bsdcryptoinstall
#!/usr/bin/perl
# cpanel - bsdcryptoinstall 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', '/scripts'; }
use Digest::MD5;
use cPanelBSDPKGS;
use Cpanel::OSSys;
my($system,$release,$machine) = (Cpanel::OSSys::uname())[0,2,4];
if (-e "/usr/lib/libcrypto.so") {
exit();
}
my @GOODURLS;
if ($#SYSMIRRORLIST > -1) {
@GOODURLS = @SYSMIRRORLIST;
} else {
@GOODURLS = cPanelBSDPKGS::getmirrorlist();
@SYSMIRRORLIST = @GOODURLS;
}
use Cpanel::OSSys;
my($sysname, $nodename, $release, $version, $machine) = Cpanel::OSSys::uname();
my $basedir = '/usr/home/crypto-install';
mkdir($basedir,0700);
my(@PKGS) = ("crypto");
foreach my $pkg (@PKGS) {
mkdir("${basedir}/${pkg}",0700);
getfile($pkg,$basedir,"CHECKSUM.MD5");
open(BASE,"${basedir}/${pkg}/CHECKSUM.MD5");
while(<BASE>) {
/\S+\s*\(([^\)]+)\)\s*=\s*(\S+)/;
my $file = $1;
my $md5 = $2;
if (!checkdigest($pkg,$basedir,$file,$md5)) {
unlink("${basedir}/${pkg}/${file}");
getfile($pkg,$basedir,$file);
}
if (!checkdigest($pkg,$basedir,$file,$md5)) {
getfile($pkg,$basedir,$file);
}
if (!checkdigest($pkg,$basedir,$file,$md5)) {
die "${file}: md5 check failed!";
} else {
print "${file}: md5 check passed!\n";
}
}
close(BASE);
chdir("${basedir}/${pkg}");
chmod(0700,"install.sh");
open(INS,"|./install.sh");
print INS "y\n";
close(INS);
}
system("/scripts/bsdldconfig");
sub getfile {
my($pkg,$basedir,$file) = @_;
foreach my $pkghost (@GOODURLS) {
if ((stat("${basedir}/${pkg}/${file}"))[7] > 0) {
last;
}
system("fetch","-o","${basedir}/${pkg}/${file}","${pkghost}/pub/FreeBSD/releases/i386/${release}/${pkg}/${file}");
if ((stat("${basedir}/${pkg}/${file}"))[7] > 0) {
last;
}
}
}
sub checkdigest {
my($pkg,$basedir,$file,$md5) = @_;
if (! -e "${basedir}/${pkg}/${file}") { return(0); }
my $ctx = Digest::MD5->new;
open(FILE,"${basedir}/${pkg}/${file}");
$ctx->addfile(\*FILE);
close(FILE);
my $digest = $ctx->hexdigest;
if ($digest eq $md5) {
return(1);
} else {
return(0);
}
}