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

[BUGFIX] Fix foodcritic and warnings

parent 996caeb1
=begin default['typo3_solr']['solr']['solr_home'] = '/srv/solr'
default[:typo3_solr][:versions] = { \ No newline at end of file
: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
use_inline_resources
action :add do action :add do
uri = URI.parse("https://raw.githubusercontent.com/TYPO3-Solr/ext-solr/release-#{new_resource.extension}.x/README.md") 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 ...@@ -9,258 +11,248 @@ action :add do
if response.code.to_i == 200 if response.code.to_i == 200
remote_branch = "release-#{new_resource.extension}.x" remote_branch = "release-#{new_resource.extension}.x"
else else
remote_branch = "master" remote_branch = 'master'
end 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}"
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}"
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
service "tomcat" do service 'tomcat' do
service_name "tomcat6" service_name 'tomcat6'
supports :restart => true, :reload => true, :status => true supports :restart => true, :reload => true, :status => true
end 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 bash 'Fetch Solr' do
user 'vagrant' user 'vagrant'
timeout 3000000 timeout 3000000
only_if { 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 code <<-EOF
rsync --delete -auvz --progress -e "ssh -o StrictHostKeyChecking=no" \ rsync --delete -auvz --progress -e "ssh -o StrictHostKeyChecking=no" \
--no-o --no-g deploy@deploy.sgalinski.de:~/solr/solr-#{new_resource.solr}.tgz \ --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 EOF
action :run action :run
end end
execute "decompress-solr-archive - #{new_resource.name}" do 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" 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 end
# copy solr war-file # copy solr war-file
execute "rename-solr-dir - #{new_resource.name}" do 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}" 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 end
execute "copy-solr-app - #{new_resource.name}" do execute "copy-solr-app - #{new_resource.name}" do
cwd Chef::Config[:file_cache_path] 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" 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" creates "#{node['tomcat']['webapp_dir']}/#{new_resource.name}.war"
end end
execute "copy-solr-libs - #{new_resource.name}" do execute "copy-solr-libs - #{new_resource.name}" do
cwd Chef::Config[:file_cache_path] cwd Chef::Config['file_cache_path']
command "cp apache-solr-#{new_resource.solr}/example/lib/ext/*.jar #{node["tomcat"]["home"]}/lib/" 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') } only_if { Gem::Version.new(new_resource.solr) >= Gem::Version.new('4.0.0') }
end end
execute "chmod - #{new_resource.name}" do execute "chmod - #{new_resource.name}" do
command "chmod -R 777 #{node["tomcat"]["home"]}/lib/" command "chmod -R 777 #{node['tomcat']['home']}/lib/"
end end
execute "copy-log4j-properties - #{new_resource.name}" do execute "copy-log4j-properties - #{new_resource.name}" do
cwd Chef::Config[:file_cache_path] cwd Chef::Config['file_cache_path']
command "cp apache-solr-#{new_resource.solr}/example/resources/log4j.properties #{node["tomcat"]["home"]}/lib/log4j.properties" command "cp apache-solr-#{new_resource.solr}/example/resources/log4j.properties #{node['tomcat']['home']}/lib/log4j.properties"
creates "#{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') } only_if { Gem::Version.new(new_resource.solr) >= Gem::Version.new('4.0.0') }
end end
directory "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3cores/conf" do directory "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/typo3cores/conf" do
owner node[:tomcat][:user] owner node['tomcat']['user']
group "root" group 'root'
mode 0775 mode 0775
action :create action :create
recursive true recursive true
end end
execute "copy-solr-files - #{new_resource.name}" do execute "copy-solr-files - #{new_resource.name}" do
cwd Chef::Config[:file_cache_path] 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}/" command "cp -r apache-solr-#{new_resource.solr}/example/solr/* #{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/"
creates creates
end end
new_resource.languages.each do |language| new_resource.languages.each do |language|
directory "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3cores/conf/#{language}" do directory "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/typo3cores/conf/#{language}" do
owner node[:tomcat][:user] owner node['tomcat']['user']
group "root" group 'root'
mode 0775 mode 0775
action :create action :create
end end
%w{ protwords.txt schema.xml synonyms.txt }.each do |file| %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}" source "#{ext_solr_uri}/typo3cores/conf/#{language}/#{file}"
action :create_if_missing action :create_if_missing
owner node[:tomcat][:user] owner node['tomcat']['user']
mode 0644 mode 0644
end end
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" source "#{ext_solr_uri}/typo3cores/conf/#{language}/_schema_analysis_stopwords_#{language}.json"
action :create_if_missing action :create_if_missing
owner node[:tomcat][:user] owner node['tomcat']['user']
mode 0644 mode 0644
end 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" source "#{ext_solr_uri}/typo3cores/conf/#{language}/german-common-nouns.txt"
action :create_if_missing action :create_if_missing
owner node[:tomcat][:user] owner node['tomcat']['user']
mode 0644 mode 0644
only_if { language === 'german' } only_if { language === 'german' }
end end
end end
%w{ elevate.xml general_schema_fields.xml general_schema_types.xml solrconfig.xml }.each do |file| %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}" source "#{ext_solr_uri}/typo3cores/conf/#{file}"
action :create_if_missing action :create_if_missing
owner node[:tomcat][:user] owner node['tomcat']['user']
mode 0664 mode 0664
end end
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" source "#{ext_solr_uri}/typo3cores/conf/currency.xml"
action :create_if_missing action :create_if_missing
owner node[:tomcat][:user] owner node['tomcat']['user']
mode 0644 mode 0644
only_if { Gem::Version.new(new_resource.extension) >= Gem::Version.new('2.8.0') } only_if { Gem::Version.new(new_resource.extension) >= Gem::Version.new('2.8.0') }
end 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 action :delete
end end
template "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/solr.xml" do template "#{node['typo3_solr']['solr']['solr_home']}/#{new_resource.name}/solr.xml" do
source "solr.xml.erb" source 'solr.xml.erb'
#variables(:cores => node[:typo3_solr][:cores][new_resource.extension]) #variables(:cores => node['typo3_solr'][:cores][new_resource.extension])
owner node[:tomcat][:user] owner node['tomcat']['user']
mode 0644 mode 0644
cookbook 'typo3_solr' cookbook 'typo3_solr'
end end
%w{ bin conf data }.each do |directory| %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 action :delete
recursive true recursive true
end end
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 action :delete
end end
template "#{node[:tomcat][:context_dir]}/#{new_resource.name}.xml" do template "#{node['tomcat']['context_dir']}/#{new_resource.name}.xml" do
source "tomcat_solr.xml.erb" source 'tomcat_solr.xml.erb'
variables(:app => new_resource.name) variables(:app => new_resource.name)
owner node[:tomcat][:user] owner node['tomcat']['user']
mode 0644 mode 0644
cookbook 'typo3_solr' cookbook 'typo3_solr'
end 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 action :create
mode 0775 mode 0775
end end
execute "copy-dist - #{new_resource.name}" do 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 end
execute "copy-contrib - #{new_resource.name}" do 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 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 action :create
mode 0775 mode 0775
end end
# old typo3 solr plugin # 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" source "#{plugin_uri}/solr-typo3-plugin-#{new_resource.plugin}.jar"
mode 0644 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') } only_if { Gem::Version.new(new_resource.plugin) > Gem::Version.new('0.0.0') }
end end
# new typo3-solr plugins # 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 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" source "http://www.typo3-solr.com/fileadmin/files/solr/Solr4x/solr-typo3-access-#{new_resource.plugin_access}.jar"
mode 0644 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') } only_if { Gem::Version.new(new_resource.plugin_access) > Gem::Version.new('0.0.0') }
end 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" source "http://www.typo3-solr.com/fileadmin/files/solr/Solr4x/solr-typo3-utils-#{new_resource.plugin_utils}.jar"
mode 0644 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') } only_if { Gem::Version.new(new_resource.plugin_utils) > Gem::Version.new('0.0.0') }
end 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" source "http://www.typo3-solr.com/fileadmin/files/solr/Solr4x/commons-lang3-#{new_resource.plugin_lang}.jar"
mode 0644 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') } only_if { Gem::Version.new(new_resource.plugin_lang) > Gem::Version.new('0.0.0') }
end end
# reset directory access restrictions # reset directory access restrictions
execute "chown - #{new_resource.name}" do 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 end
new_resource.updated_by_last_action(true) new_resource.updated_by_last_action(true)
end end
action :remove do action :remove do
service "tomcat" do service 'tomcat' do
service_name "tomcat6" service_name 'tomcat6'
supports :restart => true, :reload => true, :status => true supports :restart => true, :reload => true, :status => true
end 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 action :delete
recursive true recursive true
end end
file "#{node[:tomcat][:context_dir]}/#{new_resource.name}.xml" do file "#{node['tomcat']['context_dir']}/#{new_resource.name}.xml" do
action :delete action :delete
end end
file "#{node[:tomcat][:webapp_dir]}/#{new_resource.name}.war" do file "#{node['tomcat']['webapp_dir']}/#{new_resource.name}.war" do
action :delete action :delete
end end
directory "#{node[:tomcat][:webapp_dir]}/#{new_resource.name}" do directory "#{node['tomcat']['webapp_dir']}/#{new_resource.name}" do
action :delete action :delete
recursive true recursive true
notifies :restart, "service[tomcat]", :immediately notifies :restart, 'service[tomcat]', :immediately
end end
new_resource.updated_by_last_action(true) new_resource.updated_by_last_action(true)
......
use_inline_resources
action :add do action :add do
new_resource.updated_by_last_action(false) new_resource.updated_by_last_action(false)
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
include_recipe 'tomcat' include_recipe 'tomcat'
directory node[:typo3_solr][:solr][:solr_home] do directory node['typo3_solr']['solr']['solr_home'] do
owner node[:tomcat][:user] owner node['tomcat']['user']
group 'root' group 'root'
mode 0770 mode 0770
action :create action :create
......
<Context docBase="<%= @app %>.war" debug="0" crossContext="true" > <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> </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