diff --git a/recipes/source.rb b/recipes/source.rb index 79dff2b..8f20504 100644 --- a/recipes/source.rb +++ b/recipes/source.rb @@ -23,7 +23,8 @@ install_prefix = node['redis']['source']['prefix'] tar_url = node['redis']['source']['tar_url'] tar_checksum = node['redis']['source']['tar_checksum'] -tar_file = "redis-#{node['redis']['source']['version']}.tar.gz" +redis_version = node['redis']['source']['version'] +tar_file = "redis-#{redis_version}.tar.gz" tar_dir = tar_file.sub(/\.tar\.gz$/, '') port = node['redis']['port'] redis_user = node['redis']['source']['user'] @@ -50,9 +51,17 @@ execute "Build #{tar_dir.split('/').last}" do cwd "#{cache_dir}/#{tar_dir}" - command %{make prefix=#{install_prefix} install} + command %{ + make prefix=#{install_prefix} install + mv "#{install_prefix}/bin/redis-server" "#{install_prefix}/bin/redis-server-#{redis_version}" + } - creates "#{install_prefix}/bin/redis-server" + creates "#{install_prefix}/bin/redis-server-#{redis_version}" +end + +execute "rm -f #{install_prefix}/bin/redis-server" +link "#{install_prefix}/bin/redis-server" do + to "#{install_prefix}/bin/redis-server-#{redis_version}" end group redis_group @@ -77,18 +86,23 @@ execute "Install redis-server init.d script" do command <<-COMMAND - cp #{cache_dir}/#{tar_dir}/utils/redis_init_script /etc/init.d/redis + cp #{cache_dir}/#{tar_dir}/utils/redis_init_script /etc/init.d/redis-#{redis_version} COMMAND - creates "/etc/init.d/redis" + creates "/etc/init.d/redis-#{redis_version}" end - file "/etc/init.d/redis" do + file "/etc/init.d/redis-#{redis_version}" do owner "root" group "root" mode "0755" end + execute "rm -f /etc/init.d/redis" + link "/etc/init.d/redis" do + to "/etc/init.d/redis-#{redis_version}" + end + service "redis" do supports :status => false, :restart => false, :reload => false action :enable @@ -105,6 +119,7 @@ owner "root" group "root" mode "0644" + variables({:version => node['redis']['source']['version']}) notifies :restart, "service[redis]" end diff --git a/templates/default/redis.conf.erb b/templates/default/redis.conf.erb index 5744e65..2c54544 100644 --- a/templates/default/redis.conf.erb +++ b/templates/default/redis.conf.erb @@ -1,4 +1,7 @@ # Redis configuration file example +<% if @version %> +# Configuration of redis version <%= @version %> +<% end %> # By default Redis does not run as a daemon. Use 'yes' if you need it. # Note that Redis will write a pid file in /var/run/redis.pid when daemonized. @@ -149,7 +152,7 @@ requirepass <%= node['redis']['password'] %> appendonly no # The fsync() call tells the Operating System to actually write data on disk -# instead to wait for more data in the output buffer. Some OS will really flush +# instead to wait for more data in the output buffer. Some OS will really flush # data on disk, some other OS will just try to do it ASAP. # # Redis supports three different modes: @@ -173,7 +176,7 @@ appendfsync always # Glue small output buffers together in order to send small replies in a # single TCP packet. Uses a bit more CPU but most of the times it is a win # in terms of number of queries per second. Use 'yes' if unsure. -glueoutputbuf yes +# glueoutputbuf yes # Use object sharing. Can save a lot of memory if you have many common # string in your dataset, but performs lookups against the shared objects