Skip to content
This repository was archived by the owner on Jul 15, 2019. It is now read-only.

added init script for RHEL / CENTOS systems #16

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@
default['jetty']['syslog']['tag'] = ''

default['jetty']['start_ini']['custom'] = false
default['jetty']['start_ini']['content'] = []
default['jetty']['start_ini']['default'] = false
default['jetty']['start_ini']['content'] = []
56 changes: 53 additions & 3 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,50 @@
end
end


#### Copy Jetty Modules
if version == 9
ruby_block 'Copy Jetty Modules' do
block do
Chef::Log.info "Copying Jetty Modules into #{node['jetty']['home']}"
FileUtils.cp_r File.join(node['jetty']['extracted'], 'modules', ''), node['jetty']['home']
FileUtils.chown_R(node['jetty']['user'],node['jetty']['group'],File.join(node['jetty']['home'], 'modules', ''))
raise "Failed to copy Jetty libraries" if Dir[File.join(node['jetty']['home'], 'modules', '*')].empty?
end

action :create

not_if do
Dir[File.join(node['jetty']['home'], 'modules', '*')].empty?
not Dir.exist? "#{node['jetty']['extracted']}/modules"
end
end
end


#################################################################################
# Init script and setup service

if node['jetty']['syslog']['enable']
template '/etc/init.d/jetty' do

if node['jetty']['syslog']['enable'] and not platform_family?("rhel")

template '/etc/init.d/jetty' do
source "jetty-#{version}.sh.erb"
mode '544'
action :create
end
else

elsif platform_family?("rhel")

template "/etc/init.d/jetty" do
source "jetty_init_el.erb"
mode 0755
owner "root"
group "root"
notifies :restart , "service[jetty]" , :delayed
end

else
ruby_block 'Copy Jetty init file (jetty.sh)' do
block do
Chef::Log.info "Copying Jetty init file (jetty.sh) into /etc/init.d/ folder"
Expand Down Expand Up @@ -227,6 +261,22 @@
group node['jetty']['group']
notifies :restart, "service[jetty]"
end

elsif node['jetty']['start_ini']['default']

Chef::Log.info "Using default start.ini"

ruby_block 'Copy start.ini' do
block do
Chef::Log.info "Copying start.ini"
FileUtils.cp File.join(node['jetty']['extracted'], 'start.ini'), "#{node['jetty']['home']}/start.ini"
raise "Failed to copy start.ini" unless File.exists?("#{node['jetty']['home']}/start.ini")
end
action :create
not_if do
File.exists?("#{node['jetty']['home']}/start.ini")
end
end
else
cookbook_file "#{node['jetty']['home']}/start.ini" do
source "jetty-#{version}-start.ini"
Expand Down
27 changes: 27 additions & 0 deletions recipes/rotate_logs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Cookbook Name:: hipsnip-jetty
## Recipe:: rotate_logs
##
## Copyright 2012-2013, HipSnip Limited
##
## 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 "logrotate"


logrotate_app "jetty" do
cookbook "logrotate"
path "#{node['jetty']['logs']}/*.log"
frequency "daily"
rotate 30
create "644 root root"
end
Loading