do not try to delete if file does not exist
[phorkie.git] / src / phorkie / SetupCheck.php
index b1107b51b15b66c26a6b982cc0146ac45024b400..b205b87baa60a43631e0bd5281d85ccd873245fe 100644 (file)
@@ -14,7 +14,7 @@ class SetupCheck
     );
 
     protected $writableDirs;
-
+    protected $elasticsearch;
 
     public function __construct()
     {
@@ -23,6 +23,7 @@ class SetupCheck
             'gitdir' => $cfg['gitdir'],
             'workdir' => $cfg['workdir'],
         );
+        $this->elasticsearch = $cfg['elasticsearch'];
     }
 
     public static function run()
@@ -73,6 +74,18 @@ class SetupCheck
 
     public function checkDatabase()
     {
+        if ($this->elasticsearch == '') {
+            return;
+        }
+
+        $es = parse_url($this->elasticsearch);
+        if (!preg_match("#/.+/#", $es['path'], $matches)) {
+            $this->fail(
+                'Improper elasticsearch url.  Elasticsearch requires a'
+                . ' search domain to store your data.'
+                . ' (e.g. http://localhost:9200/phorkie/)'
+            );
+        }
         $dbs = new Database();
         $dbs->getSetup()->setup();
     }