<commit_before># ==================================================
# Java setup
# ==================================================
include_recipe "java::default"

# ==================================================
# XLDeploy user setup
# ==================================================
group "xldeploy" do
  action :create
  group_name node['xldeploy']['group']
end

# ==================================================
# This user will run XL Deploy
# ==================================================
user "xldeploy" do
  action :create
  username  node['xldeploy']['user']
  gid       node['xldeploy']['group']
  comment   "XL Deploy system user"
  home      "/home/xldeploy"
  system    true
  shell     "/bin/false"
end

# ==========================================
# wget installation archive
# ==========================================
execute "wget xldeploy installation archive" do
  command "wget -P #{node['xldeploy']['installdir']} --user=#{node['xldeploy']['username']} --password=#{node['xldeploy']['password']} #{node['xldeploy']['downloadurl']}"
end
# ==========================================
# xldeploy
# ==========================================
execute "unzip installation archive" do
  command "unzip /opt/#{node['xldeploy']['filename']} -d /opt"
end

# ==================================================
# chown install directory
# ==================================================
execute "update ownership" do
  command "chown -R xldeploy:xldeploy #{node['xldeploy']['home']}"
end 

# ==================================================
# Create the input file for the installer
# ==================================================
template "setup-config" do
  source  "setup-config.txt.erb"
  path    "#{node['xldeploy']['home']}/setup-config.txt"
  owner   node['xldeploy']['user']
  group   node['xldeploy']['group']
  mode    "0600"
    variables(
    :adminpassword  => "#{node['xldeploy']['adminpassword']}",
    :repository  => "#{node['xldeploy']['repository']}",
    :threads  => "#{node['xldeploy']['threads']}",
    :ssl  => "#{node['xldeploy']['ssl']}",
    :csre  => "#{node['xldeploy']['csre']}",
    :http_bind  =>"#{node['xldeploy']['http_bind']}",
    :http_context_root  => "#{node['xldeploy']['http_context_root']}",
    :threads_max  => "#{node['xldeploy']['threads_max']}",
    :cstm => "#{node['xldeploy']['cstm']}",
    :hide_internals => "#{node['xldeploy']['hide_internals']}",
    :import_packages => "#{node['xldeploy']['import_packages']}",
    :port => "#{node['xldeploy']['port']}"
    )
  notifies :run, 'execute[install-xldeploy]', :immediately
end

# ==================================================
# Run the installer
# ==================================================
execute "install-xldeploy" do
  user    node['xldeploy']['user']
  group   node['xldeploy']['group']
  cwd     "#{node['xldeploy']['home']}/bin"
  command "./server.sh -setup -reinitialize -force -setup-defaults #{node['xldeploy']['home']}/setup-config.txt &> #{node['xldeploy']['home']}/install.log"
  creates "#{node['xldeploy']['home']}/install.log"
  action :nothing
end

# ==================================================
# Runit configuration
# ==================================================
include_recipe "runit::default"

# ==================================================
# Create the service resource
# ==================================================
runit_service "xldeploy" do
  sv_dir "/etc/sv"
  service_dir "/etc/service"
  owner node['xldeploy']['user']
  group node['xldeploy']['group']
end
directory "/etc/sv/xldeploy/control" do
  owner 'root'
  group 'root'
  mode '0644'
  action :create
end
template '/etc/sv/xldeploy/control/d' do
  source 'sv-xldeploy-java-down.erb'
  owner 'root'
  group 'root'
  mode '0744'
end<commit_msg>replaced hardcoding of /opt with the existing installdir attribute, foodcritic warning cleanup, added package unzip for those OS where unzip isn't already installed<commit_after># ==================================================
# Java setup
# ==================================================
include_recipe "java::default"

# ==================================================
# XLDeploy user setup
# ==================================================
group "xldeploy" do
  action :create
  group_name node['xldeploy']['group']
end

# ==================================================
# This user will run XL Deploy
# ==================================================
user "xldeploy" do
  action :create
  username  node['xldeploy']['user']
  gid       node['xldeploy']['group']
  comment   "XL Deploy system user"
  home      "/home/xldeploy"
  system    true
  shell     "/bin/false"
end

# ==========================================
# wget installation archive
# ==========================================
execute "wget xldeploy installation archive" do
  command "wget -P #{node['xldeploy']['installdir']} --user=#{node['xldeploy']['username']} --password=#{node['xldeploy']['password']} #{node['xldeploy']['downloadurl']}"
end

# install unzip program
package "unzip" do
  action :install
end

# ==========================================
# xldeploy
# ==========================================
execute "unzip installation archive" do
  command "unzip #{node['xldeploy']['installdir']}/#{node['xldeploy']['filename']} -d #{node['xldeploy']['installdir']}"
end

# ==================================================
# chown install directory
# ==================================================
execute "update ownership" do
  command "chown -R xldeploy:xldeploy #{node['xldeploy']['home']}"
end 

# ==================================================
# Create the input file for the installer
# ==================================================
template "setup-config" do
  source  "setup-config.txt.erb"
  path    "#{node['xldeploy']['home']}/setup-config.txt"
  owner   node['xldeploy']['user']
  group   node['xldeploy']['group']
  mode    "0600"
    variables(
    :adminpassword  => node['xldeploy']['adminpassword'],
    :repository  => node['xldeploy']['repository'],
    :threads  => node['xldeploy']['threads'],
    :ssl  => node['xldeploy']['ssl'],
    :csre  => node['xldeploy']['csre'],
    :http_bind  => node['xldeploy']['http_bind'],
    :http_context_root  => node['xldeploy']['http_context_root'],
    :threads_max  => node['xldeploy']['threads_max'],
    :cstm => node['xldeploy']['cstm'],
    :hide_internals => node['xldeploy']['hide_internals'],
    :import_packages => node['xldeploy']['import_packages'],
    :port => node['xldeploy']['port']
    )
  notifies :run, 'execute[install-xldeploy]', :immediately
end

# ==================================================
# Run the installer
# ==================================================
execute "install-xldeploy" do
  user    node['xldeploy']['user']
  group   node['xldeploy']['group']
  cwd     "#{node['xldeploy']['home']}/bin"
  command "./server.sh -setup -reinitialize -force -setup-defaults #{node['xldeploy']['home']}/setup-config.txt &> #{node['xldeploy']['home']}/install.log"
  creates "#{node['xldeploy']['home']}/install.log"
  action :nothing
end

# ==================================================
# Runit configuration
# ==================================================
include_recipe "runit::default"

# ==================================================
# Create the service resource
# ==================================================
runit_service "xldeploy" do
  sv_dir "/etc/sv"
  service_dir "/etc/service"
  owner node['xldeploy']['user']
  group node['xldeploy']['group']
end
directory "/etc/sv/xldeploy/control" do
  owner 'root'
  group 'root'
  mode '0644'
  action :create
end
template '/etc/sv/xldeploy/control/d' do
  source 'sv-xldeploy-java-down.erb'
  owner 'root'
  group 'root'
  mode '0744'
end
{'fraction_non_alphanumeric': 0.3898326733937923, 'fraction_numerical': 0.003065525609911866, 'mean_word_length': 6.450047573739296, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4357775', 'n_tokens_mistral': 2357, 'n_tokens_neox': 2251, 'n_words': 438}