Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[COOK-1222] Change the defaults to download the 'latest' archive by d…

…efault, adjust recipe to handle.
  • Loading branch information...
commit 5bba642b8f539c7777b46bf7ffd50128528653c7 1 parent 5c52dcd
@lewg lewg authored
Showing with 22 additions and 8 deletions.
  1. +2 −2 README.md
  2. +2 −2 attributes/default.rb
  3. +18 −4 recipes/default.rb
View
4 README.md
@@ -26,8 +26,8 @@ Cookbooks
Attributes
==========
-* `node['wordpress']['version']` - Set the version to download.
-* `node['wordpress']['checksum']` - sha256sum of the tarball, make sure this matches for the version!
+* `node['wordpress']['version']` - Set the version to download. Using 'latest' (the default) will install the most current version.
+* `node['wordpress']['checksum']` - sha256sum of the tarball, make sure this matches for the version! (Not used for 'latest' version.)
* `node['wordpress']['dir']` - Set the location to place wordpress files. Default is /var/www.
* `node['wordpress']['db']['database']` - Wordpress will use this MySQL database to store its data.
* `node['wordpress']['db']['user']` - Wordpress will connect to MySQL using this user.
View
4 attributes/default.rb
@@ -19,8 +19,8 @@
#
# General settings
-default['wordpress']['version'] = "3.3.1"
-default['wordpress']['checksum'] = "e884db6e551c155f022533b6653867b048088cd3cbcbfe546b404696dd960dc2"
+default['wordpress']['version'] = "latest"
+default['wordpress']['checksum'] = ""
default['wordpress']['dir'] = "/var/www/wordpress"
default['wordpress']['db']['database'] = "wordpressdb"
default['wordpress']['db']['user'] = "wordpressuser"
View
22 recipes/default.rb
@@ -35,10 +35,24 @@
node.set['wordpress']['keys']['logged_in'] = secure_password
node.set['wordpress']['keys']['nonce'] = secure_password
-remote_file "#{Chef::Config[:file_cache_path]}/wordpress-#{node['wordpress']['version']}.tar.gz" do
- checksum node['wordpress']['checksum']
- source "http://wordpress.org/wordpress-#{node['wordpress']['version']}.tar.gz"
- mode "0644"
+
+if node['wordpress']['version'] == 'latest'
+ # WordPress.org does not provide a sha256 checksum, so we'll use the sha1 they do provide
+ require 'digest/sha1'
+ require 'open-uri'
+ local_file = "#{Chef::Config[:file_cache_path]}/wordpress-latest.tar.gz"
+ latest_sha1 = open('http://wordpress.org/latest.tar.gz.sha1') {|f| f.read }
+ unless File.exists?(local_file) && ( Digest::SHA1.hexdigest(File.read(local_file)) == latest_sha1 )
+ remote_file "#{Chef::Config[:file_cache_path]}/wordpress-latest.tar.gz" do
+ source "http://wordpress.org/latest.tar.gz"
+ mode "0644"
+ end
+ end
+else
+ remote_file "#{Chef::Config[:file_cache_path]}/wordpress-#{node['wordpress']['version']}.tar.gz" do
+ source "http://wordpress.org/wordpress-#{node['wordpress']['version']}.tar.gz"
+ mode "0644"
+ end
end
directory "#{node['wordpress']['dir']}" do
Please sign in to comment.
Something went wrong with that request. Please try again.