diff --git a/Web/lib/MJB/Web.pm b/Web/lib/MJB/Web.pm index f83721d..28c2b8f 100644 --- a/Web/lib/MJB/Web.pm +++ b/Web/lib/MJB/Web.pm @@ -24,9 +24,10 @@ sub startup ($self) { # Minion Plugin & Tasks $self->plugin( Minion => { Pg => $self->config->{database}->{minion} } ); - $self->minion->add_task( create_blog => 'MJB::Web::Task::CreateBlog' ); - $self->minion->add_task( purge_blog => 'MJB::Web::Task::PurgeBlog' ); - $self->minion->add_task( deploy_blog => 'MJB::Web::Task::DeployBlog' ); + $self->minion->add_task( create_blog => 'MJB::Web::Task::CreateBlog' ); + $self->minion->add_task( purge_blog => 'MJB::Web::Task::PurgeBlog' ); + $self->minion->add_task( deploy_blog => 'MJB::Web::Task::DeployBlog' ); + $self->minion->add_task( create_ssl_cert => 'MJB::Web::Task::CreateSSLCert' ); # Standard router. my $r = $self->routes->under( '/' => sub ($c) { diff --git a/Web/lib/MJB/Web/Task/CreateSSLCert.pm b/Web/lib/MJB/Web/Task/CreateSSLCert.pm new file mode 100644 index 0000000..c0b41d9 --- /dev/null +++ b/Web/lib/MJB/Web/Task/CreateSSLCert.pm @@ -0,0 +1,18 @@ +package MJB::Web::Task::CreateSSLCert; +use Mojo::Base 'MJB::Web::Task', -signatures; +use IPC::Run3; + +sub run ( $job, $blog_id ) { + $job->note( _mds_template => 'build_static' ); + + my $blog = $job->app->db->blog( $blog_id ); + + # Get the SSL Certificate + my $result = $job->system_command( [ + qw(sudo certbot certonly --standalone -d), $blog->domain->name, qw(--agree-tos --register-unsafely-without-email) + ]); + + $job->finish(); +} + +1;