Server IP : 103.119.228.120 / Your IP : 18.219.253.199 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,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,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON 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;