From 494f8ffb69ff251b3448a5027a5e6b39f7dfd77b Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Tue, 25 Sep 2012 18:30:27 -0400 Subject: ADD: do a cursory validatation of the elasticsearch url --- src/phorkie/SetupCheck.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/phorkie/SetupCheck.php b/src/phorkie/SetupCheck.php index b1107b5..f1fbc0f 100644 --- a/src/phorkie/SetupCheck.php +++ b/src/phorkie/SetupCheck.php @@ -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() @@ -31,7 +32,9 @@ class SetupCheck $sc->checkDeps(); $sc->checkDirs(); $sc->checkGit(); - $sc->checkDatabase(); + if ($this->elasticsearch != '') { + $sc->checkDatabase(); + } } public function checkDeps() @@ -73,6 +76,11 @@ class SetupCheck public function checkDatabase() { + $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(); } -- cgit v1.2.3