Sha256: 7d196323e447f01cf80e9ea75d5f5111fdbf2bb87700e7f1c8d3d12b47d88f7c

Contents?: true

Size: 1.19 KB

Versions: 792

Compression:

Stored size: 1.19 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'rest-client'
require 'nokogiri'

printf 'Installing phantomjs ******************************************************************'
phantomjs_tar_bz2 = ''
phantomjs_tar_extraction_path = '/opt/phantomjs-releases'
phantomjs_linux_download = ''
url = 'http://phantomjs.org/download.html'
# Look for specific links w/ pattern matching 64 bit linux tar.gz
phantomjs_resp = RestClient.get(url)
links = Nokogiri::HTML(phantomjs_resp).xpath('//a/@href')
links.each do |link|
  if link.value.match?(/linux-x86_64\.tar\.bz2/)
    phantomjs_tar_bz2 = "/opt/#{File.basename(link.value)}"
    phantomjs_linux_download = link.value
  end
end

puts `sudo wget -O #{phantomjs_tar_bz2} #{phantomjs_linux_download}` unless File.exist?(phantomjs_tar_bz2)

puts `sudo mkdir -p #{phantomjs_tar_extraction_path}` unless Dir.exist?(phantomjs_tar_extraction_path)
puts `sudo tar -xjvf #{phantomjs_tar_bz2} -C #{phantomjs_tar_extraction_path}`
phantomjs_tar_extracted_root = "#{phantomjs_tar_extraction_path}/#{File.basename(phantomjs_tar_bz2, '.tar.bz2')}"
puts `sudo cp "#{phantomjs_tar_extracted_root}/bin/phantomjs" "/usr/local/bin/phantomjs"`
puts `sudo rm #{phantomjs_tar_bz2}`

Version data entries

792 entries across 792 versions & 1 rubygems

Version Path
pwn-0.4.371 packer/provisioners/phantomjs.rb
pwn-0.4.370 packer/provisioners/phantomjs.rb
pwn-0.4.369 packer/provisioners/phantomjs.rb
pwn-0.4.368 packer/provisioners/phantomjs.rb
pwn-0.4.367 packer/provisioners/phantomjs.rb
pwn-0.4.366 packer/provisioners/phantomjs.rb
pwn-0.4.365 packer/provisioners/phantomjs.rb
pwn-0.4.364 packer/provisioners/phantomjs.rb
pwn-0.4.363 packer/provisioners/phantomjs.rb
pwn-0.4.361 packer/provisioners/phantomjs.rb
pwn-0.4.360 packer/provisioners/phantomjs.rb
pwn-0.4.359 packer/provisioners/phantomjs.rb
pwn-0.4.357 packer/provisioners/phantomjs.rb
pwn-0.4.356 packer/provisioners/phantomjs.rb
pwn-0.4.355 packer/provisioners/phantomjs.rb
pwn-0.4.353 packer/provisioners/phantomjs.rb
pwn-0.4.352 packer/provisioners/phantomjs.rb
pwn-0.4.351 packer/provisioners/phantomjs.rb
pwn-0.4.350 packer/provisioners/phantomjs.rb
pwn-0.4.349 packer/provisioners/phantomjs.rb