Hi Laurent,
here is the content of the script
Perl
- #!/usr/bin/perl
- # i-MSCP LetsEncrypt plugin
- #
- # @author Laurent Deckercq <l.declercq@nuxwin.com>
- # @copyright (C) 2016-2017 Laurent Declercq <l.declercq@nuxwin.com>
- # @license i-MSCP License <http://www.i-mscp.net/license-agreement.html>
- use strict;
- use warnings;
- use FindBin;
- use lib "$FindBin::Bin/../../../../engine/PerlLib", "$FindBin::Bin/../../../../engine/PerlVendor";
- use Class::Autouse qw/ :nostat iMSCP::Database iMSCP::DbTasksProcessor iMSCP::Service /;
- use File::Basename;
- use iMSCP::Bootstrapper;
- use iMSCP::Debug;
- use iMSCP::Getopt;
- use JSON;
- sub getConfig
- {
- my $db = shift;
- my $dbi = $db->getRawDb( );
- my $config = $dbi->selectrow_hashref( "SELECT plugin_config FROM plugin WHERE plugin_name = 'LetsEncrypt'" );
- !$dbi->errstr or die( $dbi->errstr );
- $config or die( "Couldn't find LetsEncrypt plugin configuration in database" );
- JSON->new( )->decode( $config->{'plugin_config'} );
- }
- my $bootstrapper = iMSCP::Bootstrapper->getInstance( );
- exit unless $bootstrapper->lock( '/var/lock/imscp-letsencrypt-renew.lock', 'nowait' );
- eval {
- newDebug( 'letsencrypt-plugin-renew.pl.log' );
- iMSCP::Getopt->parseNoDefault( sprintf( 'Usage: perl %s [OPTION]...', basename( $0 ) ).qq {
- Process renewal tasks.
- OPTIONS:
- -d, --debug Enable debug mode.
- -v, --verbose Enable verbose mode.},
- 'debug|d' => \&iMSCP::Getopt::debug,
- 'verbose|v' => \&iMSCP::Getopt::verbose
- );
- setVerbose( iMSCP::Getopt->verbose );
- iMSCP::Bootstrapper->getInstance( )->boot(
- {
- config_readonly => 'yes',
- norequirements => 'yes'
- }
- );
- iMSCP::Service->getInstance( )->isRunning( 'mysql' ) or exit;
- my $db = iMSCP::Database->factory( );
- my $qrs = $db->doQuery(
- 'u', "UPDATE letsencrypt SET letsencrypt_status = ? WHERE letsencrypt_status = ? AND letsencrypt_expires <= ?",
- 'torenew',
- 'ok',
- ( time( )+getConfig($db)->{'renew_before_expiry'} )
- );
- ref $qrs eq 'HASH' or die( $qrs );
- iMSCP::DbTasksProcessor->getInstance( mode => 'backend' )->process( );
- };
- if ($@) {
- error("Couldn't process Let's Encrypt renewal tasks: %s", $@);
- exit 1;
- }
- END { $bootstrapper->unlock( '/var/lock/imscp-letsencrypt-renew.lock' ); }
- 1;
- __END__;
THe version ist 3.5.0