lib/beaker-pe/install/pe_utils.rb
#Determine the PE package to download/upload on a unix style host, download/upload that package onto the host
#and unpack it.
# @param [Host] host The unix style host to download/upload and unpack PE onto
# @param  [Hash{Symbol=>Symbol, String}] opts The options
# @option opts [String] :pe_dir Default directory or URL to pull PE package from
#                  (Otherwise uses individual hosts pe_dir)
# @option opts [Boolean] :fetch_local_then_push_to_host determines whether
#                 you use Beaker as the middleman for this (true), or curl the
#                 file from the host (false; default behavior)
# @api private
Determine the PE package to download/upload on a unix style host, download/upload that package onto the host
and unpack it.
Determine the PE package to download / upload on a unix style host download / upload that package onto the host and unpack it .
def fetch_pe_on_unix(host, opts)
          path = host['pe_dir'] || opts[:pe_dir]
          local = File.directory?(path)
          filename = "#{host['dist']}"
          if local
            extension = File.exists?("#{path}/#{filename}.tar.gz") ? ".tar.gz" : ".tar"
            if not File.exists?("#{path}/#{filename}#{extension}")
              raise "attempting installation on #{host}, #{path}/#{filename}#{extension} does not exist"
            end
            scp_to host, "#{path}/#{filename}#{extension}", "#{host['working_dir']}/#{filename}#{extension}"
            if extension =~ /gz/
              on host, "cd #{host['working_dir']}; gunzip #{filename}#{extension}"
            end
            if extension =~ /tar/
              on host, "cd #{host['working_dir']}; tar -xvf #{filename}.tar"
            end
          else
            if host['platform'] =~ /eos/
              extension = '.swix'
            else
              extension = link_exists?("#{path}/#{filename}.tar.gz") ? ".tar.gz" : ".tar"
            end
            if not link_exists?("#{path}/#{filename}#{extension}")
              raise "attempting installation on #{host}, #{path}/#{filename}#{extension} does not exist"
            end
            if host['platform'] =~ /eos/
              host.get_remote_file("#{path}/#{filename}#{extension}")
            else
              unpack = 'tar -xvf -'
              unpack = extension =~ /gz/ ? 'gunzip | ' + unpack  : unpack
              if opts[:fetch_local_then_push_to_host]
                fetch_and_push_pe(host, path, filename, extension)
                command_file_push = 'cat '
              else
                command_file_push = "curl #{path}/"
              end
              on host, "cd #{host['working_dir']}; #{command_file_push}#{filename}#{extension} | #{unpack}"
            end
          end
        end
def fetch_pe_on_unix ( host , opts ) path = host [ 'pe_dir' ] || opts [ :pe_dir ] local = File . directory? ( path ) filename = "#{host['dist']}" if local extension = File . exists? ( "#{path}/#{filename}.tar.gz" ) ? ".tar.gz" : ".tar" if not File . exists? ( "#{path}/#{filename}#{extension}" ) raise "attempting installation on #{host}, #{path}/#{filename}#{extension} does not exist" end scp_to host , "#{path}/#{filename}#{extension}" , "#{host['working_dir']}/#{filename}#{extension}" if extension =~ / gz / on host , "cd #{host['working_dir']}; gunzip #{filename}#{extension}" end if extension =~ / tar / on host , "cd #{host['working_dir']}; tar -xvf #{filename}.tar" end else if host [ 'platform' ] =~ / eos / extension = '.swix' else extension = link_exists? ( "#{path}/#{filename}.tar.gz" ) ? ".tar.gz" : ".tar" end if not link_exists? ( "#{path}/#{filename}#{extension}" ) raise "attempting installation on #{host}, #{path}/#{filename}#{extension} does not exist" end if host [ 'platform' ] =~ / eos / host . get_remote_file ( "#{path}/#{filename}#{extension}" ) else unpack = 'tar -xvf -' unpack = extension =~ / gz / ? 'gunzip | ' + unpack : unpack if opts [ :fetch_local_then_push_to_host ] fetch_and_push_pe ( host , path , filename , extension ) command_file_push = 'cat ' else command_file_push = "curl #{path}/" end on host , "cd #{host['working_dir']}; #{command_file_push}#{filename}#{extension} | #{unpack}" end end end
Determine the PE package to download/upload on a unix style host, download/upload that package onto the host
and unpack it.
Determine the PE package to download / upload on a unix style host download / upload that package onto the host and unpack it .
host
<not_specific>
opts
<not_specific>