Fix bug #24: verify geshi installation, Fix bug #25: setupcheck: verify markdown
[phorkie.git] / src / phorkie / SetupCheck.php
index 24f7009e62f59656e56ca0eaa9646ac9e2cf65df..0affe05caec281d960e4fa093a8ba23b4e592390 100644 (file)
@@ -8,14 +8,14 @@ class SetupCheck
         'pear.twig-project.org/Twig'       => 'Twig_Autoloader',
         'pear.php.net/Date_HumanDiff'      => 'Date_HumanDiff',
         'pear.php.net/HTTP_Request2'       => 'HTTP_Request2',
+        'pear.php.net/OpenID'              => 'OpenID',
         'pear.php.net/Pager'               => 'Pager',
         'pear.php.net/Services_Libravatar' => 'Services_Libravatar',
         'zustellzentrum.cweiske.de/MIME_Type_PlainDetect' => 'MIME_Type_PlainDetect',
-        'pear.michelf.ca/Markdown'         => 'Markdown',
     );
 
     protected $writableDirs;
-
+    protected $elasticsearch;
 
     public function __construct()
     {
@@ -24,6 +24,7 @@ class SetupCheck
             'gitdir' => $cfg['gitdir'],
             'workdir' => $cfg['workdir'],
         );
+        $this->elasticsearch = $cfg['elasticsearch'];
     }
 
     public static function run()
@@ -42,6 +43,18 @@ class SetupCheck
                 $this->fail('PEAR package not installed: ' . $package);
             }
         }
+
+        $geshi = stream_resolve_include_path(
+            $GLOBALS['phorkie']['cfg']['geshi']
+        );
+        if ($geshi === false) {
+            $this->fail('GeSHi not available');
+        }
+
+        $markdown = stream_resolve_include_path('markdown.php');
+        if ($markdown === false) {
+            $this->fail('Markdown renderer not available');
+        }
     }
 
     public function checkDirs()
@@ -74,6 +87,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();
     }