<commit_before>#
# Author:: <NAME> (<<EMAIL>>)
# Cookbook Name:: jboss
# Recipe:: default
#
# Copyright 2011, Meltmedia
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_recipe "java"

# jboss is packaged as a zip
case node['platform']
when "ubuntu","debian","centos","redhat","fedora"
  %w{unzip}.each do |pkg|
    package pkg do
      action :install
    end
  end
end

if node.has_key?("ec2")
  server_fqdn = node['ec2']['public_hostname']
else
  server_fqdn = node['fqdn']
end

directory "#{node[:jboss][:dir]}" do
  recursive true
  action :create
end

# Add User and group
group node[:jboss][:systemgroup] do
end

user node[:jboss][:systemuser] do
  comment "JBoss"
  gid node[:jboss][:systemgroup]
  home node[:jboss][:dir]
  shell "/bin/bash"
end

if !File.exists?("#{node[:jboss][:dir]}/JBossORG-EULA.txt")
  remote_file "#{Chef::Config[:file_cache_path]}/jboss-#{node[:jboss][:version]}.zip" do
    checksum node[:jboss][:checksum]
    source node[:jboss][:url]
    mode "0644"

    action :create_if_missing
  end

  execute "unzip-jboss" do
    cwd node[:jboss][:target_dir]
    command "unzip #{Chef::Config[:file_cache_path]}/jboss-#{node[:jboss][:version]}.zip"

    creates "#{node[:jboss][:dir]}/JBossORG-EULA.txt"
  end
end

# Link init script, and add to runlevel
# TODO add additional platforms
case node['platform']
when "ubuntu","debian"
  template "#{node[:jboss][:dir]}/bin/jboss_init_ubuntu.sh" do
    source "jboss_init_ubuntu.sh.erb"
    owner node[:jboss][:systemuser]
    group node[:jboss][:systemgroup]
    mode "0755"
  end

  execute "link-jboss-init" do
    command "ln -s #{node[:jboss][:dir]}/bin/jboss_init_ubuntu.sh #{node[:jboss][:init_script]}"
    creates "#{node[:jboss][:init_script]}"
  end
  
  execute "add-jboss-init" do
    command "update-rc.d jboss defaults #{node[:jboss][:runlevel]}"
  end
end

template "#{node[:jboss][:server]}/conf/bootstrap/profile-repository.xml" do
  source "profile-repository.xml.erb"
  owner node[:jboss][:systemuser]
  group node[:jboss][:systemgroup]
  mode "0644"
  variables :deploy_paths => node[:jboss][:deploy_paths]
end

chown "#{node['jboss']['dir']}" do
  user node[:jboss][:systemuser]
  group node[:jboss][:systemgroup]
  notifies :start, "service[jboss]", :delayed
end

service "jboss" do<commit_msg>updated again<commit_after>#
# Author:: <NAME> (<<EMAIL>>)
# Cookbook Name:: jboss
# Recipe:: default
#
# Copyright 2011, Meltmedia
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_recipe "java"

# jboss is packaged as a zip
case node['platform']
when "ubuntu","debian","centos","redhat","fedora"
  %w{unzip}.each do |pkg|
    package pkg do
      action :install
    end
  end
end

if node.has_key?("ec2")
  server_fqdn = node['ec2']['public_hostname']
else
  server_fqdn = node['fqdn']
end

directory "#{node[:jboss][:dir]}" do
  recursive true
  action :create
end

# Add User and group
group node[:jboss][:systemgroup] do
end

user node[:jboss][:systemuser] do
  comment "JBoss"
  gid node[:jboss][:systemgroup]
  home node[:jboss][:dir]
  shell "/bin/bash"
end

if !File.exists?("#{node[:jboss][:dir]}/JBossORG-EULA.txt")
  remote_file "#{Chef::Config[:file_cache_path]}/jboss-#{node[:jboss][:version]}.zip" do
    checksum node[:jboss][:checksum]
    source node[:jboss][:url]
    mode "0644"

    action :create_if_missing
  end

  execute "unzip-jboss" do
    cwd node[:jboss][:target_dir]
    command "unzip #{Chef::Config[:file_cache_path]}/jboss-#{node[:jboss][:version]}.zip"

    creates "#{node[:jboss][:dir]}/JBossORG-EULA.txt"
  end
end

# Link init script, and add to runlevel
# TODO add additional platforms
case node['platform']
when "ubuntu","debian"
  template "#{node[:jboss][:dir]}/bin/jboss_init_ubuntu.sh" do
    source "jboss_init_ubuntu.sh.erb"
    owner node[:jboss][:systemuser]
    group node[:jboss][:systemgroup]
    mode "0755"
  end

  execute "link-jboss-init" do
    command "ln -s #{node[:jboss][:dir]}/bin/jboss_init_ubuntu.sh #{node[:jboss][:init_script]}"
    creates "#{node[:jboss][:init_script]}"
  end
  
  execute "add-jboss-init" do
    command "update-rc.d jboss defaults #{node[:jboss][:runlevel]}"
  end
end

template "#{node[:jboss][:dir]}/#{node[:jboss][:server]}/conf/bootstrap/profile-repository.xml" do
  source "profile-repository.xml.erb"
  owner node[:jboss][:systemuser]
  group node[:jboss][:systemgroup]
  mode "0644"
  variables :deploy_paths => node[:jboss][:deploy_paths]
end

chown "#{node['jboss']['dir']}" do
  user node[:jboss][:systemuser]
  group node[:jboss][:systemgroup]
  notifies :start, "service[jboss]", :delayed
end

service "jboss" do
{'fraction_non_alphanumeric': 0.15562678062678062, 'fraction_numerical': 0.007834757834757835, 'mean_word_length': 4.869383490073146, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6297905', 'n_tokens_mistral': 2101, 'n_tokens_neox': 1966, 'n_words': 506}