Object
# File lib/chef/solr/solr_installer.rb, line 338 def chdir(dir, &block) say "entering #{dir}" if config.noop? yield if block_given? # still call the block so we get the noop output. else Dir.chdir(dir) { yield if block_given? } end end
# File lib/chef/solr/solr_installer.rb, line 255 def chef_solr_installed? File.exist?(config.solr_home_path) end
# File lib/chef/solr/solr_installer.rb, line 354 def chown(file) if config.user msg = "chown -R #{config.user}" msg << ":#{config.group}" if config.group msg << " #{file}" say msg FileUtils.chown_R(config.user, config.group, file) unless config.noop? end end
# File lib/chef/solr/solr_installer.rb, line 281 def confirm_overwrite if STDIN.tty? && STDOUT.tty? say "Chef Solr is already installed in #{config.solr_home_path}" print "Do you want to overwrite the current install? All existing Solr data will be lost. [y/n] " unless STDIN.gets =~ /^y/ say "Quitting. Try running this with --noop to see what it will change." exit 1 end else say(ERROR: Chef Solr is already installed in #{config.solr_home_path} and you did not use the--force option. Use --force to overwrite an existing installation in a non-interactive terminal.) exit 1 end end
# File lib/chef/solr/solr_installer.rb, line 316 def create_solr_data_dir group("Creating Solr Data Directory") do mkdir_p(config.solr_data_path) chown(config.solr_data_path) end end
# File lib/chef/solr/solr_installer.rb, line 307 def create_solr_home group("Creating Solr Home Directory") do mkdir_p(config.solr_home_path) chdir(config.solr_home_path) do sh("tar zxvf #{File.join(PACKAGED_SOLR_DIR, 'solr-home.tar.gz')}") end end end
# File lib/chef/solr/solr_installer.rb, line 375 def group(message, &block) say(message) indent(&block) end
# File lib/chef/solr/solr_installer.rb, line 369 def indent @indent += 1 yield @indent -= 1 end
# File lib/chef/solr/solr_installer.rb, line 333 def mkdir_p(directory) say "mkdir -p #{directory}" FileUtils.mkdir_p(directory, :mode => 0755) unless config.noop? end
# File lib/chef/solr/solr_installer.rb, line 251 def overwriting? @overwriting end
# File lib/chef/solr/solr_installer.rb, line 364 def rm_rf(path) say "rm -rf #{path}" FileUtils.rm_rf(path) unless config.noop? end
# File lib/chef/solr/solr_installer.rb, line 259 def run say '' say "*** DRY RUN ***" if config.noop? if chef_solr_installed? @overwriting = true confirm_overwrite unless config.force? || config.noop? scorch_the_earth end create_solr_home create_solr_data_dir unpack_solr_jetty say "" say "Successfully installed Chef Solr." if overwriting? say "You can restore your search index using `knife index rebuild`" end end
# File lib/chef/solr/solr_installer.rb, line 380 def say(message) puts "#{' ' * (2 * @indent)}#{message}" end
# File lib/chef/solr/solr_installer.rb, line 299 def scorch_the_earth group("Removing the existing Chef Solr installation") do rm_rf(config.solr_home_path) rm_rf(config.solr_jetty_path) rm_rf(config.solr_data_path) end end
# File lib/chef/solr/solr_installer.rb, line 347 def sh(*args) opts = args[1, args.size - 1] opts_msg = opts.empty? ? '' : " #{opts.to_s}" say "#{args.first}#{opts_msg}" shell_out!(*(args << {:cwd => false})) unless config.noop? end
# File lib/chef/solr/solr_installer.rb, line 323 def unpack_solr_jetty group("Unpacking Solr Jetty") do mkdir_p(config.solr_jetty_path) chdir(config.solr_jetty_path) do sh("tar zxvf #{File.join(PACKAGED_SOLR_DIR, 'solr-jetty.tar.gz')}") end chown(config.solr_jetty_path) end end
Generated with the Darkfish Rdoc Generator 2.