From 753b29b51e39fc08996b7b6ac3fc524da51427a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn?= Date: Wed, 5 Aug 2020 17:06:55 +0200 Subject: [PATCH] bugfix check message for nginx test --- app/Factories/NginxVhostFactory.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/Factories/NginxVhostFactory.php b/app/Factories/NginxVhostFactory.php index 253be5a..beb3756 100644 --- a/app/Factories/NginxVhostFactory.php +++ b/app/Factories/NginxVhostFactory.php @@ -168,9 +168,18 @@ class NginxVhostFactory // check status if ($menu->getSelectedItem()->getChecked()) { symlink('/etc/nginx/sites-available/'.$vhost['file'], '/etc/nginx/sites-enabled/'.$vhost['file']); + exec('nginx -c /etc/nginx/nginx.conf -t 2>&1', $output); + $result = preg_match_all("/syntax is ok/", implode(' ', $output), $output); + + // restart if success message was found + if ($result > 0) { + exec('service nginx restart'); + $menu->confirm('Success! ')->display('OK!'); - if ($output) { + $vhost['enabled'] = true; + $status = 'enabled'; + } else { unlink('/etc/nginx/sites-enabled/'.$vhost['file']); $menu->confirm('Error! Configuration not Working!')->display('OK!'); @@ -179,15 +188,6 @@ class NginxVhostFactory $vhost['enabled'] = false; $status = 'disabled'; - } else { - - // restart - exec('service nginx restart'); - $menu->confirm('Success! ')->display('OK!'); - - $vhost['enabled'] = true; - $status = 'enabled'; - } } else { unlink('/etc/nginx/sites-enabled/'.$vhost['file']);