File manager - Edit - /usr/local/cpanel/install/MigratePalToNova.pm
Back
package Install::MigratePalToNova; # cpanel - install/MigratePalToNova.pm # Copyright 2026 WebPros International, LLC # All rights reserved. # copyright@cpanel.net http://cpanel.net # This code is subject to the cPanel license. Unauthorized copying is prohibited use cPstrict; use parent qw( Cpanel::Task ); use Cpanel::Debug (); our $VERSION = '1.0'; our $PAL_PACKAGE = 'cpanel-pal-plugin'; our $NOVA_PACKAGE = 'cpanel-nova-plugin'; =head1 NAME Install::MigratePalToNova - Queue installation of cpanel-nova-plugin for servers with cpanel-pal-plugin =head1 DESCRIPTION This task handles the migration from cpanel-pal-plugin to cpanel-nova-plugin for servers that have automatic package updates disabled. For servers with automatic updates enabled, the package manager installs cpanel-nova-plugin (which obsoletes cpanel-pal-plugin), and Nova's lifecycle handles the migration tasks. This task performs the following: =over 4 =item * Detects if cpanel-pal-plugin is installed =item * Verifies cpanel-nova-plugin is available in repositories =item * Queues Nova plugin installation via C<Cpanel::ServerTasks> =back The actual feature list migration, marker file handling, and metadata cleanup are performed by the Nova plugin's lifecycle script (C<migrate_pal_to_nova_featurelists>) which runs automatically during Nova installation. User data migration (PAL_API_TOKEN to NOVA_API_TOKEN) is handled separately by the Nova plugin when users access the application. =over 1 =item Type: Software Install =item Frequency: once =item EOL: never =back =cut exit __PACKAGE__->runtask() unless caller; sub new ($proto) { my $self = $proto->SUPER::new; require Cpanel::Version; my $cpanel_version = Cpanel::Version::get_short_release_number(); $self->{flag} = "${cpanel_version}_migrate_pal_to_nova"; $self->set_internal_name( $self->{flag} ); return $self; } sub perform ($self) { my $status = 1; $self->do_once( version => $self->{flag}, eol => 'never', code => sub { $status = $self->_migrate_plugin(); } ) if $self->_should_migrate(); return $status; } sub _should_migrate ($self) { # On sandboxes we may not have the rpm, just install. if ( -e '/var/cpanel/dev_sandbox' ) { Cpanel::Debug::log_info("Running on a sandbox. Skipping migration check."); return 0; } require Cpanel::Pkgr; my $pal_installed = Cpanel::Pkgr::is_installed($PAL_PACKAGE); if ( !$pal_installed ) { Cpanel::Debug::log_info("PAL plugin ($PAL_PACKAGE) not installed. No migration needed."); return 0; } Cpanel::Debug::log_info("PAL plugin ($PAL_PACKAGE) is installed. Proceeding with migration check."); # Check if Nova package is available before proceeding if ( !$self->_is_nova_package_available() ) { Cpanel::Debug::log_warn("Nova plugin ($NOVA_PACKAGE) is not available in repositories. Skipping migration."); return 0; # we skip migration if nova package is not available } return 1; } sub _migrate_plugin ($self) { Cpanel::Debug::log_info("Starting migration from PAL plugin to Nova plugin."); # Installing cpanel-nova-plugin will uninstall cpanel-pal-plugin if ( !$self->_install_nova_plugin() ) { Cpanel::Debug::log_warn("Failed to install Nova plugin ($NOVA_PACKAGE). Migration will be retried; PAL plugin remains installed."); return 0; # Return failure so we can retry } Cpanel::Debug::log_info("Successfully installed Nova plugin ($NOVA_PACKAGE)."); Cpanel::Debug::log_info("Migration from PAL plugin to Nova plugin completed successfully."); return 1; } sub _is_nova_package_available ($self) { require Cpanel::OS; my $available; if ( Cpanel::OS::package_manager() eq 'apt' ) { # On APT systems, use apt-cache policy to check package availability # what_provides in apt uses apt-file which doesn't work, so we use apt-cache policy instead require Cpanel::Binaries::Debian::AptCache; my $apt_cache = Cpanel::Binaries::Debian::AptCache->new(); my $result = $apt_cache->cmd( 'policy', $NOVA_PACKAGE ); # Package is available if apt-cache policy returns success and Candidate is not "(none)" # Ex: cpanel-nova-plugin: # Installed: (none) # Candidate: 1.6.0-3+9.1.cpanel $available = ( $result->{status} == 0 && ( $result->{output} // '' ) =~ /Candidate:\s+(?!\(none\))\S+/ ) ? 1 : 0; } else { # On YUM/DNF systems, use repoquery to check package availability require Cpanel::RepoQuery; my $packages = Cpanel::RepoQuery::what_provides($NOVA_PACKAGE); $available = $packages && @{$packages} ? 1 : 0; } if ($available) { Cpanel::Debug::log_info("Nova plugin ($NOVA_PACKAGE) is available in repositories."); } else { Cpanel::Debug::log_info("Nova plugin ($NOVA_PACKAGE) is not available in repositories."); } return $available; } sub _install_nova_plugin ($self) { require Cpanel::ServerTasks; Cpanel::Debug::log_info("Queueing installation task for Nova plugin ($NOVA_PACKAGE)."); my $result = Cpanel::ServerTasks::queue_task( ['PluginTasks'], "install_plugin $NOVA_PACKAGE" ); if ( !$result ) { Cpanel::Debug::log_warn("Failed to queue installation task for Nova plugin ($NOVA_PACKAGE)."); return 0; } return 1; } 1;
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings