Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial support for Ubuntu 20 to Ubuntu 22 upgrades #547

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,404 changes: 1,087 additions & 317 deletions elevate-cpanel

Large diffs are not rendered by default.

96 changes: 51 additions & 45 deletions lib/Elevate/Components.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,53 @@ use cPstrict;
# enforce packing these packages
use Elevate::Components::Base ();

use Elevate::Components::AbsoluteSymlinks ();
use Elevate::Components::AutoSSL ();
use Elevate::Components::BootKernel ();
use Elevate::Components::CCS ();
use Elevate::Components::CloudLinux ();
use Elevate::Components::cPanelPlugins ();
use Elevate::Components::cPanelPrep ();
use Elevate::Components::DatabaseUpgrade ();
use Elevate::Components::DiskSpace ();
use Elevate::Components::Distros ();
use Elevate::Components::DNS ();
use Elevate::Components::EA4 ();
use Elevate::Components::ElevateScript ();
use Elevate::Components::ELS ();
use Elevate::Components::Grub2 ();
use Elevate::Components::Imunify ();
use Elevate::Components::InfluxDB ();
use Elevate::Components::IsContainer ();
use Elevate::Components::JetBackup ();
use Elevate::Components::KernelCare ();
use Elevate::Components::Kernel ();
use Elevate::Components::Leapp ();
use Elevate::Components::LiteSpeed ();
use Elevate::Components::MountPoints ();
use Elevate::Components::MySQL ();
use Elevate::Components::NICs ();
use Elevate::Components::NixStats ();
use Elevate::Components::OVH ();
use Elevate::Components::PackageRestore ();
use Elevate::Components::PackageDupes ();
use Elevate::Components::Panopta ();
use Elevate::Components::PECL ();
use Elevate::Components::PerlXS ();
use Elevate::Components::PostgreSQL ();
use Elevate::Components::R1Soft ();
use Elevate::Components::Repositories ();
use Elevate::Components::RmMod ();
use Elevate::Components::RpmDB ();
use Elevate::Components::SSH ();
use Elevate::Components::Softaculous ();
use Elevate::Components::UnconvertedModules ();
use Elevate::Components::WHM ();
use Elevate::Components::WPToolkit ();
use Elevate::Components::Acronis ();
use Elevate::Components::AbsoluteSymlinks ();
use Elevate::Components::AutoSSL ();
use Elevate::Components::BootKernel ();
use Elevate::Components::CCS ();
use Elevate::Components::CloudLinux ();
use Elevate::Components::cPanelPlugins ();
use Elevate::Components::cPanelPrep ();
use Elevate::Components::DatabaseUpgrade ();
use Elevate::Components::DiskSpace ();
use Elevate::Components::Distros ();
use Elevate::Components::DNS ();
use Elevate::Components::EA4 ();
use Elevate::Components::ElevateScript ();
use Elevate::Components::ELS ();
use Elevate::Components::Grub2 ();
use Elevate::Components::Imunify ();
use Elevate::Components::InfluxDB ();
use Elevate::Components::IsContainer ();
use Elevate::Components::JetBackup ();
use Elevate::Components::KernelCare ();
use Elevate::Components::Kernel ();
use Elevate::Components::Leapp ();
use Elevate::Components::Lists ();
use Elevate::Components::LiteSpeed ();
use Elevate::Components::MountPoints ();
use Elevate::Components::MySQL ();
use Elevate::Components::NICs ();
use Elevate::Components::NixStats ();
use Elevate::Components::OVH ();
use Elevate::Components::PackageRestore ();
use Elevate::Components::PackageDupes ();
use Elevate::Components::Panopta ();
use Elevate::Components::PECL ();
use Elevate::Components::PerlXS ();
use Elevate::Components::PostgreSQL ();
use Elevate::Components::R1Soft ();
use Elevate::Components::Repositories ();
use Elevate::Components::RmMod ();
use Elevate::Components::RpmDB ();
use Elevate::Components::SSH ();
use Elevate::Components::Softaculous ();
use Elevate::Components::UnconvertedModules ();
use Elevate::Components::UpdateReleaseUpgrades ();
use Elevate::Components::UpdateSystem ();
use Elevate::Components::WHM ();
use Elevate::Components::WPToolkit ();
use Elevate::Components::Acronis ();

use Simple::Accessor qw(
cpev
Expand Down Expand Up @@ -91,7 +94,9 @@ our @CHECKS = qw{

MySQL
Repositories
Lists
JetBackup
KernelCare
NICs
EA4
BootKernel
Expand All @@ -109,7 +114,6 @@ our @NOOP_CHECKS = qw{
ELS
InfluxDB
Kernel
KernelCare
LiteSpeed
NixStats
PECL
Expand All @@ -123,6 +127,8 @@ our @NOOP_CHECKS = qw{
RpmDB
Softaculous
UnconvertedModules
UpdateReleaseUpgrades
UpdateSystem
WPToolkit
cPanelPlugins
cPanelPrep
Expand Down
30 changes: 20 additions & 10 deletions lib/Elevate/Components/DNS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use Log::Log4perl qw(:easy);

sub check ($self) {

return $self->_blocker_non_bind_powerdns( _get_nameserver_type() );
return $self->_blocker_nameserver_not_supported( _get_nameserver_type() );
}

sub _get_nameserver_type () {
Expand All @@ -43,17 +43,27 @@ sub _get_nameserver_type () {
return $cpconf->{'local_nameserver_type'} // '';
}

sub _blocker_non_bind_powerdns ( $self, $nameserver = '' ) {
sub _blocker_nameserver_not_supported ( $self, $nameserver = '' ) {

if ( $nameserver eq 'nsd' or $nameserver eq 'mydns' ) {
my $pretty_distro_name = Elevate::OS::upgrade_to_pretty_name();
return $self->has_blocker( <<~"EOS");
$pretty_distro_name only supports bind or powerdns. We suggest you switch to powerdns.
Before upgrading, we suggest you run: /scripts/setupnameserver powerdns.
EOS
}
# Nameserver is not set so it is likely disabled which is ok
return 0 unless length $nameserver;

return 0;
my @supported_nameserver_types = Elevate::OS::supported_cpanel_nameserver_types();
return 0 if grep { $_ eq $nameserver } @supported_nameserver_types;

my $pretty_distro_name = Elevate::OS::upgrade_to_pretty_name();
my $supported_nameservers = join( "\n", @supported_nameserver_types );
return $self->has_blocker( <<~"EOS");
$pretty_distro_name only supports the following nameservers:

$supported_nameservers

We suggest you switch to powerdns.
Before upgrading, we suggest you run:

/usr/local/cpanel/scripts/setupnameserver powerdns

EOS
}

1;
2 changes: 2 additions & 0 deletions lib/Elevate/Components/Distros.pm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ sub _blocker_os_is_not_supported ($self) {

sub _blocker_is_old_centos7 ($self) {

return if Elevate::OS::skip_minor_version_check();

if ( Cpanel::OS::minor() < MINIMUM_CENTOS_7_SUPPORTED ) { ## no critic(Cpanel::CpanelOS)
my $pretty_distro_name = Elevate::OS::upgrade_to_pretty_name();
return $self->has_blocker(
Expand Down
2 changes: 1 addition & 1 deletion lib/Elevate/Components/EA4.pm
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ sub _backup_config_files ($self) {

Elevate::StageFile::remove_from_stage_file('ea4_config_files');

my $ea4_config_files = Elevate::PkgMgr::get_config_files_for_pkg_prefix('ea-');
my $ea4_config_files = Elevate::PkgMgr::get_config_files_for_pkg_prefix('ea-*');

Elevate::StageFile::update_stage_file( { ea4_config_files => $ea4_config_files } );

Expand Down
4 changes: 4 additions & 0 deletions lib/Elevate/Components/Grub2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ sub _persistent_id {
}

sub mark_cmdline ($self) {
return unless -x GRUBBY_PATH;

my $arg = "elevate-" . _persistent_id;
INFO("Marking default boot entry with additional parameter \"$arg\".");

Expand All @@ -118,6 +120,7 @@ sub _remove_but_dont_stop_service ($self) {
}

sub verify_cmdline ($self) {
return unless -x GRUBBY_PATH;
if ( $self->cpev->should_run_distro_upgrade() ) {
my $arg = "elevate-" . _persistent_id;
INFO("Checking for \"$arg\" in booted kernel's command line...");
Expand Down Expand Up @@ -316,6 +319,7 @@ sub post_distro_upgrade ($self) {

sub check ($self) {

return 1 unless Elevate::OS::needs_leapp();
return 1 unless $self->should_run_distro_upgrade; # skip when --upgrade-distro-manually is provided

my $ok = 1;
Expand Down
20 changes: 13 additions & 7 deletions lib/Elevate/Components/Imunify.pm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ use constant IMUNIFY_LICENSE_BACKUP => Elevate::Constants::ELEVATE_BACKUP_DIR .

sub pre_distro_upgrade ($self) {

return if Elevate::OS::leapp_can_handle_imunify();
if ( Elevate::OS::needs_leapp() ) {
return if Elevate::OS::leapp_can_handle_imunify();
}

return unless $self->is_installed;

Expand All @@ -59,7 +61,9 @@ sub pre_distro_upgrade ($self) {

sub post_distro_upgrade ($self) {

return if Elevate::OS::leapp_can_handle_imunify();
if ( Elevate::OS::needs_leapp() ) {
return if Elevate::OS::leapp_can_handle_imunify();
}

# order matters
$self->run_once('_reinstall_imunify_360');
Expand All @@ -71,8 +75,8 @@ sub post_distro_upgrade ($self) {

sub _capture_imunify_packages ($self) {

# only capture the imunify packages
my @packages = grep { m/^imunify-/ } Elevate::PkgMgr::get_installed_pkgs_in_repo(qw{ imunify imunify360 });
my $pkg_info = Elevate::PkgMgr::get_installed_pkgs('imunify-*');
my @packages = keys %$pkg_info;

return unless scalar @packages;

Expand Down Expand Up @@ -254,7 +258,7 @@ sub _remove_imunify_360 ($self) {
INFO("Imunify360: Removing $product_type prior to upgrade.");
INFO("Imunify360: Product $product_type detected. Uninstalling before upgrade for later restore.");

if ( $self->ssystem( '/usr/bin/bash', $installer_script, '--uninstall' ) != 0 ) {
if ( $self->ssystem( '/usr/bin/bash', $installer_script, '-y', '--uninstall' ) != 0 ) {
LOGDIE("Imunify360: Failed to uninstall $product_type.");
return;
}
Expand All @@ -263,7 +267,9 @@ sub _remove_imunify_360 ($self) {
Elevate::StageFile::update_stage_file( { 'reinstall' => { 'imunify360' => $product_type } } );

# Cleanup any lingering packages.
Elevate::PkgMgr::remove_pkgs_from_repos('imunify');
my $pkg_info = Elevate::PkgMgr::get_installed_pkgs('imunify-*');
my @packages = keys %$pkg_info;
Elevate::PkgMgr::remove(@packages);

return;
}
Expand All @@ -275,7 +281,7 @@ sub _reinstall_imunify_360 ($self) {

my $installer_script = _fetch_imunify_installer($product_type) or return;

if ( $self->ssystem( '/usr/bin/bash', $installer_script ) == 0 ) {
if ( $self->ssystem( '/usr/bin/bash', $installer_script, '-y' ) == 0 ) {
INFO("Successfully reinstalled $product_type.");
}
else {
Expand Down
18 changes: 17 additions & 1 deletion lib/Elevate/Components/JetBackup.pm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,23 @@ sub post_distro_upgrade ($self) {

sub check ($self) {

return $self->_blocker_old_jetbackup;
$self->_blocker_jetbackup_is_supported();
$self->_blocker_old_jetbackup;

return;
}

# Support for JetBackup on Ubuntu is scheduled via RE-668
# For now, we block to reduce scope for the initial release
sub _blocker_jetbackup_is_supported ($self) {
return unless Cpanel::Pkgr::is_installed('jetbackup');
return if Elevate::OS::supports_jetbackup();

my $name = Elevate::OS::default_upgrade_to();
return $self->has_blocker( <<~"END" );
ELevate does not currently support JetBackup for upgrades of $name.
Support for JetBackup on $name will be added in a future version of ELevate.
END
}

sub _blocker_old_jetbackup ($self) {
Expand Down
17 changes: 11 additions & 6 deletions lib/Elevate/Components/Kernel.pm
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,25 @@ sub post_distro_upgrade ($self) {

sub _kernel_check ($self) {

my @kernel_rpms = Elevate::PkgMgr::get_installed_pkgs();
@kernel_rpms = sort grep { m/^kernel-\S+el7/ } @kernel_rpms;
my $kernel_pkgs = Elevate::PkgMgr::get_installed_pkgs('kernel-*');

return unless @kernel_rpms;
chomp @kernel_rpms;
my @el7_kernels;
foreach my $kernel ( sort keys %$kernel_pkgs ) {
if ( $kernel_pkgs->{$kernel} =~ m/\.el7\./ ) {
push @el7_kernels, "$kernel-$kernel_pkgs->{$kernel}";
}
}

return unless @el7_kernels;

my $pretty_distro_name = Elevate::OS::upgrade_to_pretty_name();

my $msg = "The following kernels should probably be removed as they will not function on $pretty_distro_name:\n\n";
foreach my $kernel (@kernel_rpms) {
foreach my $kernel (@el7_kernels) {
$msg .= " $kernel\n";
}

$msg .= "\nYou can remove these by running: /usr/bin/rpm -e " . join( " ", @kernel_rpms ) . "\n";
$msg .= "\nYou can remove these by running: /usr/bin/rpm -e " . join( " ", @el7_kernels ) . "\n";

Elevate::Notify::add_final_notification($msg);

Expand Down
15 changes: 14 additions & 1 deletion lib/Elevate/Components/KernelCare.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Elevate::Components::KernelCare

=head2 check

noop
Check if KernelCare is supported for the upgrade if it is installed

=head2 pre_distro_upgrade

Expand Down Expand Up @@ -36,6 +36,7 @@ use parent qw{Elevate::Components::Base};

sub pre_distro_upgrade ($self) {

return unless Elevate::OS::supports_kernelcare();
return if Elevate::OS::leapp_can_handle_kernelcare();

$self->run_once("_remove_kernelcare_if_needed");
Expand All @@ -45,6 +46,7 @@ sub pre_distro_upgrade ($self) {

sub post_distro_upgrade ($self) {

return unless Elevate::OS::supports_kernelcare();
return if Elevate::OS::leapp_can_handle_kernelcare();

$self->run_once('_restore_kernelcare');
Expand Down Expand Up @@ -92,4 +94,15 @@ sub _restore_kernelcare ($self) {
return;
}

sub check ($self) {
return unless -x q[/usr/bin/kcarectl];
return if Elevate::OS::supports_kernelcare();

my $name = Elevate::OS::default_upgrade_to();
return $self->has_blocker( <<~"EOS" );
ELevate does not currently support KernelCare for upgrades of $name.
Support for KernelCare on $name will be added in a future version of ELevate.
EOS
}

1;
3 changes: 3 additions & 0 deletions lib/Elevate/Components/Leapp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ noop
use cPstrict;

use Elevate::Constants ();
use Elevate::OS ();

use parent qw{Elevate::Components::Base};

Expand All @@ -33,6 +34,8 @@ sub check ($self) {

return if $self->is_check_mode(); # skip for --check

return unless Elevate::OS::needs_leapp();

return unless $self->should_run_distro_upgrade; # skip when --upgrade-distro-manually is provided

return if ( $self->components->num_blockers_found() > 0 ); # skip if any blockers have already been found
Expand Down
Loading
Loading