Edit File: migrate_autossl_cpstore_to_sqlite
#!/usr/local/cpanel/3rdparty/bin/perl # cpanel - scripts/migrate_autossl_cpstore_to_sqlite Copyright 2017 cPanel, Inc. # All rights reserved. # copyright@cpanel.net http://cpanel.net # This code is subject to the cPanel license. Unauthorized copying is prohibited package scripts::migrate_autossl_cpstore_to_sqlite; =head1 NAME migrate_autossl_cpstore_to_sqlite =head1 USAGE migrate_autossl_cpstore_to_sqlite [--help] =head1 DESCRIPTION This script migrates a cPanel Store AutoSSL queue to the v1 SQLite schema. There is normally no need to run this script manually. =cut use strict; use warnings; use parent qw( Cpanel::HelpfulScript ); use Cpanel::Autodie::File (); use Cpanel::SSL::Auto::Provider::cPanel::Queue (); use Cpanel::Transaction::File::JSON (); our $_QUEUE_FILE = '/var/cpanel/autossl_queue_cpanel.json'; __PACKAGE__->new(@ARGV)->run() if !caller; use constant _OPTIONS => (); sub run { my ($self) = @_; if ( !-e $_QUEUE_FILE ) { $self->say('No pre-SQLite queue exists.'); return; } my $xaction = Cpanel::Transaction::File::JSON->new( path => $_QUEUE_FILE, ); my $queue_hr = $xaction->get_data(); if ( 'HASH' ne ref $queue_hr ) { $self->say("The queue file ($_QUEUE_FILE) contains no data."); return; } my $queue = Cpanel::SSL::Auto::Provider::cPanel::Queue->new(); for my $username ( keys %$queue_hr ) { for my $vh_name ( keys %{ $queue_hr->{$username} } ) { eval { $queue->add( username => $username, vhost_name => $vh_name, %{ $queue_hr->{$username}{$vh_name} }, ); }; warn if $@; } } Cpanel::Autodie::File::rename( $_QUEUE_FILE, "$_QUEUE_FILE.old" ); return; } 1;