diff --git a/modules/Installer/Config/config.php b/modules/Installer/Config/config.php index 44efaa95..76ea37af 100644 --- a/modules/Installer/Config/config.php +++ b/modules/Installer/Config/config.php @@ -1,14 +1,10 @@ [ 'version' => '7.0.0' ], - # TODO: Remove eventually -// 'env_postfix' => '.generated', 'env_postfix' => '', 'extensions' => [ @@ -20,9 +16,15 @@ return [ 'cURL', ], + # Make sure these are writable 'permissions' => [ - 'storage/framework/' => 'writeable', - 'storage/logs/' => 'writeable', - 'bootstrap/cache/' => 'writable' + 'bootstrap/cache', + 'storage', + 'storage/app/public', + 'storage/framework', + 'storage/framework/cache', + 'storage/framework/sessions', + 'storage/framework/views', + 'storage/logs', ], ]; diff --git a/modules/Installer/Http/Controllers/InstallerController.php b/modules/Installer/Http/Controllers/InstallerController.php index 9f6c0d47..7fff0358 100644 --- a/modules/Installer/Http/Controllers/InstallerController.php +++ b/modules/Installer/Http/Controllers/InstallerController.php @@ -2,6 +2,7 @@ namespace Modules\Installer\Http\Controllers; +use Illuminate\Database\QueryException; use Log; use Illuminate\Http\Request; @@ -61,27 +62,45 @@ class InstallerController extends AppBaseController ]); } + /** + * Check if any of the items has been marked as failed + * @param array $arr + * @return bool + */ + protected function allPassed(array $arr): bool + { + foreach($arr as $item) { + if($item['passed'] === false) { + return false; + } + } + + return true; + } + /** * Step 1. Check the modules and permissions */ public function step1(Request $request) { - $passed = true; $php_version = $this->reqService->checkPHPVersion(); - if($php_version['passed'] === false) { - $passed = false; - } - $extensions = $this->reqService->checkExtensions(); - foreach ($extensions as $ext) { - if($ext['passed'] === false) { - $passed = false; - } - } + $directories = $this->reqService->checkPermissions(); + + # Only pass if all the items in the ext and dirs are passed + $statuses = [ + $php_version['passed'] === true, + $this->allPassed($extensions) === true, + $this->allPassed($directories) === true + ]; + + # Make sure there are no false values + $passed = ! in_array(false, $statuses, true); return view('installer::steps/step1-requirements', [ 'php' => $php_version, 'extensions' => $extensions, + 'directories' => $directories, 'passed' => $passed, ]); } @@ -123,16 +142,16 @@ class InstallerController extends AppBaseController */ public function dbsetup(Request $request) { - $log = []; - - $log[] = 'Creating database'; - $console_out = $this->dbService->setupDB($request->input('db_conn')); + try { + $console_out = $this->dbService->setupDB($request->input('db_conn')); + } catch(QueryException $e) { + flash()->error($e->getMessage()); + return redirect(route('installer.step2')); + } return view('installer::steps/step2a-completed', [ 'console_output' => $console_out ]); - - //return redirect('/'); } /** diff --git a/modules/Installer/Resources/views/app.blade.php b/modules/Installer/Resources/views/app.blade.php index dfea5c51..ce188121 100644 --- a/modules/Installer/Resources/views/app.blade.php +++ b/modules/Installer/Resources/views/app.blade.php @@ -22,6 +22,9 @@ + @yield('css') @@ -44,18 +47,18 @@
- +{{----}}diff --git a/modules/Installer/Resources/views/steps/step2-db.blade.php b/modules/Installer/Resources/views/steps/step2-db.blade.php index 4ce0080a..e1e1e614 100644 --- a/modules/Installer/Resources/views/steps/step2-db.blade.php +++ b/modules/Installer/Resources/views/steps/step2-db.blade.php @@ -5,7 +5,7 @@ {!! Form::open(['route' => 'installer.envsetup', 'method' => 'POST']) !!}
Select Database Type | +Select Database Type |
{!! Form::select('db_conn', $db_types, null, ['class' => 'form-control', 'id' => 'db_conn']) !!}
diff --git a/modules/Installer/Services/RequirementsService.php b/modules/Installer/Services/RequirementsService.php
index 9ba34e2f..8c202715 100644
--- a/modules/Installer/Services/RequirementsService.php
+++ b/modules/Installer/Services/RequirementsService.php
@@ -40,4 +40,34 @@ class RequirementsService {
return $extensions;
}
+
+ /**
+ * Check the permissions for the directories specified
+ * Make sure they exist and are writable
+ * @return array
+ */
+ public function checkPermissions(): array
+ {
+ $directories = [];
+ foreach (config('installer.permissions') as $dir)
+ {
+ $pass = true;
+ $path = base_path($dir);
+
+ if(!file_exists($path)) {
+ $pass = false;
+ }
+
+ if(!is_writable($path)) {
+ $pass = false;
+ }
+
+ $directories[] = [
+ 'dir' => $dir,
+ 'passed' => $pass,
+ ];
+ }
+
+ return $directories;
+ }
}
|