A hosting service for Jekyll Blogs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

42 lines
1.2 KiB

package MJB::Backend::Nginx;
use Moo;
use MJB::Backend::Nginx::DomainConfig;
use Mojo::File qw( tempfile );
with 'MJB::Backend::Role::SystemCommand';
has servers => (
is => 'ro',
default => sub { [ ] },
);
sub provision_website {
my ( $self, $domain, $ssl_domain ) = @_;
$ssl_domain ||= $domain;
my $config = MJB::Backend::Nginx::DomainConfig->new(
domain => $domain,
ssl_domain => $ssl_domain,
)->config;
my $config_file = tempfile;
$config_file->spurt( $config );
my $welcome_file = tempfile;
$welcome_file->spurt( "Your new blog is being setup... please reload soon." );
foreach my $server ( @{$self->servers} ) {
$self->system_command( [ 'scp', $config_file->to_string, $server . ":/etc/nginx/sites-enabled/" . $domain ] );
$self->system_command( [ 'ssh', $server, 'mkdir -p /var/www/' . $domain . '/html' ] );
$self->system_command( [ 'scp', $welcome_file->to_string, $server . "/var/www/" . $domain . "/html/index.html" ] );
$self->system_command( [ 'ssh', $server, 'chown -R www-data:www-data /var/www/' . $domain ] );
}
}
sub deprovision_website {
}
1;