Gestionnaire de fichiers - Editer - /usr/local/cpanel/scripts/fix_pear_registry
Arrière
#!/usr/local/cpanel/3rdparty/bin/perl # cpanel - scripts/fix_pear_registry 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 use strict; use Cpanel::Imports; use Cpanel::Binaries (); use Cpanel::Pkgr (); use Cpanel::SafeRun::Object (); # This script is intended to clean up after the Horde and other PEAR RPMs that had # a faulty %postun. This has since been fixed, but the script is needed as a one-time # operation to repair the PEAR registry, since the %postun of the old RPM is executed # after the new RPM's %post has already run. This could be handled with a %triggerpostun, # but that would add a new element to the long-term behavior of the RPMs, which is # undesirable for this one-time cleanup measure. exit run(@ARGV) unless caller; sub run { my %report; my $pear_bin = Cpanel::Binaries::CPANEL_PHP_BIN() . '/pear'; # Don't use Cpanel::FindBin for this. It may grab the system pear, which we don't want. my $php_rpm_prefix = 'cpanel-php' . Cpanel::Binaries::get_php_version( flat => 1 ) . '*'; my @installed_pear_packages = keys( %{ Cpanel::Pkgr::installed_packages($php_rpm_prefix) } ); $report{installed} = @installed_pear_packages; for my $pkg ( sort @installed_pear_packages ) { my $xmlfile = Cpanel::Binaries::CPANEL_PHP . '/lib/pear/' . $pkg . '.xml'; if ( -f $xmlfile ) { my $package_is_registered = is_registered($pkg); if ($package_is_registered) { logger->info( locale->maketext( 'The “[_1]” package is already in the [asis,PEAR] registry.', $pkg ) ); $report{already_registered}++; next; } $report{not_already_registered}++; my @pear_args = ( qw(install --nodeps --force --register-only), $xmlfile ); my $run = Cpanel::SafeRun::Object->new( program => $pear_bin, args => \@pear_args, ); if ( $run->CHILD_ERROR || !is_registered($pkg) ) { logger->warn( locale->maketext( 'The system failed to add the [asis,PEAR] registry entry for “[_1]”: [_2]', $pkg, $run->stdout ) ); # pear errors are on stdout, and pear may exit zero without actually doing anything logger->warn("Command: $pear_bin @pear_args"); $report{failed}++; } else { print $run->stdout; logger->info( locale->maketext( 'The system added the [asis,PEAR] registry entry for “[_1]”.', $pkg ) ); $report{succeeded}++; } } else { logger->info( locale->maketext( 'The system could not find the [asis,XML] file for “[_1]”.', $pkg ) ); $report{no_xml}++; } } logger->info( locale->maketext( 'There are [numf,_1] installed [asis,PEAR] packages. Of those packages, [numf,_2] already existed in the [asis,PEAR] registry, [numf,_3] did not, and [numf,_4] did not contain an [asis,XML] file. Of the [quant,_3,package,packages] not listed in the registry, the system successfully added [numf,_5], and failed to add [numf,_6].', map { $_ || 0 } @report{qw(installed already_registered not_already_registered no_xml succeeded failed )} ) ); # We can't count on every single PEAR package to always register successfully, so only exit nonzero if something # very bad like the pear binary being missing occurred. return 0; } sub is_registered { my ($pkg) = @_; my $pear_bin = Cpanel::Binaries::THIRD_PARTY_BIN . '/pear'; return scalar grep { my $channel = $_; my @pear_args = ( qw(list -c horde), "$channel/$pkg" ); my $run = Cpanel::SafeRun::Object->new( program => $pear_bin, args => \@pear_args, ); !$run->CHILD_ERROR; } 'horde', 'pear'; }
| ver. 1.4 |
Github
|
.
| PHP 8.0.30 | Génération de la page: 0.01 |
proxy
|
phpinfo
|
Réglages