Commit a3292373 authored by Stefan Galinski's avatar Stefan Galinski 🎮
Browse files

[BUGFIX] Fix foodcritic and warnings

parent 996caeb1
=begin
default[:typo3_solr][:versions] = {
:Client15_Metallbringts => {
:solr => '3.6.2',
:ext => '2.8',
:plugin => '1.2.0',
:languages => %w{ german english french italian generic hungarian }
},
:Client8_MacHoffmann => {
:solr => '3.5.0',
:ext => '2.2',
:plugin => '1.2.0',
:languages => %w{ german english french italian generic hungarian }
}
}
=end
default[:typo3_solr][:solr][:solr_home] = "/srv/solr"
\ No newline at end of file
default['typo3_solr']['solr']['solr_home'] = '/srv/solr'
\ No newline at end of file
use_inline_resources
action :add do
uri = URI.parse("https://raw.githubusercontent.com/TYPO3-Solr/ext-solr/release-#{new_resource.extension}.x/README.md")
......@@ -9,258 +11,248 @@ action :add do
if response.code.to_i == 200
remote_branch = "release-#{new_resource.extension}.x"
else
remote_branch = "master"
remote_branch = 'master'
end
resources_path = "Resources/Solr"
resources_path = 'Resources/Solr'
if Gem::Version.new(new_resource.extension) >= Gem::Version.new('3.1')
ext_solr_uri = "https://raw.githubusercontent.com/TYPO3-Solr/ext-solr/#{remote_branch}/#{resources_path}"
plugin_uri = "https://github.com/TYPO3-Solr/solr-typo3-plugin/releases/download/release-#{new_resource.plugin}"
else
ext_solr_uri = "https://forge.typo3.org/projects/extension-solr/repository/revisions/#{remote_branch}/raw/#{resources_path}"
plugin_uri = "http://www.typo3-solr.com/fileadmin/files/solr"
end
ext_solr_uri = "https://raw.githubusercontent.com/TYPO3-Solr/ext-solr/#{remote_branch}/#{resources_path}"
plugin_uri = "https://github.com/TYPO3-Solr/solr-typo3-plugin/releases/download/release-#{new_resource.plugin}"
service "tomcat" do
service_name "tomcat6"
service 'tomcat' do
service_name 'tomcat6'
supports :restart => true, :reload => true, :status => true
end
#remote_file "/home/vagrant/apache-solr-#{new_resource.solr}.tar.gz" do
# source "http://www.us.apache.org/dist/lucene/solr/#{new_resource.solr}/solr-#{new_resource.solr}.tgz"
# action :create_if_missing
#end
bash 'Fetch Solr' do
user 'vagrant'
timeout 3000000
only_if {
not ::File.exists?("#{Chef::Config[:file_cache_path]}/apache-solr-#{new_resource.solr}.tar.gz")
not ::File.exists?("#{Chef::Config['file_cache_path']}/apache-solr-#{new_resource.solr}.tar.gz")
}
code <<-EOF
rsync --delete -auvz --progress -e "ssh -o StrictHostKeyChecking=no" \
--no-o --no-g deploy@deploy.sgalinski.de:~/solr/solr-#{new_resource.solr}.tgz \
"#{Chef::Config[:file_cache_path]}/apache-solr-#{new_resource.solr}.tar.gz";
"#{Chef::Config['file_cache_path']}/apache-solr-#{new_resource.solr}.tar.gz";
EOF
action :run
end
execute "decompress-solr-archive - #{new_resource.name}" do
cwd "#{Chef::Config[:file_cache_path]}"
cwd #{Chef::Config['file_cache_path']}
command "tar -xzf apache-solr-#{new_resource.solr}.tar.gz"
creates "#{Chef::Config[:file_cache_path]}/apache-solr-#{new_resource.solr}/dist/apache-solr-#{new_resource.solr}.war"
creates "#{Chef::Config['file_cache_path']}/apache-solr-#{new_resource.solr}/dist/apache-solr-#{new_resource.solr}.war"
end
# copy solr war-file
execute "rename-solr-dir - #{new_resource.name}" do
cwd Chef::Config[:file_cache_path]
cwd Chef::Config['file_cache_path']
command "mv solr-#{new_resource.solr} apache-solr-#{new_resource.solr}"
creates "#{Chef::Config[:file_cache_path]}/apache-solr-#{new_resource.solr}"
creates "#{Chef::Config['file_cache_path']}/apache-solr-#{new_resource.solr}"
end
execute "copy-solr-app - #{new_resource.name}" do
cwd Chef::Config[:file_cache_path]
command "cp apache-solr-#{new_resource.solr}/dist/solr-#{new_resource.solr}.war #{node[:tomcat][:webapp_dir]}/#{new_resource.name}.war"
creates "#{node[:tomcat][:webapp_dir]}/#{new_resource.name}.war"
cwd Chef::Config['file_cache_path']
command "cp apache-solr-#{new_resource.solr}/dist/solr-#{new_resource.solr}.war #{node['tomcat']['webapp_dir']}/#{new_resource.name}.war"
creates "#{node['tomcat']['webapp_dir']}/#{new_resource.name}.war"
end
execute "copy-solr-libs - #{new_resource.name}" do
cwd Chef::Config[:file_cache_path]
command "cp apache-solr-#{new_resource.solr}/example/lib/ext/*.jar #{node["tomcat"]["home"]}/lib/"
cwd Chef::Config['file_cache_path']
command "cp apache-solr-#{new_resource.solr}/example/lib/ext/*.jar #{node['tomcat']['home']}/lib/"
only_if { Gem::Version.new(new_resource.solr) >= Gem::Version.new('4.0.0') }
end
execute "chmod - #{new_resource.name}" do
command "chmod -R 777 #{node["tomcat"]["home"]}/lib/"
command "chmod -R 777 #{node['tomcat']['home']}/lib/"
end
execute "copy-log4j-properties - #{new_resource.name}" do
cwd Chef::Config[:file_cache_path]
command "cp apache-solr-#{new_resource.solr}/example/resources/log4j.properties #{node["tomcat"]["home"]}/lib/log4j.properties"
creates "#{node["tomcat"]["home"]}/lib/log4j.properties"
cwd Chef::Config['file_cache_path']
command "cp apache-solr-#{new_resource.solr}/example/resources/log4j.properties #{node['tomcat']['home']}/lib/log4j.properties"
creates "#{node['tomcat']['home']}/lib/log4j.properties"
only_if { Gem::Version.new(new_resource.solr) >= Gem::Version.new('4.0.0') }
end
directory "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3cores/conf" do
owner node[:tomcat][:user]
group "root"
directory "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/typo3cores/conf" do
owner node['tomcat']['user']
group 'root'
mode 0775
action :create
recursive true
end
execute "copy-solr-files - #{new_resource.name}" do
cwd Chef::Config[:file_cache_path]
command "cp -r apache-solr-#{new_resource.solr}/example/solr/* #{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/"
cwd Chef::Config['file_cache_path']
command "cp -r apache-solr-#{new_resource.solr}/example/solr/* #{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/"
creates
end
new_resource.languages.each do |language|
directory "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3cores/conf/#{language}" do
owner node[:tomcat][:user]
group "root"
directory "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/typo3cores/conf/#{language}" do
owner node['tomcat']['user']
group 'root'
mode 0775
action :create
end
%w{ protwords.txt schema.xml synonyms.txt }.each do |file|
remote_file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3cores/conf/#{language}/#{file}" do
remote_file "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/typo3cores/conf/#{language}/#{file}" do
source "#{ext_solr_uri}/typo3cores/conf/#{language}/#{file}"
action :create_if_missing
owner node[:tomcat][:user]
owner node['tomcat']['user']
mode 0644
end
end
remote_file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3cores/conf/#{language}/_schema_analysis_stopwords_#{language}.json" do
remote_file "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/typo3cores/conf/#{language}/_schema_analysis_stopwords_#{language}.json" do
source "#{ext_solr_uri}/typo3cores/conf/#{language}/_schema_analysis_stopwords_#{language}.json"
action :create_if_missing
owner node[:tomcat][:user]
owner node['tomcat']['user']
mode 0644
end
remote_file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3cores/conf/#{language}/german-common-nouns.txt" do
remote_file "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/typo3cores/conf/#{language}/german-common-nouns.txt" do
source "#{ext_solr_uri}/typo3cores/conf/#{language}/german-common-nouns.txt"
action :create_if_missing
owner node[:tomcat][:user]
owner node['tomcat']['user']
mode 0644
only_if { language === 'german' }
end
end
%w{ elevate.xml general_schema_fields.xml general_schema_types.xml solrconfig.xml }.each do |file|
remote_file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3cores/conf/#{file}" do
remote_file "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/typo3cores/conf/#{file}" do
source "#{ext_solr_uri}/typo3cores/conf/#{file}"
action :create_if_missing
owner node[:tomcat][:user]
owner node['tomcat']['user']
mode 0664
end
end
remote_file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3cores/conf/currency.xml" do
remote_file "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/typo3cores/conf/currency.xml" do
source "#{ext_solr_uri}/typo3cores/conf/currency.xml"
action :create_if_missing
owner node[:tomcat][:user]
owner node['tomcat']['user']
mode 0644
only_if { Gem::Version.new(new_resource.extension) >= Gem::Version.new('2.8.0') }
end
file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/solr.xml" do
file "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/solr.xml" do
action :delete
end
template "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/solr.xml" do
source "solr.xml.erb"
#variables(:cores => node[:typo3_solr][:cores][new_resource.extension])
owner node[:tomcat][:user]
template "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/solr.xml" do
source 'solr.xml.erb'
#variables(:cores => node['typo3_solr'][:cores][new_resource.extension])
owner node['tomcat']['user']
mode 0644
cookbook 'typo3_solr'
end
%w{ bin conf data }.each do |directory|
directory "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/#{directory}" do
directory "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/#{directory}" do
action :delete
recursive true
end
end
file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/README.txt" do
file "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/README.txt" do
action :delete
end
template "#{node[:tomcat][:context_dir]}/#{new_resource.name}.xml" do
source "tomcat_solr.xml.erb"
template "#{node['tomcat']['context_dir']}/#{new_resource.name}.xml" do
source 'tomcat_solr.xml.erb'
variables(:app => new_resource.name)
owner node[:tomcat][:user]
owner node['tomcat']['user']
mode 0644
cookbook 'typo3_solr'
end
directory "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/dist" do
directory "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/dist" do
action :create
mode 0775
end
execute "copy-dist - #{new_resource.name}" do
command "cp -r #{Chef::Config[:file_cache_path]}/apache-solr-#{new_resource.solr}/dist #{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/"
command "cp -r #{Chef::Config['file_cache_path']}/apache-solr-#{new_resource.solr}/dist #{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/"
end
execute "copy-contrib - #{new_resource.name}" do
command "cp -r #{Chef::Config[:file_cache_path]}/apache-solr-#{new_resource.solr}/contrib #{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/"
command "cp -r #{Chef::Config['file_cache_path']}/apache-solr-#{new_resource.solr}/contrib #{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/"
end
directory "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3lib" do
directory "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/typo3lib" do
action :create
mode 0775
end
# old typo3 solr plugin
remote_file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3lib/solr-typo3-plugin-#{new_resource.plugin}.jar" do
remote_file "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/typo3lib/solr-typo3-plugin-#{new_resource.plugin}.jar" do
source "#{plugin_uri}/solr-typo3-plugin-#{new_resource.plugin}.jar"
mode 0644
notifies :restart, "service[tomcat]", :immediately
notifies :restart, 'service[tomcat]', :immediately
only_if { Gem::Version.new(new_resource.plugin) > Gem::Version.new('0.0.0') }
end
# new typo3-solr plugins
remote_file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3lib/solr-typo3-access-#{new_resource.plugin_access}.jar" do
source "http://www.typo3-solr.com/fileadmin/files/solr/Solr4x/solr-typo3-access-#{new_resource.plugin_access}.jar"
remote_file "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/typo3lib/solr-typo3-access-#{new_resource.plugin_access}.jar" do
source "http://www.typo3-solr.com/fileadmin/files/solr/Solr4x/solr-typo3-access-#{new_resource.plugin_access}.jar"
mode 0644
notifies :restart, "service[tomcat]", :immediately
notifies :restart, 'service[tomcat]', :immediately
only_if { Gem::Version.new(new_resource.plugin_access) > Gem::Version.new('0.0.0') }
end
remote_file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3lib/solr-typo3-utils-#{new_resource.plugin_utils}.jar" do
remote_file "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/typo3lib/solr-typo3-utils-#{new_resource.plugin_utils}.jar" do
source "http://www.typo3-solr.com/fileadmin/files/solr/Solr4x/solr-typo3-utils-#{new_resource.plugin_utils}.jar"
mode 0644
notifies :restart, "service[tomcat]", :immediately
notifies :restart, 'service[tomcat]', :immediately
only_if { Gem::Version.new(new_resource.plugin_utils) > Gem::Version.new('0.0.0') }
end
remote_file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3lib/commons-lang3-#{new_resource.plugin_lang}.jar" do
remote_file "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/typo3lib/commons-lang3-#{new_resource.plugin_lang}.jar" do
source "http://www.typo3-solr.com/fileadmin/files/solr/Solr4x/commons-lang3-#{new_resource.plugin_lang}.jar"
mode 0644
notifies :restart, "service[tomcat]", :immediately
notifies :restart, 'service[tomcat]', :immediately
only_if { Gem::Version.new(new_resource.plugin_lang) > Gem::Version.new('0.0.0') }
end
# reset directory access restrictions
execute "chown - #{new_resource.name}" do
command "chown -R #{node[:tomcat][:user]}:#{node[:tomcat][:group]} #{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name} && chmod -R o+rw #{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}"
command "chown -R #{node['tomcat']['user']}:#{node['tomcat']['group']} #{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name} && chmod -R o+rw #{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}"
end
new_resource.updated_by_last_action(true)
end
action :remove do
service "tomcat" do
service_name "tomcat6"
service 'tomcat' do
service_name 'tomcat6'
supports :restart => true, :reload => true, :status => true
end
directory "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}" do
directory "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}" do
action :delete
recursive true
end
file "#{node[:tomcat][:context_dir]}/#{new_resource.name}.xml" do
file "#{node['tomcat']['context_dir']}/#{new_resource.name}.xml" do
action :delete
end
file "#{node[:tomcat][:webapp_dir]}/#{new_resource.name}.war" do
file "#{node['tomcat']['webapp_dir']}/#{new_resource.name}.war" do
action :delete
end
directory "#{node[:tomcat][:webapp_dir]}/#{new_resource.name}" do
directory "#{node['tomcat']['webapp_dir']}/#{new_resource.name}" do
action :delete
recursive true
notifies :restart, "service[tomcat]", :immediately
notifies :restart, 'service[tomcat]', :immediately
end
new_resource.updated_by_last_action(true)
......
use_inline_resources
action :add do
new_resource.updated_by_last_action(false)
......
......@@ -24,8 +24,8 @@
include_recipe 'tomcat'
directory node[:typo3_solr][:solr][:solr_home] do
owner node[:tomcat][:user]
directory node['typo3_solr']['solr']['solr_home'] do
owner node['tomcat']['user']
group 'root'
mode 0770
action :create
......
<Context docBase="<%= @app %>.war" debug="0" crossContext="true" >
<Environment name="solr/home" type="java.lang.String" value="<%= node[:typo3_solr][:solr][:solr_home] %>/<%= @app %>" override="true" />
<Environment name="solr/home" type="java.lang.String" value="<%= node['typo3_solr']['solr']['solr_home'] %>/<%= @app %>" override="true" />
</Context>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment