Sha256: 6084f9fb247d28eb449c7dea22b161ba9632157e574d2709c2ae49849ca3407a

Contents?: true

Size: 1.81 KB

Versions: 3

Compression:

Stored size: 1.81 KB

Contents

#
# Cookbook Name:: nginx
# Recipe:: pagespeed_module
#

src_filename = ::File.basename(node['nginx']['pagespeed']['url'])
src_filepath = "#{Chef::Config['file_cache_path']}/#{src_filename}"
extract_path = "#{Chef::Config['file_cache_path']}/nginx_pagespeed-#{node['nginx']['pagespeed']['version']}"

remote_file src_filepath do
  source   node['nginx']['pagespeed']['url']
  owner    'root'
  group    node['root_group']
  mode     '0644'
  not_if { ::File.exist?(src_filepath) }
end

psol_src_filename = "psol-#{::File.basename(node['nginx']['psol']['url'])}"
psol_src_filepath = "#{Chef::Config['file_cache_path']}/#{psol_src_filename}"
psol_extract_path = "#{Chef::Config['file_cache_path']}/nginx_pagespeed-#{node['nginx']['pagespeed']['version']}/psol"

remote_file psol_src_filepath do
  source   node['nginx']['psol']['url']
  owner    'root'
  group    node['root_group']
  mode     '0644'
  not_if { ::File.exist?(psol_src_filepath) }
end

packages = value_for_platform_family(
    %w(rhel)   => node['nginx']['pagespeed']['packages']['rhel'],
    %w(debian) => node['nginx']['pagespeed']['packages']['debian']
)

unless packages.empty?
  packages.each do |name|
    package name
  end
end

bash 'extract_pagespeed' do
  cwd  ::File.dirname(src_filepath)
  code <<-EOH
    mkdir -p #{extract_path}
    tar xzf #{src_filename} -C #{extract_path}
    mv #{extract_path}/*/* #{extract_path}/
  EOH
  not_if { ::File.exist?(extract_path) }
end

bash 'extract_psol' do
  cwd  ::File.dirname(psol_src_filepath)
  code <<-EOH
    mkdir -p #{psol_extract_path}
    tar xzf #{psol_src_filename} -C #{psol_extract_path}
    mv #{psol_extract_path}/*/* #{psol_extract_path}/
  EOH
  not_if { ::File.exist?(psol_extract_path) }
end

node.run_state['nginx_configure_flags'] =
  node.run_state['nginx_configure_flags'] | ["--add-module=#{extract_path}"]

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
from-scratch-0.7.0 cookbooks/nginx/recipes/pagespeed_module.rb
from-scratch-0.6.0 cookbooks/nginx/recipes/pagespeed_module.rb
from-scratch-0.5.0 cookbooks/nginx/recipes/pagespeed_module.rb