@@ -283,15 +283,22 @@ function site_status_check( $site_url ) {
283283 EE ::log ( 'Checking and verifying site-up status. This may take some time. ' );
284284 $ httpcode = get_curl_info ( $ site_url );
285285 $ i = 0 ;
286+ $ auth = false ;
286287 while ( 200 !== $ httpcode && 302 !== $ httpcode && 301 !== $ httpcode ) {
287288 EE ::debug ( "$ site_url status httpcode: $ httpcode " );
288- $ httpcode = get_curl_info ( $ site_url );
289+ if ( 401 === $ httpcode ) {
290+ $ user_pass = get_global_auth ();
291+ $ auth = $ user_pass ['username ' ] . ': ' . $ user_pass ['password ' ];
292+ }
293+ $ httpcode = get_curl_info ( $ site_url , 80 , false , $ auth );
289294 echo '. ' ;
290295 sleep ( 2 );
291296 if ( $ i ++ > 60 ) {
292297 break ;
293298 }
294299 }
300+ EE ::debug ( "$ site_url status httpcode: $ httpcode " );
301+ echo PHP_EOL ;
295302 if ( 200 !== $ httpcode && 302 !== $ httpcode && 301 !== $ httpcode ) {
296303 throw new \Exception ( 'Problem connecting to site! ' );
297304 }
@@ -304,17 +311,21 @@ function site_status_check( $site_url ) {
304311 * @param string $url url to get info about.
305312 * @param int $port The port to check.
306313 * @param bool $port_info Return port info or httpcode.
314+ * @param mixed $auth Send http auth with passed value if not false.
307315 *
308316 * @return bool|int port occupied or httpcode.
309317 */
310- function get_curl_info ( $ url , $ port = 80 , $ port_info = false ) {
318+ function get_curl_info ( $ url , $ port = 80 , $ port_info = false , $ auth = false ) {
311319
312320 $ ch = curl_init ( $ url );
313321 curl_setopt ( $ ch , CURLOPT_HEADER , true );
314322 curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 );
315323 curl_setopt ( $ ch , CURLOPT_NOBODY , true );
316324 curl_setopt ( $ ch , CURLOPT_TIMEOUT , 10 );
317325 curl_setopt ( $ ch , CURLOPT_PORT , $ port );
326+ if ( $ auth ) {
327+ curl_setopt ( $ ch , CURLOPT_USERPWD , $ auth );
328+ }
318329 curl_exec ( $ ch );
319330 if ( $ port_info ) {
320331 return empty ( curl_getinfo ( $ ch , CURLINFO_PRIMARY_IP ) );
@@ -405,3 +416,27 @@ function configure_postfix( $site_url, $site_fs_path ) {
405416function reload_global_nginx_proxy () {
406417 \EE ::launch ( sprintf ( 'docker exec %s sh -c "/app/docker-entrypoint.sh /usr/local/bin/docker-gen /app/nginx.tmpl /etc/nginx/conf.d/default.conf; /usr/sbin/nginx -s reload" ' , EE_PROXY_TYPE ) );
407418}
419+
420+ /**
421+ * Get global auth if it exists.
422+ */
423+ function get_global_auth () {
424+ if ( ! class_exists ( '\EE\Model\Auth ' ) ) {
425+ return false ;
426+ }
427+
428+ $ auth = \EE \Model \Auth::where ( [
429+ 'site_url ' => 'default ' ,
430+ 'scope ' => 'site ' ,
431+ ] );
432+
433+ if ( empty ( $ auth ) ) {
434+ return false ;
435+ }
436+
437+ return [
438+ 'username ' => $ auth [0 ]->username ,
439+ 'password ' => $ auth [0 ]->password ,
440+ ];
441+
442+ }
0 commit comments