#!/usr/bin/env ruby require 'pathname' # Not using optparse or trollop because they raise on unknown args, and # we want to pass all unknown args to elasticsearch. args = ARGV.join(" ") config_directory_arg = /-c\s+(\S+)\s?/ if dir = args.slice!(config_directory_arg) conf = config_directory_arg.match(dir){ |m| Pathname.new(m[1]) } raise "Must provide the configuration directory." unless conf.directory? ENV['ES_JAVA_OPTS'] = "-Des.path.conf=#{conf.to_s}" if es_include = conf.children(false).detect { |p| p.to_s == "elasticsearch.in.sh" } ENV['ES_INCLUDE'] = (conf + es_include).to_s end end exec (Pathname.new(File.dirname(__FILE__)) + "../vendor/elasticsearch/bin/elasticsearch").realpath.to_s, args.strip