Skip to content

Commit

Permalink
Merge pull request #372 from cPholloway/RE-18
Browse files Browse the repository at this point in the history
Add initial support for Elevating from CL7 to CL8
  • Loading branch information
toddr authored Feb 19, 2024
2 parents 3683914 + bc0e616 commit b8379ca
Show file tree
Hide file tree
Showing 35 changed files with 2,249 additions and 1,038 deletions.
1,149 changes: 823 additions & 326 deletions elevate-cpanel

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions lib/Elevate/Blockers/Databases.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Blockers for datbase: MySQL, PostgreSQL...
use cPstrict;

use Cpanel::OS ();
use Cpanel::Pkgr ();
use Cpanel::Version::Tiny ();
use Cpanel::JSON ();
use Cpanel::SafeRun::Simple ();
Expand All @@ -29,6 +30,7 @@ sub check ($self) {
$ok = 0 unless $self->_blocker_acknowledge_postgresql_datadir;
$ok = 0 unless $self->_blocker_old_mysql;
$ok = 0 unless $self->_blocker_mysql_upgrade_in_progress;
$ok = 0 unless $self->_blocker_mysql_governor;
$self->_warning_mysql_not_enabled();
return $ok;
}
Expand Down Expand Up @@ -185,6 +187,21 @@ sub _blocker_mysql_upgrade_in_progress ($self) {
return 0;
}

sub _blocker_mysql_governor ($self) {

if ( Cpanel::Pkgr::is_installed('governor-mysql') ) {
return $self->has_blocker( <<~'EOS' );
You have MySQL Governor installed. Upgrades with this software in place are not currently supported.
For more information regarding MySQL Governor, please review the documentation:
https://docs.cloudlinux.com/shared/cloudlinux_os_components/#mysql-governor
EOS
}

return 0;
}

sub _warning_mysql_not_enabled ($self) {
require Cpanel::Services::Enabled;
my $enabled = Cpanel::Services::Enabled::is_enabled('mysql');
Expand Down
20 changes: 7 additions & 13 deletions lib/Elevate/Blockers/Distros.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ use constant MINIMUM_CENTOS_7_SUPPORTED => 9;

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

use Elevate::OS ();

use Log::Log4perl qw(:easy);

sub check ($self) {

my @checks = qw{
_blocker_is_non_centos7
_blocker_os_is_not_supported
_blocker_is_old_centos7
_blocker_is_experimental_os
};
Expand All @@ -36,16 +38,13 @@ sub check ($self) {
return 0;
}

sub _blocker_is_non_centos7 ($self) {
unless ( Cpanel::OS::major() == 7 && Cpanel::OS::distro() eq 'centos' ) {
my $pretty_distro_name = $self->upgrade_to_pretty_name();
return $self->has_blocker(qq[This script is only designed to upgrade CentOS 7 to $pretty_distro_name.]);
}

sub _blocker_os_is_not_supported ($self) {
Elevate::OS::is_supported(); # dies
return 0;
}

sub _blocker_is_old_centos7 ($self) {

if ( Cpanel::OS::minor() < MINIMUM_CENTOS_7_SUPPORTED ) {
my $pretty_distro_name = $self->upgrade_to_pretty_name();
return $self->has_blocker(
Expand All @@ -69,12 +68,7 @@ sub _blocker_is_experimental_os ($self) {

# We are OK if can_be_elevated or if
sub bail_out_on_inappropriate_distro () {

if ( !( eval { Cpanel::OS::can_be_elevated() } // ( Cpanel::OS::distro() eq 'centos' && Cpanel::OS::major() == 7 ) ) ) {
FATAL(qq[This script is designed to only run on CentOS 7 servers.\n]);
exit 1;
}

Elevate::OS::is_supported(); # dies
return;
}

Expand Down
4 changes: 4 additions & 0 deletions lib/Elevate/Blockers/Python.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ use cPstrict;

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

use Elevate::OS ();

use Cpanel::Pkgr ();

sub check ($self) {
return if Elevate::OS::leapp_can_handle_python36();

my $pkg = Cpanel::Pkgr::what_provides('python36');
return unless $pkg && Cpanel::Pkgr::is_installed($pkg);
return $self->has_blocker( <<~"END" );
Expand Down
93 changes: 3 additions & 90 deletions lib/Elevate/Blockers/Repositories.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,99 +16,12 @@ use Cpanel::OS ();
use Cpanel::JSON ();

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

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

use Log::Log4perl qw(:easy);

# still used by disable_known_yum_repositories function
use constant DISABLE_MYSQL_YUM_REPOS => qw{
Mysql57.repo
Mysql80.repo
MariaDB102.repo
MariaDB103.repo
MariaDB105.repo
MariaDB106.repo
mysql-community.repo
};

# FIXME use some RegExp...
use constant VETTED_MYSQL_YUM_REPO_IDS => qw{
mysql-cluster-7.5-community
mysql-cluster-7.5-community-source
mysql-cluster-7.5-community-source
mysql-cluster-7.6-community
mysql-cluster-7.6-community-source
mysql-cluster-7.6-community-source
mysql-cluster-8.0-community
mysql-cluster-8.0-community-debuginfo
mysql-cluster-8.0-community-source
mysql-connectors-community
mysql-connectors-community-debuginfo
mysql-connectors-community-source
mysql-connectors-community-source
mysql-tools-community
mysql-tools-community-debuginfo
mysql-tools-community-source
mysql-tools-preview
mysql-tools-preview-source
mysql55-community
mysql55-community-source
mysql56-community
mysql56-community-source
mysql57-community
mysql57-community-source
mysql80-community
mysql80-community-debuginfo
mysql80-community-source
MariaDB102
MariaDB103
MariaDB105
MariaDB106
};

use constant VETTED_YUM_REPO => qw{
base
c7-media
centos-kernel
centos-kernel-experimental
centosplus
cp-dev-tools
cpanel-addons-production-feed
cpanel-plugins
cr
ct-preset
digitalocean-agent
droplet-agent
EA4
EA4-c$releasever
elasticsearch
elasticsearch-7.x
elevate
elevate-source
epel
epel-testing
extras
fasttrack
imunify360
imunify360-ea-php-hardened
imunify360-rollout-1
imunify360-rollout-2
imunify360-rollout-3
imunify360-rollout-4
imunify360-rollout-5
imunify360-rollout-6
imunify360-rollout-7
imunify360-rollout-8
influxdb
kernelcare
updates
wp-toolkit-cpanel
wp-toolkit-thirdparties
}, VETTED_MYSQL_YUM_REPO_IDS;

sub check ($self) {
my $ok = 1;
$ok = 0 unless $self->_blocker_system_update;
Expand Down Expand Up @@ -217,7 +130,7 @@ sub _check_yum_repos ($self) {
$self->{_yum_repos_to_disable} = [];
$self->{_yum_repos_unsupported_with_packages} = [];

my %vetted = map { $_ => 1 } VETTED_YUM_REPO;
my @vetted_repos = Elevate::OS::vetted_yum_repo();

my $repo_dir = Elevate::Constants::YUM_REPOS_D;

Expand All @@ -244,7 +157,7 @@ sub _check_yum_repos ($self) {
return unless length $current_repo_name;
return unless $current_repo_enabled;

my $is_vetted = $vetted{$current_repo_name} || $vetted{ lc $current_repo_name };
my $is_vetted = grep { $current_repo_name =~ m/$_/ } @vetted_repos;

if ( !$is_vetted ) {
$status{'UNVETTED'} = 1;
Expand Down
10 changes: 10 additions & 0 deletions lib/Elevate/Components/Base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use Carp ();
use Simple::Accessor qw(
cpev
rpm
yum
dnf
);

use Log::Log4perl qw(:easy);
Expand Down Expand Up @@ -52,6 +54,14 @@ sub _build_rpm ($self) {
return Elevate::RPM->new( cpev => $self );
}

sub _build_yum ($self) {
return Elevate::YUM->new( cpev => $self );
}

sub _build_dnf ($self) {
return Elevate::DNF->new( cpev => $self );
}

sub run_once ( $self, $subname ) {

my $cpev = $self->cpev;
Expand Down
7 changes: 4 additions & 3 deletions lib/Elevate/Components/EA4.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ Perform am EA4 backup pre-elevate then restore it after the elevation process.
use cPstrict;

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

use Cwd ();
use Log::Log4perl qw(:easy);
Expand Down Expand Up @@ -73,7 +75,7 @@ sub post_leapp ($self) {
sub _cleanup_rpm_db ($self) {

# remove all ea- packages
$self->ssystem(q{/usr/bin/yum -y erase ea-*});
$self->yum->remove('ea-*');

return;
}
Expand Down Expand Up @@ -134,8 +136,7 @@ sub _backup_ea4_profile ($self) { ## _backup_ea4_profile

sub _get_ea4_profile ($self) {

# obs_project_aliases from /etc/cpanel/ea4/ea4-metainfo.json
my $ea_alias = $self->upgrade_to_rocky() ? 'CentOS_8' : 'AlmaLinux_8';
my $ea_alias = Elevate::OS::ea_alias();

my @cmd = ( '/usr/local/bin/ea_current_to_profile', "--target-os=$ea_alias" );

Expand Down
4 changes: 0 additions & 4 deletions lib/Elevate/Components/Grub2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ use Elevate::Blockers ();
use constant GRUB_EDITENV => '/usr/bin/grub2-editenv';
use constant GRUB_ENV_FILE => '/boot/grub2/grubenv';

##
## Call early so we can use a blocker based on existing ea4 profile
##

sub pre_leapp ($self) {

$self->run_once('_update_grub2_workaround_if_needed'); # required part
Expand Down
5 changes: 5 additions & 0 deletions lib/Elevate/Components/Imunify.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use cPstrict;
use Elevate::Constants ();
use Elevate::Fetch ();
use Elevate::Notify ();
use Elevate::OS ();

use Cwd ();
use Log::Log4perl qw(:easy);
Expand All @@ -33,6 +34,8 @@ use constant IMUNIFY_LICENSE_BACKUP => Elevate::Constants::ELEVATE_BACKUP_DIR .

sub pre_leapp ($self) {

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

return unless $self->is_installed;

$self->run_once("_capture_imunify_features");
Expand All @@ -44,6 +47,8 @@ sub pre_leapp ($self) {

sub post_leapp ($self) {

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

# order matters
$self->run_once('_reinstall_imunify_360');
$self->run_once('_restore_imunify_features');
Expand Down
5 changes: 5 additions & 0 deletions lib/Elevate/Components/KernelCare.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Capture and reinstall KernelCare.
use cPstrict;

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

use Cwd ();
use File::Copy ();
Expand All @@ -23,13 +24,17 @@ use parent qw{Elevate::Components::Base};

sub pre_leapp ($self) {

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

$self->run_once("_remove_kernelcare_if_needed");

return;
}

sub post_leapp ($self) {

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

$self->run_once('_restore_kernelcare');

return;
Expand Down
31 changes: 27 additions & 4 deletions lib/Elevate/Components/Repositories.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ Disable some repostiories.

use cPstrict;

use Elevate::Constants ();
use Elevate::Blockers::Repositories ();
use Elevate::Constants ();
use Elevate::OS ();
use Elevate::RPM ();

use Cpanel::SafeRun::Simple ();
use Cwd ();
Expand All @@ -24,6 +25,8 @@ use parent qw{Elevate::Components::Base};

sub pre_leapp ($self) {

$self->run_once("_disable_epel");
$self->run_once("_disable_yum_plugin_fastestmirror");
$self->run_once("_disable_known_yum_repositories");

return;
Expand All @@ -32,8 +35,7 @@ sub pre_leapp ($self) {
sub _disable_known_yum_repositories {

# remove all MySQL repos
my @repo_files = map { Elevate::Constants::YUM_REPOS_D . '/' . $_ } #
Elevate::Blockers::Repositories::DISABLE_MYSQL_YUM_REPOS;
my @repo_files = map { Elevate::Constants::YUM_REPOS_D . '/' . $_ } Elevate::OS::disable_mysql_yum_repos();

foreach my $f (@repo_files) {
next unless -e $f;
Expand All @@ -50,4 +52,25 @@ sub _disable_known_yum_repositories {
return;
}

sub _disable_yum_plugin_fastestmirror ($self) {
my $pkg = 'yum-plugin-fastestmirror';
$self->_erase_package($pkg);
return;
}

sub _disable_epel ($self) {

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

my $pkg = 'epel-release';
$self->_erase_package($pkg);
return;
}

sub _erase_package ( $self, $pkg ) {
return unless Cpanel::Pkgr::is_installed($pkg);
$self->rpm->remove_no_dependencies($pkg);
return;
}

1;
Loading

0 comments on commit b8379ca

Please sign in to comment.