Skip to content

Commit

Permalink
Merge pull request #353 from timmullin/Issue-338
Browse files Browse the repository at this point in the history
Improve warning before starting the upgrade process
  • Loading branch information
toddr authored Jan 18, 2024
2 parents 45854e6 + dc67afa commit 562a6fd
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 10 deletions.
3 changes: 3 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2024-??-?? - version 20
- #338 - Improve warning and add prompt before starting the upgrade process

2024-01-16 - version 19
- #337 - Add blocker if cPanel is not running version 110
- #341 - Use canonical_dump() when building JSON for repo blocker reports
Expand Down
37 changes: 32 additions & 5 deletions elevate-cpanel
Original file line number Diff line number Diff line change
Expand Up @@ -4593,6 +4593,7 @@ EOS
update version
upgrade-to=s
no-leapp
non-interactive
);
}

Expand Down Expand Up @@ -4714,6 +4715,7 @@ Helps to upgrade CentOS 7 cPanel servers to AlmaLinux 8 or Rocky Linux 8.
--clean Cleanup scripts and files created by elevate-cpanel
--upgrade-to=[rocky|almalinux] Update to AlmaLinux 8 or Rocky Linux 8
[default to 'almalinux']
--non-interactive Skip the yes/no prompt before proceeding with the upgrade.
--update Instruct the script to replace itself on disk with a downloaded copy of the latest version.
--version Print the version number and exit.
Expand Down Expand Up @@ -4743,6 +4745,14 @@ You can start an elevation update by running:
# Rocky Linux 8 update
/scripts/elevate-cpanel --start --upgrade-to=rocky
=item Start an installation and skip the confirmation prompt
By default, you will be asked if you wish to proceed with the upgrade.
If you wish to skip this prompt (by assuming yes):
# Perform the update in non-interactive mode
/scripts/elevate-cpanel --start --non-interactive
=item Compatibility check with elevation
You can check if your server is compatible with the upgrade process without
Expand Down Expand Up @@ -4831,6 +4841,9 @@ is not a risk free update.
Depending on the state of your current distribution multiple errors can occur.
We recommend updating your system to the last upstream state before starting.
It is *highly* recommended that you have a full backup or snapshot
of your server before beginning the elevation process.
The elevation process can take several long minutes and requires multiple reboots.
Some reboots are expected to be longer than normal.
Expand Down Expand Up @@ -4876,6 +4889,7 @@ use File::Slurper ();
use File::Spec ();
use File::Temp ();
use Hash::Merge ();
use IO::Prompt ();
use Term::ANSIColor ();

use Cpanel::AccessIds::SetUids ();
Expand Down Expand Up @@ -5271,13 +5285,26 @@ EOS
Elevate::Notify::warn_skip_version_check() if $self->getopt('skip-cpanel-version-check'); # give one last reminder

say <<EOS;
This is your chance now to cancel the update process.
You can hit CTRL-C to abort, otherwise the install starts in a few seconds.
It is *highly* recommended that you have a full backup or snapshot
of your server before proceeding.
EOS

do { sleep 1; print '.' }
for 1 .. 6;
print "\n";
if ( !$self->getopt('non-interactive') ) {
if (
!IO::Prompt::prompt(
'-one_char',
'-yes_no',
'-tty',
-default => 'n',
"Do you wish to proceed with the upgrade process [y/N]: ",
)
) {
INFO("The update process has been canceled");
exit 0;
}
}

INFO("The update process has begun");

return;
}
Expand Down
1 change: 1 addition & 0 deletions lib/Elevate/Usage.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ sub _OPTIONS {
update version
upgrade-to=s
no-leapp
non-interactive
);
}

Expand Down
34 changes: 29 additions & 5 deletions script/elevate-cpanel.PL
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Helps to upgrade CentOS 7 cPanel servers to AlmaLinux 8 or Rocky Linux 8.
--clean Cleanup scripts and files created by elevate-cpanel
--upgrade-to=[rocky|almalinux] Update to AlmaLinux 8 or Rocky Linux 8
[default to 'almalinux']
--non-interactive Skip the yes/no prompt before proceeding with the upgrade.
--update Instruct the script to replace itself on disk with a downloaded copy of the latest version.
--version Print the version number and exit.
Expand Down Expand Up @@ -79,6 +80,14 @@ You can start an elevation update by running:
# Rocky Linux 8 update
/scripts/elevate-cpanel --start --upgrade-to=rocky
=item Start an installation and skip the confirmation prompt
By default, you will be asked if you wish to proceed with the upgrade.
If you wish to skip this prompt (by assuming yes):
# Perform the update in non-interactive mode
/scripts/elevate-cpanel --start --non-interactive
=item Compatibility check with elevation
You can check if your server is compatible with the upgrade process without
Expand Down Expand Up @@ -167,6 +176,9 @@ is not a risk free update.
Depending on the state of your current distribution multiple errors can occur.
We recommend updating your system to the last upstream state before starting.
It is *highly* recommended that you have a full backup or snapshot
of your server before beginning the elevation process.
The elevation process can take several long minutes and requires multiple reboots.
Some reboots are expected to be longer than normal.
Expand Down Expand Up @@ -212,6 +224,7 @@ use File::Slurper ();
use File::Spec ();
use File::Temp ();
use Hash::Merge ();
use IO::Prompt ();
use Term::ANSIColor ();

use Cpanel::AccessIds::SetUids ();
Expand Down Expand Up @@ -607,13 +620,24 @@ EOS
Elevate::Notify::warn_skip_version_check() if $self->getopt('skip-cpanel-version-check'); # give one last reminder

say <<EOS;
This is your chance now to cancel the update process.
You can hit CTRL-C to abort, otherwise the install starts in a few seconds.
It is *highly* recommended that you have a full backup or snapshot
of your server before proceeding.
EOS

do { sleep 1; print '.' }
for 1 .. 6;
print "\n";
if ( !$self->getopt('non-interactive') ) {
if ( !IO::Prompt::prompt(
'-one_char',
'-yes_no',
'-tty',
-default => 'n',
"Do you wish to proceed with the upgrade process [y/N]: ",
) ) {
INFO("The update process has been canceled");
exit 0;
}
}

INFO("The update process has begun");

return;
}
Expand Down
1 change: 1 addition & 0 deletions t/cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ requires "Params::Util";
requires "Simple::Accessor";
requires "Sub::Identify";
requires "Net::CIDR";
requires "IO::Prompt";

# test
on 'test' => sub {
Expand Down

0 comments on commit 562a6fd

Please sign in to comment.