66# Licensed under the Apache License, Version 2.0 (the "License");
77# you may not use this file except in compliance with the License.
88# You may obtain a copy of the License at
9- #
9+ #
1010# http://www.apache.org/licenses/LICENSE-2.0
11- #
11+ #
1212# Unless required by applicable law or agreed to in writing, software
1313# distributed under the License is distributed on an "AS IS" BASIS,
1414# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2121require 'chef/application'
2222require 'chef/daemon'
2323require 'chef/client'
24+ require 'chef/solr'
2425
2526class Chef
2627 class Solr
2728 class Application
2829 class Solr < Chef ::Application
29-
30- option :config_file ,
30+
31+ option :config_file ,
3132 :short => "-c CONFIG" ,
3233 :long => "--config CONFIG" ,
3334 :default => "/etc/chef/solr.rb" ,
3435 :description => "The configuration file to use"
3536
36- option :log_level ,
37+ option :log_level ,
3738 :short => "-l LEVEL" ,
3839 :long => "--log_level LEVEL" ,
3940 :description => "Set the log level (debug, info, warn, error, fatal)" ,
@@ -101,11 +102,19 @@ class Solr < Chef::Application
101102 option :solr_java_opts ,
102103 :short => "-j OPTS" ,
103104 :long => "--java-opts OPTS" ,
104- :description => "Raw options passed to Java"
105+ :description => "Raw options passed to Java"
106+
107+ option :version ,
108+ :short => "-v" ,
109+ :long => "--version" ,
110+ :description => "Show chef-solr version" ,
111+ :boolean => true ,
112+ :proc => lambda { |v | puts "chef-solr: #{ ::Chef ::Solr ::VERSION } " } ,
113+ :exit => 0
105114
106115 def initialize
107116 super
108- Chef ::Log . level = Chef ::Config [ :log_level ]
117+ Chef ::Log . level = Chef ::Config [ :log_level ]
109118 end
110119
111120 def setup_application
@@ -119,7 +128,7 @@ def setup_application
119128
120129 # Create the Jetty container
121130 unless File . directory? ( Chef ::Config [ :solr_jetty_path ] )
122- Chef ::Log . warn ( "Initializing the Jetty container" )
131+ Chef ::Log . warn ( "Initializing the Jetty container" )
123132 solr_jetty_dir = Chef ::Resource ::Directory . new ( Chef ::Config [ :solr_jetty_path ] , nil , c . node )
124133 solr_jetty_dir . recursive ( true )
125134 solr_jetty_dir . run_action ( :create )
@@ -131,7 +140,7 @@ def setup_application
131140
132141 # Create the solr home
133142 unless File . directory? ( Chef ::Config [ :solr_home_path ] )
134- Chef ::Log . warn ( "Initializing Solr home directory" )
143+ Chef ::Log . warn ( "Initializing Solr home directory" )
135144 solr_home_dir = Chef ::Resource ::Directory . new ( Chef ::Config [ :solr_home_path ] , nil , c . node )
136145 solr_home_dir . recursive ( true )
137146 solr_home_dir . run_action ( :create )
@@ -141,7 +150,7 @@ def setup_application
141150 solr_jetty_untar . run_action ( :run )
142151 end
143152
144- # Create the solr data path
153+ # Create the solr data path
145154 unless File . directory? ( Chef ::Config [ :solr_data_path ] )
146155 Chef ::Log . warn ( "Initializing Solr data directory" )
147156 solr_data_dir = Chef ::Resource ::Directory . new ( Chef ::Config [ :solr_data_path ] , nil , c . node )
0 commit comments