MOON
Server: Apache
System: Linux vps.thepromohut.com 2.6.18-398.el5 #1 SMP Tue Sep 16 20:51:48 EDT 2014 i686
User: caretrak (507)
PHP: 5.2.10
Disabled: NONE
Upload Files
File: //scripts.20110601.041516.15411/check_system_storable
#!/usr/bin/perl
# cpanel - check_system_storable                  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 strict;
use warnings;
use Storable;

my $unlink = 0;
my $file   = "/tmp/ensure_store.$$";

if ( @ARGV && -e $ARGV[0] ) {
    $file = $ARGV[0];
}
else {
    warn "Specified file does not exist, defaulting to $file...";
    $unlink = 1;
}

if ( !-e $file ) {

    # create cPanel Storable data store
    system '/usr/local/cpanel/whostmgr/bin/whostmgr', '--make_test_store', $file;
    die "Could not make $file" if !-e $file;
}

my $hr;

# Load cPanel Storable data store with system's Storable
eval {
    $hr = retrieve($file);    # load it with 'binary's Storbale'
};

unlink $file if $unlink;      # quietly remove it if we created it

if ( $@ =~ m{Byte order} || ref $hr ne 'hashref' || $hr->{'test'} ne 'storable' ) {

    # down load and untar tarball

    print "Incompatibility between system Storable and cPanel's Storable detected!\n";

    #require '/scripts/Cpanel/HttpRequest.pm';
    #
    #my $os = 'TODO';
    #my $targz = "$file.tar.gz";
    #
    #Cpanel::HttpRequest->new()->request(
    #    'host'     => 'layer1.cpanel.net',
    #    'url'      => '/perl/$os/perl.tar.gz',
    #    'destfile' => $targz,
    #) || die 'Could not download tarball';
    #
    #die 'Tarball download failed' if !-e $targz || -z $targz;
    #
    #chdir '/usr/local/cpanel' or die "Could not go intop /usr/local : $!";
    #
    #system qw(tar xzf), $targz;
    #
    #unlink $targz or warn "Unable to remove $targz: $!";
}