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: //scripts.20110531.215904.25158/cpanel_easy_sanity_check
#!/usr/bin/perl
# cpanel - cpanel_easy_sanity_check               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 Cpanel::Config::Sources       ();
use Cpanel::Encoder::Tiny         ();
use Cpanel::SafeDir::MK           ();
use Cpanel::SafeRun::Dynamic      ();
use Cpanel::CPAN::Digest::MD5::File ();
use Cpanel::CPAN::Getopt::Param     ();

my $param = Cpanel::CPAN::Getopt::Param->new();
my $loud  = $param->param('quiet') ? 0 : 1;
my $html  = $param->param('as-html') ? 1 : 0;

if ( -e '/var/cpanel/easy_skip_cpanelsync' ) {
    print "Skipping cPanel Sync as per file\n" if $loud;
    exit;
}

my $opt_mod_dir    = '/var/cpanel/perl/easy';
my $httpupdate_uri = 'easy';

if ( defined $param->param('test-branch') ) {
    if ( $param->param('test-branch') ) {
        my $branch = $param->param('test-branch');
        $httpupdate_uri .= $branch =~ m{^[^-\s]\S+$}s ? "_$branch" : '_test';
    }
}
elsif ( -e '/var/cpanel/use_easy_test_branch' ) {
    my $branch = 'test';
    if ( !-z '/var/cpanel/use_easy_test_branch' ) {
        open my $uetb_fh, '/var/cpanel/use_easy_test_branch' || die "Could not open /var/cpanel/use_easy-test_branch for reading: $!";
        my $content = readline($uetb_fh);
        close $uetb_fh;
        chomp $content;
        $branch = $content if $content && $content =~ m{ \A \S+ \z }xms;
    }

    $httpupdate_uri .= "_$branch";
}

if ( !-d $opt_mod_dir ) {
    Cpanel::SafeDir::MK::safemkdir($opt_mod_dir) or die "Could not create opt mod directory: $!";
}

my $action = $param->param('action') || '';
my $skip = $action eq '_pre_cpanel_sync_screen' || $param->param('help') || $param->param('skip-cpanelsync') ? 1 : 0;
exit if $skip;

my %CPSRC = Cpanel::Config::Sources::loadcpsources();

my $cpanelsync = "$opt_mod_dir/.cpanelsync";

if ( -x '/scripts/cpanelsync' ) {
    my $orig = -e $cpanelsync ? Cpanel::CPAN::Digest::MD5::File::file_md5_hex($cpanelsync) : 0;

    for my $run ( [ "/cpanelsync/$httpupdate_uri/Cpanel", "$opt_mod_dir/Cpanel" ], [ "/cpanelsync/$httpupdate_uri/profiles", '/var/cpanel/' ], ) {
        $|++;
        Cpanel::SafeRun::Dynamic::livesaferun(
            'prog'      => [ '/scripts/cpanelsync', $CPSRC{'HTTPUPDATE'}, @{$run} ],
            'formatter' => sub {
                my ($line) = @_;

                if ($html) {
                    chomp $line;
                    $line = Cpanel::Encoder::Tiny::safe_html_encode_str($line);
                    $line .= "<br />\n";
                }

                return $line if $loud;

                if (   $line =~ /The update server is currently updating its files/i
                    || $line =~ /It may take up to 30 minutes before access can be obtained/i
                    || $line =~ /Waiting 30 seconds for access to the update server/i
                    || $line =~ /Checking again/i ) {

                    return $line;
                }

                return '';    # empty string to stay quiet && avoid uninit value warnings
            },
        );
    }

    my $crnt = -e $cpanelsync ? Cpanel::CPAN::Digest::MD5::File::file_md5_hex($cpanelsync) : 0;

    unlink '/var/cpanel/easy/apache/state.yaml' if !$orig || !$crnt || $orig ne $crnt;
}
else {
    die '/scripts/cpanelsync must exist and be executable';
}