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/checkwebdiskproxydomains
#!/usr/bin/perl
# cpanel - checkwebdiskproxydomains               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 Cpanel::Proxy              ();
use Cpanel::Config::LoadCpConf ();
use Cpanel::HttpUtils::Version ();
use Cpanel::SafeRun::Errors    ();
use Getopt::Long;
use Pod::Usage;

if ( $> != 0 ) {
    die "Must be root to run /scripts/checkwebdiskproxydomains";
}

# process arguments

my $help;
my $man;
my $force;

GetOptions( 'help' => \$help, 'man' => \$man, 'force' => \$force );

pod2usage( { -verbose => 2 } ) if $man;
pod2usage(1) if $help;

# Verify it's configured
my $cpconf_ref = Cpanel::Config::LoadCpConf::loadcpconf();
unless ( $force || ( defined $cpconf_ref->{'proxysubdomains'} && $cpconf_ref->{'proxysubdomains'} eq '1' && !-e '/var/cpanel/version/proxydomains2' ) ) {
    exit 0;
}

# Update DNS
my %args = ();
if ( !$force && ( -e '/var/cpanel/version/proxydomains' || -e '/var/cpanel/version/proxydomains2' ) ) {

    # only update the webdisk subdomain if proxydomains has been run before
    %args = ( 'subdomain' => 'webdisk' );
}

print "***Updating DNS records***\n";
my $rsp = Cpanel::Proxy::setup_all_proxy_subdomains(%args);
foreach my $response ( @{$rsp} ) {
    print $response->{'domain'} . ' - ' . $response->{'msg'} . "\n";
}

# Update httpd.conf and template
my $apache_short_version = Cpanel::HttpUtils::Version::get_current_apache_version_key();
if ($apache_short_version) {
    $apache_short_version = substr( $short_version, 0, 1 );
    my $output = Cpanel::SafeRun::Errors::saferunnoerror( 'grep', '# CPANEL/WHM/WEBMAIL/WEBDISK PROXY SUBDOMAINS', '/var/cpanel/templates/apache' . $short_version . '/main.default' );
    unless ( $output || $force ) {
        print "***Updating httpd.conf***\n";
        system '/usr/local/cpanel/bin/apache_conf_distiller', '--update', '--main';
        system '/usr/local/cpanel/bin/build_apache_conf';
        system '/scripts/restartsrv_httpd';
    }
}

# Note update
if ( open my $fh, '>', '/var/cpanel/version/proxydomains2' ) {
    print {$fh} time;
    close $fh;
}

exit 0;

__END__

=head1 NAME

checkwebdiskproxydomains - Update existing prodydomains install for webdisk

=head1 SYNOPSIS

checkwebdiskproxydomains [options]

    Options:
      --help        Brief help message
      --man         Full help message
      --force       Rerun configuration even if previously done

=head1 DESCRIPTION

The original implimentatin of proxydomains consisted of cpanel, whm
and webmail.  This script updates these older proxydomains configurations
to include the webdisk proxy subdomain.

Most likely, this program has already been run for you and you doesn't need
to be executed manually.

=cut