<commit_before>#
# Cookbook Name:: easy_travel
# Recipes:: dynatrace
# will install Easy Travel
# Copyright 2016, dynatrace
#
require 'json'
require 'net/https'

include_recipe 'java'
include_recipe 'dynatrace::dynatrace_user'
include_recipe 'dynatrace::agents_package'
name = '<NAME>'

installer_bitsize = node['easy_travel']['installer']['bitsize']
dynatrace_owner = node['dynatrace']['owner']
dynatrace_group = node['dynatrace']['group']

# assume that we can install Easy Travel, it will be verified now
could_be_installed = true

if platform_family?('debian', 'fedora', 'rhel')
  installer_prefix_dir = node['easy_travel']['linux']['installer']['prefix_dir']
  installer_file_name  = node['easy_travel']['linux']['installer']['file_name']
  installer_file_url   = node['easy_travel']['linux']['installer']['file_url']

  installer_cache_dir = "#{Chef::Config['file_cache_path']}/easy_travel"
  installer_path      = "#{installer_cache_dir}/#{installer_file_name}"

  dir2delete = installer_prefix_dir + "/easytravel"
  log 'Test if destination directory: ' + dir2delete + ' is empty.'
  if Dir.exist?(dir2delete) && !(Dir.entries(dir2delete) - %w{ . .. }).empty? 
    # cannot install Easy Travel because of destination directory already exists
	log 'Destination directory:' + dir2delete + ' exists and is NOT empty. Easy Travel will not be installed. Run easy_travel_uninstall recipe first. Be careful - you will lost your configuration.'
	could_be_installed = false
  end
  
else
	# Unsupported platform
	could_be_installed = false
	log 'Unsuppored platform. Only Red Hat Enterprise Linux, Debian and Fedora are supported. Easy Travel will not be installed.'
end

if could_be_installed == true then
	#creating tmp installer directory
	directory "Create the installer cache directory: #{installer_cache_dir}" do
	  path   installer_cache_dir
	  action :create
	end

	#download installation jar file
	dynatrace_copy_or_download_file "Downloading installation jar file: #{name}" do
	  file_name       installer_file_name
	  file_url        installer_file_url  
	  path            installer_path
	  dynatrace_owner dynatrace_owner
	  dynatrace_group dynatrace_group
	end

	ruby_block "#{name}" do
	  block do
		node.set[:easy_travel][:installation][:is_required] = Dynatrace::Helpers.requires_installation?(installer_prefix_dir, installer_path, '', type=:jar)
	  end
	end

	#creating installation directory
	directory "Create the installation directory #{installer_prefix_dir}" do
	  path      installer_prefix_dir
	  owner     dynatrace_owner unless ::File.exist?(installer_prefix_dir)
	  group     dynatrace_group unless ::File.exist?(installer_prefix_dir)
	  recursive true
	  action    :create
	  only_if { node[:easy_travel][:installation][:is_required] }
	end
  
  symlink = 'easytravel'
  version = node['easy_travel']['linux']['installer']['version']<commit_msg>[JLT-150550] Fix missing lib dependency when performing easyTravel recipe<commit_after>#
# Cookbook Name:: easy_travel
# Recipes:: dynatrace
# will install Easy Travel
# Copyright 2016, dynatrace
#
require 'json'
require 'net/https'

include_recipe 'java'
include_recipe 'dynatrace::dynatrace_user'
include_recipe 'dynatrace::agents_package'
name = 'Easy Travel'

installer_bitsize = node['easy_travel']['installer']['bitsize']
dynatrace_owner = node['dynatrace']['owner']
dynatrace_group = node['dynatrace']['group']

# assume that we can install Easy Travel, it will be verified now
could_be_installed = true

if platform_family?('debian', 'fedora', 'rhel')
  installer_prefix_dir = node['easy_travel']['linux']['installer']['prefix_dir']
  installer_file_name  = node['easy_travel']['linux']['installer']['file_name']
  installer_file_url   = node['easy_travel']['linux']['installer']['file_url']

  installer_cache_dir = "#{Chef::Config['file_cache_path']}/easy_travel"
  installer_path      = "#{installer_cache_dir}/#{installer_file_name}"

  dir2delete = installer_prefix_dir + "/easytravel"
  log 'Test if destination directory: ' + dir2delete + ' is empty.'
  if Dir.exist?(dir2delete) && !(Dir.entries(dir2delete) - %w{ . .. }).empty? 
    # cannot install Easy Travel because of destination directory already exists
	log 'Destination directory:' + dir2delete + ' exists and is NOT empty. Easy Travel will not be installed. Run easy_travel_uninstall recipe first. Be careful - you will lost your configuration.'
	could_be_installed = false
  end
  
else
	# Unsupported platform
	could_be_installed = false
	log 'Unsuppored platform. Only Red Hat Enterprise Linux, Debian and Fedora are supported. Easy Travel will not be installed.'
end

if could_be_installed == true then
	#creating tmp installer directory
	directory "Create the installer cache directory: #{installer_cache_dir}" do
	  path   installer_cache_dir
	  action :create
	end

	#download installation jar file
	dynatrace_copy_or_download_file "Downloading installation jar file: #{name}" do
	  file_name       installer_file_name
	  file_url        installer_file_url  
	  path            installer_path
	  dynatrace_owner dynatrace_owner
	  dynatrace_group dynatrace_group
	end

	ruby_block "#{name}" do
	  block do
		node.set[:easy_travel][:installation][:is_required] = Dynatrace::Helpers.requires_installation?(installer_prefix_dir, installer_path, '', type=:jar)
	  end
	end
  
  # See http://stackoverflow.com/questions/8328250/centos-64-bit-bad-elf-interpreter
  package 'glibc.i686'

	#creating installation directory
	directory "Create the installation directory #{installer_prefix_dir}" do
	  path      installer_prefix_dir
	  owner     dynatrace_owner unless ::File.exist?(installer_prefix_dir)
	  group     dynatrace_group unless ::File.exist?(installer_prefix_dir)
	  recursive true
	  action    :create
	  only_if { node[:easy_travel][:installation][:is_required] }
	end
  
  symlink = 'easytravel'
  version = node['easy_travel']['linux']['installer']['version']
{'fraction_non_alphanumeric': 0.10587639311043566, 'fraction_numerical': 0.0060790273556231, 'mean_word_length': 5.389428263214671, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '733649', 'n_tokens_mistral': 1916, 'n_tokens_neox': 1798, 'n_words': 462}