Sha256: 9b9329f942ec3f2b93f241134acc1ff94446c89bf574f3b77376cf2e59f6d145
Contents?: true
Size: 1.51 KB
Versions: 5
Compression:
Stored size: 1.51 KB
Contents
require 'fileutils' require 'open-uri' require 'uuid' require 'zip' desc "Update kibana from upstream" task :update do asset_path = File.expand_path(File.dirname(__FILE__) + "/../kibana/assets") download_url = 'https://github.com/elasticsearch/kibana/archive/master.zip' download_file = "/tmp/#{UUID.new.generate}_master.zip" tmp_path = "/tmp/#{UUID.new.generate}" # Remove kibana assets FileUtils.rm_rf(asset_path) # Create the tmp folder FileUtils.mkdir(tmp_path) # Download latest kibana from github File.open(download_file, "wb") do |file| file.write open(download_url).read end # Unpack zip into tmp folder unzip_file download_file, tmp_path # Copy src contents to asset folder FileUtils.mv "#{tmp_path}/kibana-master/src", asset_path # Delete tmp folder and downloaded file FileUtils.rm_rf(tmp_path) FileUtils.rm(download_file) # Move the config.js file to the view file and setup erb variables config_file = "#{asset_path}/../views/config.erb" FileUtils.mv "#{asset_path}/config.js", config_file text = File.read(config_file) text.gsub!('http://"+window.location.hostname+":9200', '<%= elasticsearch_url %>') text.gsub!('"kibana-int"', '"<%= kibana_index %>"') File.open(config_file, "w") {|file| file.write(text) } end def unzip_file(file, destination) Zip::File.open(file) { |zip_file| zip_file.each { |f| f_path=File.join(destination, f.name) FileUtils.mkdir_p(File.dirname(f_path)) zip_file.extract(f, f_path) unless File.exist?(f_path) } } end
Version data entries
5 entries across 5 versions & 1 rubygems