D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
usr
/
local
/
bin
/
Filename :
ea_install_profile
back
Copy
#!/usr/local/cpanel/3rdparty/bin/perl # cpanel - ea_install_profile Copyright(c) 2016 cPanel, Inc. # All rights Reserved. # copyright@cpanel.net http://cpanel.net # This code is subject to the cPanel license. Unauthorized copying is prohibited package ea_install_profile; use strict; use Cpanel::JSON; use Cpanel::PackMan; use Cpanel::Config::Httpd; use Data::Dumper; use Path::Tiny 'path'; sub usage { my ($msg) = @_; print "Error: $msg\n" if defined $msg; print "usage: ea_install_profile [--firstinstall|--install] profile_file\n"; print "\n"; print " With no flags, $0 will only do conflict resolution on the profile.\n"; print "\n"; print " --install: Resolve conflicts and install the profile.\n"; print " --firstinstall: Attempt to do the install without conflict resolution and fallback\n"; print " to doing --install if it fails. This is only intended to be used\n"; print " on a fresh cPanel install.\n"; print "\n"; exit( $msg ? 1 : 0 ); } sub script { my (@args) = @_; die "May only be run if you are using EasyApache 4" if ( !Cpanel::Config::Httpd::is_ea4() ); my $profile; my $install = 0; my $firstinstall = 0; my $idx = 0; if ( $args[$idx] eq "--firstinstall" ) { $idx++; $firstinstall = 1; } if ( $args[$idx] eq "--install" ) { $idx++; $install = 1; } usage() if ( !defined $args[$idx] ); $profile = $args[$idx]; if ( !-f $profile ) { $profile = "/etc/cpanel/ea4/profiles/custom/" . $profile; usage("Cannot find profile") if !-f $profile; } my @addl_prefixes = eval { map { $_->basename } path("/etc/cpanel/ea4/additional-pkg-prefixes/")->children; }; print "Loading profile …\n"; my %server_pkgs; @server_pkgs{ Cpanel::PackMan->instance->list( 'prefix' => 'ea-' ) } = (); for my $prefix (@addl_prefixes) { @server_pkgs{ Cpanel::PackMan->instance->list( 'prefix' => "$prefix-" ) } = (); } my $data = Cpanel::JSON::LoadFile($profile); # 1. detect any packages in the profile that do not exist on the server my %not_on_server = ( map { !exists $server_pkgs{$_} ? ( $_ => undef ) : () } @{ $data->{pkgs} } ); # 2. remove %not_on_server from $profile->{pkgs} $data->{pkgs} = [ grep { !exists $not_on_server{$_} } @{ $data->{pkgs} } ]; # 3. Tell them about the ones we are ignoring my $derps = 0; for my $derppkg ( sort keys %not_on_server ) { warn " * Warning! ignored package: $derppkg. It is in the profile’s package list but does not exist on this server.\n"; $derps++; } print "\n" if $derps; if ( $data->{pre} ) { print "Installing prereqs …\n"; my $sys = Cpanel::PackMan->instance->sys; $sys->install( @{ $data->{pre} } ); # apt, yum, and dnf’s `install` will install if its not installed, upgrade if its old, noop if its already the latest $sys->cache; # this is needed in case a new package repo was put in place print " … prereqs done!\n\n"; } if ($firstinstall) { print "The system is running in first install mode and will install the requested packages without resolving conflicts …\n"; local $@; eval { Cpanel::PackMan->instance->sys->install( @{ $data->{pkgs} } ); }; print " … done!\n"; if ($@) { warn "First install method failed ($@)."; warn "The system will fall back to doing a full install."; $install = 1; } else { return 0; } } print "The system is resolving package dependencies and conflicts. This may take some time …\n"; my $resolve_method = defined &Cpanel::PackMan::resolve_multi_op_ns ? 'resolve_multi_op_ns' : 'resolve_multi_op'; my $res = Cpanel::PackMan->instance->$resolve_method( $data->{'pkgs'}, 'ea' ); for my $prefix (@addl_prefixes) { my $prefix_res = eval { Cpanel::PackMan->instance->$resolve_method( $data->{'pkgs'}, $prefix ) }; if ($@) { if ( $@ =~ m/Unknown namespace/ ) { warn "!!!! Your system is not new enough to support EA4 pkg prefixes besides `ea-`, other prefixes will be left out !!\n"; last; } else { chomp $@; warn "!!!! There was a problem with the additional-pkg-prefix “$prefix”, it will be left out !!\n\tError: $@\n"; next; } } for my $field (qw(uninstall unaffected upgrade install)) { push @{ $res->{$field} }, @{ $prefix_res->{$field} }; } } print " … done!\n"; if ($install) { print "Installing …\n"; my $actions = Cpanel::PackMan->instance->multi_op($res); if ( !$actions ) { print " … nothing to do.\n"; } else { print " … done!\n"; } } else { print Dumper($res); } return 0; } exit( script(@ARGV) ) unless caller(); 1;
Name
Size
Last Modified
Owner
Permissions
Actions
crontab
1.84
MB
April 13 2025 3:40:14
root
0755
ea-php74
6.09
MB
December 28 2023 2:49:36
root
0755
ea-php80
7.62
MB
December 07 2023 10:30:22
root
0755
ea-php82
7.77
MB
January 25 2024 10:31:01
root
0755
ea-php83
7.79
MB
January 25 2024 10:38:19
root
0755
ea_convert_php_ini
39.854
KB
January 17 2024 4:13:36
root
0755
ea_current_to_profile
8.666
KB
January 17 2024 4:13:36
root
0755
ea_install_profile
5.16
KB
January 17 2024 4:13:36
root
0755
ea_sync_user_phpini_settings
6.727
KB
January 17 2024 4:13:36
root
0755
instmodsh
4.096
KB
June 16 2020 5:36:48
root
0555
json_xs
6.849
KB
July 28 2023 3:38:27
root
0555
lsphp
0.915
KB
September 28 2023 10:21:10
root
0755
ollama
28.53
MB
December 17 2024 6:07:40
root
0755
passwd
3.5
MB
April 13 2025 3:40:20
root
0755
pear
0.374
KB
March 23 2023 4:16:50
root
0755
php
0.911
KB
September 28 2023 10:21:10
root
0755
wp-toolkit
0.163
KB
April 04 2025 2:19:33
root
0700
2017 © D7net | D704T team