File: //proc/self/root/scripts.20110531.215904.25158/synctransfers
#!/usr/bin/perl
# cpanel - synctransfers 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::Update ();
use Cpanel::Config::Sources ();
use Cpanel::SafeDir ();
use Cpanel::SafeRun ();
my $tree = 'transfers_';
my $sync_dir = 'transfers';
my $base = '/usr/local/cpanel/Whostmgr/Pkgacct/';
my %CPSRC = Cpanel::Config::Sources::loadcpsources();
my $updateconf_ref = Cpanel::Update::loadupdateconfig();
if ( !-e $base ) {
Cpanel::SafeDir::safemkdir($base) or die "Unable to create directory: $!";
}
if ( !exists $updateconf_ref->{'CPANEL'} || !$updateconf_ref->{'CPANEL'} ) {
$tree .= 'RELEASE';
}
elsif ( $updateconf_ref->{'CPANEL'} eq 'stable' || $updateconf_ref->{'CPANEL'} eq 'manual' ) {
$tree .= 'STABLE';
}
elsif ( $updateconf_ref->{'CPANEL'} =~ m/(nightly|demo)/i ) {
$tree .= 'NIGHTLY';
}
elsif ( $updateconf_ref->{'CPANEL'} eq 'manual-edge' || $updateconf_ref->{'CPANEL'} eq 'edge' ) {
$tree .= 'EDGE';
}
elsif ( $updateconf_ref->{'CPANEL'} eq 'manual-current' || $updateconf_ref->{'CPANEL'} eq 'current' ) {
$tree .= 'CURRENT';
}
elsif ( $updateconf_ref->{'CPANEL'} eq 'manual-beta' || $updateconf_ref->{'CPANEL'} eq 'beta' ) {
$tree .= 'BETA';
}
else {
$tree .= 'RELEASE';
}
if ( -x '/scripts/cpanelsync' ) {
print "Sync transfer scripts...\n";
if ( my $pid = fork() ) {
while ( waitpid( $pid, 1 ) != -1 ) {
# wait...
}
}
else {
system( '/scripts/cpanelsync', $CPSRC{'HTTPUPDATE'}, "/cpanelsync/$tree/pkgacct", $base );
exit;
}
}
if ( -d '/usr/local/cpanel/Whostmgr/pkgacct' ) {
Cpanel::SafeRun::saferun( 'rm', '-rf', '/usr/local/cpanel/Whostmgr/pkgacct' );
}
print "Done.\n";