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.348 packer/provisioners/phantomjs.rb
pwn-0.4.347 packer/provisioners/phantomjs.rb
pwn-0.4.346 packer/provisioners/phantomjs.rb
pwn-0.4.344 packer/provisioners/phantomjs.rb
pwn-0.4.343 packer/provisioners/phantomjs.rb
pwn-0.4.342 packer/provisioners/phantomjs.rb
pwn-0.4.341 packer/provisioners/phantomjs.rb
pwn-0.4.340 packer/provisioners/phantomjs.rb
pwn-0.4.339 packer/provisioners/phantomjs.rb
pwn-0.4.338 packer/provisioners/phantomjs.rb
pwn-0.4.336 packer/provisioners/phantomjs.rb
pwn-0.4.333 packer/provisioners/phantomjs.rb