File manager - Edit - /usr/local/cpanel/install/MariaDBUbuntu.pm
Back
package Install::MariaDBUbuntu; # cpanel - install/MariaDBUbuntu.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 base qw( Cpanel::Task ); use Cpanel::OS (); our $VERSION = '1.0'; =encoding utf8 =head1 NAME Install::MariaDBUbuntu - Repoint existing MariaDB APT repositories at the stable mirror. =head1 SYNOPSIS use Install::MariaDBUbuntu (); Install::MariaDBUbuntu->new->perform; =head1 DESCRIPTION The MariaDB C<dlm.mariadb.com> download mirror became non-responsive and now returns C<404> for the repository paths cPanel previously configured, which produces warnings on every C<upcp> run on Ubuntu servers. This task runs once and rewrites any existing APT source list that still points at C<dlm.mariadb.com> so that it uses the stable C<archive.mariadb.org> mirror instead. New installations already receive the corrected URL from L<Cpanel::OS/mariadb_repo_template>; this task fixes servers that were configured before that change. =over 1 =item Type: Sanity =item Frequency: once =item EOL: 11.144 =back =cut use constant APT_SOURCES_DIR => q[/etc/apt/sources.list.d]; # Persistent do_once flag so the existing repositories are repaired a single time. use constant DO_ONCE_FLAG => q[mariadb_ubuntu_dlm_to_archive]; exit __PACKAGE__->runtask() unless caller; sub new ($proto) { my $self = $proto->SUPER::new; $self->set_internal_name('mariadbubuntu'); return $self; } =head2 perform() Repairs the existing MariaDB APT repositories a single time on apt-based systems. Returns true. =cut sub perform ($self) { # Fresh installs get the corrected template directly, so there is nothing to repair. return 1 if $ENV{'CPANEL_BASE_INSTALL'}; return 1 unless Cpanel::OS::is_apt_based(); $self->do_once( version => DO_ONCE_FLAG, eol => '11.144', code => sub { $self->_repoint_existing_repos() }, ); return 1; } =head2 _repoint_existing_repos() Scans the APT sources directory for repository files that reference the non-responsive C<dlm.mariadb.com> mirror and rewrites them in place to use C<archive.mariadb.org>. Returns true. =cut sub _repoint_existing_repos ($self) { my $dir = APT_SOURCES_DIR; return 1 unless -d $dir; opendir( my $dh, $dir ) or do { warn "Unable to read “$dir”: $!\n"; return 1; }; my @list_files = sort grep { m/[.]list\z/ } readdir $dh; closedir $dh; foreach my $file (@list_files) { $self->_repair_list_file("$dir/$file"); } return 1; } =head2 _repair_list_file($path) Rewrites a single APT source list in place when it references the non-responsive C<dlm.mariadb.com> mirror. Returns true when the file was rewritten and false when it was left untouched. =cut sub _repair_list_file ( $self, $path ) { return 0 unless -f $path; require Cpanel::LoadFile; my $content = eval { Cpanel::LoadFile::load($path) }; return 0 unless defined $content; my $new_content = $self->_rewrite_repo_content($content); return 0 unless defined $new_content; print "Updating MariaDB APT repository “$path” to use the stable archive.mariadb.org mirror.\n"; require Cpanel::FileUtils::Write; eval { Cpanel::FileUtils::Write::overwrite( $path, $new_content, 0644 ); 1 } or warn "Failed to update “$path”: $@\n"; return 1; } =head2 _rewrite_repo_content($content) Given the contents of an APT source list, returns the rewritten contents if it referenced C<dlm.mariadb.com>, or C<undef> if no change was needed. The C<main/debug> component lines are dropped because C<archive.mariadb.org> has no equivalent. =cut sub _rewrite_repo_content ( $self, $content ) { my $original = $content; # Drop the non-standard "main/debug" component lines: archive.mariadb.org # has no equivalent and apt warns about the missing component. $content =~ s{ ^ [^\n]* dlm[.]mariadb[.]com [^\n]* /debug [^\n]* \n? }{}xmsg; # Repoint the non-responsive dlm mirror at the stable archive mirror, the # same host already used for RPM-based systems. $content =~ s{ https?:// dlm[.]mariadb[.]com /repo/mariadb-server/ ([0-9]+[.][0-9]+) /repo/ubuntu } {https://archive.mariadb.org/mariadb-$1/repo/ubuntu}xmsg; return if $content eq $original; return $content; } 1;
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings