diff --git a/Web/lib/MJB/Web/Controller/Blog.pm b/Web/lib/MJB/Web/Controller/Blog.pm index 20d27bd..593bb54 100644 --- a/Web/lib/MJB/Web/Controller/Blog.pm +++ b/Web/lib/MJB/Web/Controller/Blog.pm @@ -44,7 +44,7 @@ sub do_domain_hosted ( $c ) { return; } - return $c->_initialize_blog( $sub_domain . '.' . $top_domain->name, 'show_blog_domain_hosted' ); + return $c->_initialize_blog( $sub_domain . '.' . $top_domain->name, 'show_blog_domain_hosted', $top_domain->name ); } # Initial blog creation entry point when the user @@ -78,7 +78,7 @@ sub do_domain_owned ( $c ) { # forwarded from the domain_hosted / domain_owned requests, and redirecting to # a post doesn't work. However, since we're doing things rather than displaying # things, it'll be named with the do_ -sub _initialize_blog ( $c, $domain, $from ) { +sub _initialize_blog ( $c, $domain, $from, $ssl_domain ) { # Do we already have this domain name? if ( $c->db->domain( { name => $domain } ) ) { @@ -97,6 +97,7 @@ sub _initialize_blog ( $c, $domain, $from ) { # Make the domain name record. my $domain_record = $c->stash->{person}->create_related('domains', { name => $domain, + ( $ssl_domain ? ( ssl => $ssl_domain ) : () ), }); # Make the website record @@ -121,12 +122,14 @@ sub _initialize_blog ( $c, $domain, $from ) { } # Schedule a job to deploy the website - my $ssl_job_id = $c->minion->enqueue( 'create_ssl_cert', [ $blog->id ], { - notes => { '_bid_' . $blog->id => 1 }, - priority => $blog->build_priority, - queue => 'certbot', - }); - $blog->create_related( 'builds', { job_id => $ssl_job_id } ); + if ( ! $ssl_domain ) { + my $ssl_job_id = $c->minion->enqueue( 'create_ssl_cert', [ $blog->id ], { + notes => { '_bid_' . $blog->id => 1 }, + priority => $blog->build_priority, + queue => 'certbot', + }); + $blog->create_related( 'builds', { job_id => $ssl_job_id } ); + } $c->redirect_to( $c->url_for( 'show_blog_settings', { id => $blog->id } ) ); } diff --git a/Web/lib/MJB/Web/Task/InitializeBlog.pm b/Web/lib/MJB/Web/Task/InitializeBlog.pm index 89ead0a..be3ebe9 100644 --- a/Web/lib/MJB/Web/Task/InitializeBlog.pm +++ b/Web/lib/MJB/Web/Task/InitializeBlog.pm @@ -18,7 +18,7 @@ sub run ( $job, $blog_id ) { my $config_content = MJB::Backend::Nginx::DomainConfig->new( domain => $blog->domain->name, - ssl_domain => $blog->domain->name, + ssl_domain => ( $blog->domain->ssl ? $blog->domain->ssl : $blog->domain->name ), )->config; my ( $config, $welcome ) = ( tempfile, tempfile );