#!/usr/bin/env ruby require 'optparse' require 'solrsrv' cmd = %w(java) OptionParser.new do |opts| opts.on '--home DIRECTORY', 'Set solr home directory to DIRECTORY.' do |solr_home| cmd << "-Dsolr.solr.home=#{File.expand_path(solr_home)}" end opts.on '--data-dir DIRECTORY', 'Set solr data directory to DIRECTORY.' do |data_path| cmd << "-Dsolr.data.dir=#{File.expand_path(data_path)}" end opts.on '--pid-file FILENAME', 'Save the pid in DIRECTORY. (default: none)' do |data_path| File.open(File.expand_path(data_path), 'w') do |f| f.write(Process.pid) end end opts.on '--log-dir DIRECTORY', '' do |log_path| cmd << "-Djetty.logs=#{File.expand_path(log_path)}" end opts.on '--port PORT', 'Set the port number to listen to' do |port| cmd << "-Djetty.port=#{port}" end opts.on_tail('-h', '--help', 'Show extended help message.') do puts opts exit 0 end end.parse! ARGV cmd << '-jar start.jar' exec "cd #{Solrsrv::SolrPath} && exec #{cmd.join(' ')}"