????
Current Path : /scripts/ |
Current File : //scripts/updatephpconf |
#!/usr/local/cpanel/3rdparty/bin/perl # cpanel - updatephpconf Copyright 2012 cPanel, Inc. # All rights Reserved. # copyright@cpanel.net http://cpanel.net # This code is subject to the cPanel license. Unauthorized copying is prohibited use Cpanel::Config (); use Cpanel::Logger (); use Cpanel::PHPINI (); use Cpanel::HttpUtils::ApRestart::BgSafe (); my $logger = Cpanel::Logger->new(); my $needs_update = Cpanel::PHPINI::conf_update_needed(); my @php_paths = Cpanel::PHPINI::get_installed_paths(); if ( @ARGV && -d $ARGV[0] ) { push @php_paths, $ARGV[0]; } @php_paths = grep { -d $_ } @php_paths; $logger->die('No PHP prefixes found, please check your installation') if !@php_paths; foreach my $path (@php_paths) { my $php_prefix = Cpanel::PHPINI::_check_php_prefix($path); next if !$php_prefix; # No directory my $php_ini = Cpanel::PHPINI::_get_php_ini_in_dir($php_prefix); if ( !$php_ini ) { if ( -x $php_prefix . '/bin/php' ) { if ( !-e $php_prefix . '/lib' ) { mkdir $php_prefix . '/lib'; } if ( -e $php_prefix . '/lib' ) { system 'cp', '-f', '/usr/local/cpanel/scripts/php.ini', $php_prefix . '/lib/php.ini'; $needs_update = 1; } else { $logger->warn("Unable to install default php.ini in $php_prefix"); next; } } else { next; } } if ($needs_update) { print "Updating php.ini for $php_prefix ..."; if ( Cpanel::PHPINI::update_config($php_prefix) ) { chmod 0644, $php_prefix . '/lib/php.ini'; print "Done\n"; } else { print "\nFAILED to update php.ini for $php_prefix\n\n"; } } } if ( $needs_update && Cpanel::PHPINI::update_conf_version() ) { my $version = Cpanel::PHPINI::get_conf_version(); print "Updated php.ini default values to version $version\n"; if ( Cpanel::Config::service_enabled('httpd') ) { print "Restarting Apache\n"; Cpanel::HttpUtils::ApRestart::BgSafe::restart(); } }