From 2bf90eb9e4e9d467d3c56837202592c44f3bd2c8 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Wed, 17 Oct 2018 12:34:04 +0530 Subject: [PATCH 1/2] Update enable and wrapper for ssl Signed-off-by: Riddhesh Sanghvi --- src/helper/class-ee-site.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/helper/class-ee-site.php b/src/helper/class-ee-site.php index fc52b785..67a80bff 100644 --- a/src/helper/class-ee-site.php +++ b/src/helper/class-ee-site.php @@ -300,7 +300,8 @@ public function enable( $args, $assoc_args ) { } $success = false; - if ( \EE::docker()::docker_compose_up( $this->site_data->site_fs_path, ['nginx'] ) ) { + + if ( \EE::docker()::docker_compose_up( $this->site_data->site_fs_path, $containers_to_start ) ) { $this->site_data->site_enabled = 1; $this->site_data->save(); $success = true; @@ -308,14 +309,13 @@ public function enable( $args, $assoc_args ) { $site_data_array = (array) $this->site_data; $this->site_data = reset( $site_data_array ); - $this->www_ssl_wrapper(); - + $this->www_ssl_wrapper( $containers_to_start, true ); if ( true === (bool) $this->site_data['admin_tools'] ) { EE::runcommand( 'admin-tools enable ' . $this->site_data['site_url'] . ' --force' ); } - if( true === (bool) $this->site_data['mailhog_enabled'] ) { + if ( true === (bool) $this->site_data['mailhog_enabled'] ) { EE::runcommand( 'mailhog enable ' . $this->site_data['site_url'] ); } @@ -471,7 +471,7 @@ private function reload_services( $services, $reload_commands ) { * @throws EE\ExitException * @throws \Exception */ - protected function www_ssl_wrapper( $containers_to_start = [] ) { + protected function www_ssl_wrapper( $containers_to_start = [], $site_enable = false ) { /** * This adds http www redirection which is needed for issuing cert for a site. * i.e. when you create example.com site, certs are issued for example.com and www.example.com @@ -497,14 +497,16 @@ protected function www_ssl_wrapper( $containers_to_start = [] ) { } if ( $this->site_data['site_ssl'] ) { - $this->init_ssl( $this->site_data['site_url'], $this->site_data['site_fs_path'], $this->site_data['site_ssl'], $this->site_data['site_ssl_wildcard'] ); + if ( ! $site_enable ) { + $this->init_ssl( $this->site_data['site_url'], $this->site_data['site_fs_path'], $this->site_data['site_ssl'], $this->site_data['site_ssl_wildcard'] ); - if ( $is_www_or_non_www_pointed ) { - \EE\Site\Utils\add_site_redirects( $this->site_data['site_url'], true, 'inherit' === $this->site_data['site_ssl'], $is_www_or_non_www_pointed ); + $this->dump_docker_compose_yml( [ 'nohttps' => false ] ); + \EE\Site\Utils\start_site_containers( $this->site_data['site_fs_path'], $containers_to_start ); } - $this->dump_docker_compose_yml( [ 'nohttps' => false ] ); - \EE\Site\Utils\start_site_containers( $this->site_data['site_fs_path'], $containers_to_start ); + if ( $is_www_or_non_www_pointed ) { + \EE\Site\Utils\add_site_redirects( $this->site_data['site_url'], true, 'inherit' === $this->site_data['site_ssl'] ); + } \EE\Site\Utils\reload_global_nginx_proxy(); } From 581a389dcc90b2fa580965fc69165991385562b1 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Wed, 17 Oct 2018 12:34:53 +0530 Subject: [PATCH 2/2] Update configuration for postfix Signed-off-by: Riddhesh Sanghvi --- src/helper/class-ee-site.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/helper/class-ee-site.php b/src/helper/class-ee-site.php index 67a80bff..ac63da18 100644 --- a/src/helper/class-ee-site.php +++ b/src/helper/class-ee-site.php @@ -301,6 +301,9 @@ public function enable( $args, $assoc_args ) { $success = false; + $postfix_exists = EE::docker()::service_exists( 'postfix', $this->site_data->site_fs_path ); + $containers_to_start = $postfix_exists ? [ 'nginx' ] : [ 'nginx', 'postfix' ]; + if ( \EE::docker()::docker_compose_up( $this->site_data->site_fs_path, $containers_to_start ) ) { $this->site_data->site_enabled = 1; $this->site_data->save(); @@ -311,6 +314,10 @@ public function enable( $args, $assoc_args ) { $this->site_data = reset( $site_data_array ); $this->www_ssl_wrapper( $containers_to_start, true ); + if ( $postfix_exists ) { + \EE\Site\Utils\configure_postfix( $this->site_data['site_url'], $this->site_data['site_fs_path'] ); + } + if ( true === (bool) $this->site_data['admin_tools'] ) { EE::runcommand( 'admin-tools enable ' . $this->site_data['site_url'] . ' --force' ); }