Server IP : 221.132.30.236 / Your IP : 216.73.216.91 [ Web Server : Apache System : Linux web3.trangwebvang.net 2.6.32-954.3.5.lve1.4.86.el6.x86_64 #1 SMP Tue Aug 31 17:08:39 UTC 2021 x86_64 User : cherishhotel ( 944) PHP Version : 5.6.40 Disable Function : exec, system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice, proc_terminate, proc_get_status, proc_close, pfsockopen, leak, apache_child_terminate, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid,dl,symlink Domains : 0 Domains MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /scripts/ |
Upload File : |
#!/usr/local/cpanel/3rdparty/bin/perl # cpanel - scripts/dav_change_hostname Copyright 2022 cPanel, L.L.C. # All rights reserved. # copyright@cpanel.net http://cpanel.net # This code is subject to the cPanel license. Unauthorized copying is prohibited package scripts::dav_change_hostname; use strict; use Getopt::Long (); use Cpanel::DAV::Hostname (); use Cpanel::iContact::Class::DAV::ChangeHostname (); use Cpanel::Logger::Aggregator (); use Cpanel::Imports; exit main(@ARGV) unless caller; sub main { my @args = my @orig_args = @_; my ( $old_hostname, $new_hostname, $verbose, $notify, $help, $users ); my $log_aggregator = Cpanel::Logger::Aggregator->new(); Getopt::Long::GetOptionsFromArray( \@args, 'old=s' => \$old_hostname, 'new=s' => \$new_hostname, 'user=s@' => \$users, 'verbose' => \$verbose, 'notify' => \$notify, 'help' => \$help ) and $old_hostname and $new_hostname and !@args or _die_usage(@orig_args); _exit_usage(@orig_args) if $help; $log_aggregator->info( locale->maketext( 'The system will now change the calendar and address book hostnames from “[_1]” to “[_2]”.', $old_hostname, $new_hostname ) ); my $result = Cpanel::DAV::Hostname::change_host_name( $old_hostname, $new_hostname, { callback => \&callback, verbose => $verbose, users => $users } ); my $ok = 0; if ( $result->{status} ) { $log_aggregator->info( locale->maketext( 'The system successfully updated the hostnames for all [numf,_1] users.', scalar( @{ $result->{success} } ) ) ); $ok = 1; } elsif ( !@{ $result->{success} } && !@{ $result->{failures} } ) { $log_aggregator->info( locale->maketext('No users require a hostname update.') ); $ok = 1; } else { if ( @{ $result->{success} } ) { $log_aggregator->info( locale->maketext( 'The system successfully updated the hostnames for [numf,_1] users.', scalar( @{ $result->{success} } ) ) ); } $log_aggregator->info( locale->maketext('The system failed to update some of the hostnames with the following errors:') ); $log_aggregator->info("$_->{user}: $_->{exception}") for @{ $result->{failures} }; } if ($notify) { Cpanel::iContact::Class::DAV::ChangeHostname->new( old_hostname => $old_hostname, new_hostname => $new_hostname, detail => $log_aggregator->as_text, status => $ok ); } return $ok ? 0 : 1; } sub callback { my ( $method, $msg ) = @_; my $fn = logger->can($method); if ($fn) { $fn->($msg); } else { logger->info($msg); } return; } sub _die_usage { my @orig_args = @_; print <<EOU; Invalid argument set: @orig_args EOU die _usage(); } sub _exit_usage { print _usage(); exit; } sub _usage { return <<EOU; usage: $0 --old <old hostname> --new <new hostname> --verbose This script updates stored calendar and address book data for all users on the system to reflect a new hostname. It should be called at or near the same time that the server hostname is changed. Options: --verbose - If passed will generate more verbose output. --user - One or more users. If not provided, the script will run for all users on the system. --notify - If provided, the script will send a notification to the server contact upon success or failure with additional detail about the outcome of the run. EOU } 1;