### Home Classes Methods

### In Files

- lib/chef/solr/solr_installer.rb

### Parent

Object

### Namespace

- CLASS Chef::SolrInstaller::Config

### Methods

- ::new
- #chdir
- #chef_solr_installed?
- #chown
- #confirm_overwrite
- #create_solr_data_dir
- #create_solr_home
- #group
- #indent
- #mkdir_p
- #overwriting?
- #rm_rf
- #run
- #say
- #scorch_the_earth
- #sh
- #unpack_solr_jetty

### Included Modules

- Chef::Mixin::ShellOut

### Class/Module Index

Quicksearch

- Chef
- Chef::Solr
- Chef::Solr::Application
- Chef::Solr::Application::Solr
- Chef::SolrInstaller
- Chef::SolrInstaller::Config
- Chef::SolrInstaller::Config::CLI
- Chef::SolrInstaller::Config::CompatConfig

No matching classes.

# Chef::SolrInstaller

### Constants

PACKAGED_SOLR_DIR

### Attributes

config[R]

### Public Class Methods

new(argv) click to toggle source

    # File lib/chef/solr/solr_installer.rb, line 245
    def initialize(argv)
      @indent = 0
      @config = Config.new.configure_from(argv.dup)
      @overwriting = false
    end

### Public Instance Methods

chdir(dir, &block) click to toggle source

    # 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

chef_solr_installed?() click to toggle source

    # File lib/chef/solr/solr_installer.rb, line 255
    def chef_solr_installed?
      File.exist?(config.solr_home_path)
    end

chown(file) click to toggle source

    # 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

confirm_overwrite() click to toggle source

    # 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

create_solr_data_dir() click to toggle source

    # 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

create_solr_home() click to toggle source

    # 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

group(message, &block) click to toggle source

    # File lib/chef/solr/solr_installer.rb, line 375
    def group(message, &block)
      say(message)
      indent(&block)
    end

indent() click to toggle source

    # File lib/chef/solr/solr_installer.rb, line 369
    def indent
      @indent += 1
      yield
      @indent -= 1
    end

mkdir_p(directory) click to toggle source

    # 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

overwriting?() click to toggle source

    # File lib/chef/solr/solr_installer.rb, line 251
    def overwriting?
      @overwriting
    end

rm_rf(path) click to toggle source

    # 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

run() click to toggle source

    # 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

say(message) click to toggle source

    # File lib/chef/solr/solr_installer.rb, line 380
    def say(message)
      puts "#{' ' * (2 * @indent)}#{message}"
    end

scorch_the_earth() click to toggle source

    # 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

sh(*args) click to toggle source

    # 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

unpack_solr_jetty() click to toggle source

    # 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.