From 9831c34adedc8adb075cba97a421e2a62d0c73f5 Mon Sep 17 00:00:00 2001 From: Dibayendu Dey Date: Sun, 28 Sep 2014 14:55:36 +1000 Subject: [PATCH 1/4] Cookbook for installing firefox versions This cookbook can be used in Linux Gentoo to install firefox versions. To know more, read the README.md file --- cookbooks/firefox/README.md | 15 +++++++ cookbooks/firefox/attributes/default.rb | 16 +++++++ cookbooks/firefox/recipes/default.rb | 60 +++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 cookbooks/firefox/README.md create mode 100644 cookbooks/firefox/attributes/default.rb create mode 100644 cookbooks/firefox/recipes/default.rb diff --git a/cookbooks/firefox/README.md b/cookbooks/firefox/README.md new file mode 100644 index 00000000..52f3a662 --- /dev/null +++ b/cookbooks/firefox/README.md @@ -0,0 +1,15 @@ +Firefox versions +========= + +####Compatible with Linux Gentoo. +Downloads firefox zip files in home directory, extracts them and sym links files. + +Attributes +---- +In attributes/default.rb file add the firefox versions you want to extract from [firefox ftp url]. Add the sha1 checksum in the file. + +Recipes +---- +Default recipe downloads the default firefox version and other firefox versions mentioned in the default attributes file, them symlinks them with /usr/bin/firefox#{version}. The default version is also symlinked with /usr/bin/firefox. + +[firefox ftp url]:http://ftp.mozilla.org/pub/mozilla.org/firefox/releases diff --git a/cookbooks/firefox/attributes/default.rb b/cookbooks/firefox/attributes/default.rb new file mode 100644 index 00000000..5a1654d4 --- /dev/null +++ b/cookbooks/firefox/attributes/default.rb @@ -0,0 +1,16 @@ +default[:firefox]["28"] = { + :url => "http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/28.0/linux-x86_64/en-US/firefox-28.0.tar.bz2", + :filename => "firefox-28.0.tar.bz2", + :sha => "c032902b548a6e22a5ec74fda376ca76", + :firefox_dir => 'firefox' +} + +default[:firefox]["32"] = { + :url => "http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/32.0/linux-x86_64/en-US/firefox-32.0.tar.bz2", + :filename => "firefox-32.0.tar.bz2", + :sha => "53410cf0944d4d7136130e03cf1b58b7dc181007", + :firefox_dir => 'firefox' +} + +default[:firefox][:default_version] = "28" +default[:firefox][:other_versions] = ["32"] diff --git a/cookbooks/firefox/recipes/default.rb b/cookbooks/firefox/recipes/default.rb new file mode 100644 index 00000000..eb353a72 --- /dev/null +++ b/cookbooks/firefox/recipes/default.rb @@ -0,0 +1,60 @@ +# +# Cookbook Name:: firefox +# Recipe:: default +# + +if ['app_master', 'app', 'solo', 'util'].include?(node[:instance_role]) + + # firefox-bin packages are required to run firefox + package "www-client/firefox-bin" + package "www-client/firefox-bin" do + action :upgrade + end + + dir_path = "/home/firefoxes" + + directory dir_path do + owner "root" + mode "0755" + action :create + end + + # all the firefox versions which needs to be downloaded and extracted + firefox_default_version = node[:firefox][:default_version] + # all the firefox versions which need to be downloaded and installed + node[:firefox][:versions] = firefox_default_version | node[:firefox][:other_versions] + node[:firefox][:versions].each do |firefox_version| + directory "#{dir_path}/#{firefox_version}" do + owner "root" + mode "0755" + action :create + end + + firefox = node[:firefox][firefox_version] + firefox_version_path = "#{dir_path}/#{firefox_version}" + tar_file = "#{firefox_version_path}/#{firefox[:filename]}" + + remote_file tar_file do + owner "root" + source firefox[:url] + checksum firefox[:sha] + action :create_if_missing + end + + bash "untar firefox-#{firefox_version} to #{dir_path}" do + cwd firefox_version_path + code <<-EOH + tar jxf #{tar_file} + EOH + end + + link "/usr/bin/firefox#{firefox_version}" do + to"#{firefox_version_path}/#{firefox[:firefox_dir]}/firefox" + end + end + + # the default firefox version is sym linked + link "/usr/bin/firefox" do + to"/usr/bin/firefox#{firefox_default_version}" + end +end From 860e1567d3db1ffc5e3915ed0138383a9d0c21cd Mon Sep 17 00:00:00 2001 From: Dibayendu Dey Date: Sun, 28 Sep 2014 15:02:24 +1000 Subject: [PATCH 2/4] changed owner from root to node[:owner_name] --- cookbooks/firefox/recipes/default.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cookbooks/firefox/recipes/default.rb b/cookbooks/firefox/recipes/default.rb index eb353a72..df92aaae 100644 --- a/cookbooks/firefox/recipes/default.rb +++ b/cookbooks/firefox/recipes/default.rb @@ -12,9 +12,10 @@ end dir_path = "/home/firefoxes" + user = node[:owner_name] directory dir_path do - owner "root" + owner user mode "0755" action :create end @@ -25,7 +26,7 @@ node[:firefox][:versions] = firefox_default_version | node[:firefox][:other_versions] node[:firefox][:versions].each do |firefox_version| directory "#{dir_path}/#{firefox_version}" do - owner "root" + owner user mode "0755" action :create end @@ -35,7 +36,7 @@ tar_file = "#{firefox_version_path}/#{firefox[:filename]}" remote_file tar_file do - owner "root" + owner user source firefox[:url] checksum firefox[:sha] action :create_if_missing From 0e11c58604adc6f07bbec0154601b2590920f88f Mon Sep 17 00:00:00 2001 From: Dibayendu Dey Date: Wed, 8 Oct 2014 11:50:59 +1100 Subject: [PATCH 3/4] linking firefox-bin correctly and merging array properly made a mistake earlier with simple code for merging two arrays --- cookbooks/firefox/recipes/default.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cookbooks/firefox/recipes/default.rb b/cookbooks/firefox/recipes/default.rb index df92aaae..f4e1cd1f 100644 --- a/cookbooks/firefox/recipes/default.rb +++ b/cookbooks/firefox/recipes/default.rb @@ -23,7 +23,7 @@ # all the firefox versions which needs to be downloaded and extracted firefox_default_version = node[:firefox][:default_version] # all the firefox versions which need to be downloaded and installed - node[:firefox][:versions] = firefox_default_version | node[:firefox][:other_versions] + node[:firefox][:versions] = [firefox_default_version] | node[:firefox][:other_versions] node[:firefox][:versions].each do |firefox_version| directory "#{dir_path}/#{firefox_version}" do owner user @@ -52,10 +52,18 @@ link "/usr/bin/firefox#{firefox_version}" do to"#{firefox_version_path}/#{firefox[:firefox_dir]}/firefox" end + + link "/usr/bin/firefox-bin#{firefox_version}" do + to"#{firefox_version_path}/#{firefox[:firefox_dir]}/firefox-bin" + end end # the default firefox version is sym linked link "/usr/bin/firefox" do to"/usr/bin/firefox#{firefox_default_version}" end + + link "/usr/bin/firefox-bin" do + to"/usr/bin/firefox-bin#{firefox_default_version}" + end end From 64152ec8f68a560205c7f15af7f0921ecae21dea Mon Sep 17 00:00:00 2001 From: Dibayendu Dey Date: Wed, 8 Oct 2014 11:53:20 +1100 Subject: [PATCH 4/4] added include_recipe to the main cookbook for including firefox --- cookbooks/main/recipes/default.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cookbooks/main/recipes/default.rb b/cookbooks/main/recipes/default.rb index 8a9242a8..7cf0dd80 100644 --- a/cookbooks/main/recipes/default.rb +++ b/cookbooks/main/recipes/default.rb @@ -158,3 +158,6 @@ # postgresql9_pg_buffercache "postgres" # postgresql9_pg_freespacemap "postgres" # end +# +#uncomment to include the firefox recipe +#include_recipe "firefox"