Файловый менеджер - Редактировать - /usr/local/cpanel/scripts/dav_change_hostname
Назад
#!/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;
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Генерация страницы: 0.07 |
proxy
|
phpinfo
|
Настройка