diff --git a/.gitignore b/.gitignore index 82d1b5c..71fdee5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .kitchen/ .kitchen.local.yml +/nbproject/ \ No newline at end of file diff --git a/Berksfile b/Berksfile new file mode 100644 index 0000000..20281f2 --- /dev/null +++ b/Berksfile @@ -0,0 +1,6 @@ +source "https://supermarket.getchef.com" + +metadata + +cookbook 'rc_mon' +cookbook 'bluepill' \ No newline at end of file diff --git a/README.md b/README.md index 7c32d7b..1f760f1 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Usage ```ruby override_attributes( - 's3fs-fuse' => { + 's3fs_fuse' => { :s3_key => 'key', :s3_secret => 'secret', :mounts => [ diff --git a/attributes/default.rb b/attributes/default.rb index cb87847..52f1564 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,7 +1,7 @@ default[:s3fs_fuse][:s3_url] = 'https://s3.amazonaws.com' default[:s3fs_fuse][:s3_key] = '' default[:s3fs_fuse][:s3_secret] = '' -default[:s3fs_fuse][:version] = '1.61' +default[:s3fs_fuse][:version] = '1.78' default[:s3fs_fuse][:no_upload] = false default[:s3fs_fuse][:mounts] = [] default[:s3fs_fuse][:bluepill] = false @@ -9,3 +9,5 @@ default[:s3fs_fuse][:maxmemory] = 100 default[:s3fs_fuse][:fuse_mirror] = 'voxel' default[:s3fs_fuse][:packages] = [] +default[:s3fs_fuse][:force_install] = false +default[:s3fs_fuse][:version_file] = '/etc/s3fs_fuse_version' diff --git a/metadata.rb b/metadata.rb index 4d2f820..ce8b7c9 100644 --- a/metadata.rb +++ b/metadata.rb @@ -6,5 +6,5 @@ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version "0.1.4" -suggests 'bluepill' +depends 'bluepill' depends 'rc_mon' diff --git a/recipes/default.rb b/recipes/default.rb index 604708d..651902e 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -16,7 +16,38 @@ end end -include_recipe "s3fs-fuse::install" +def s3fs_fuse_installed() + + # Is s3fs installed? + if !`which s3fs`.empty? && $? == 0 + return true # No + end + + return false # Yes +end + +def s3fs_fuse_diff_version( check_against ) + + if !s3fs_fuse_installed() + return true + end + + if File.exists?( node[:s3fs_fuse][:version_file] ) + installed_version = File.open( node[:s3fs_fuse][:version_file], &:gets ) + if installed_version.empty? || installed_version != check_against + # Not properly installed by this script or version is different + return true + end + end + + # s3fs is installed and is the correct version + return false +end + +# Should I run install? +if node[:s3fs_fuse][:force_install] || s3fs_fuse_diff_version( node[:s3fs_fuse][:version] ) + include_recipe "s3fs-fuse::install" +end if(node[:s3fs_fuse][:bluepill]) include_recipe 's3fs-fuse::bluepill' diff --git a/recipes/install.rb b/recipes/install.rb index 86b4dfb..8681f95 100644 --- a/recipes/install.rb +++ b/recipes/install.rb @@ -11,31 +11,30 @@ mode 0600 end -prereqs = case node.platform_family -when 'debian' - %w( - build-essential - libfuse-dev - fuse-utils - libcurl4-openssl-dev - libxml2-dev - mime-support - ) -when 'rhel' - %w( - gcc - libstdc++-devel - gcc-c++ - curl-devel - libxml2-devel - openssl-devel - mailcap - fuse - fuse-devel - fuse-libs - ) -else - raise "Unsupported platform family provided: #{node.platform_family}" +prereqs = [] + +case node.platform_family + when 'debian' + prereqs.push( + 'build-essential', 'libfuse-dev', 'libcurl4-openssl-dev', 'libxml2-dev', + 'mime-support' + ) + # As of Ubuntu 14.04 "fuse-utils" has been merged into package "fuse" + # so try to install both (auto-installed by fuse-utils in older) + %x(apt-cache show fuse-utils 2>&1 1>/dev/null) + if( $? == 0 ) then + prereqs.push( 'fuse-utils' ) + else + prereqs.push( 'fuse' ) + end + when 'rhel' + prereqs.push( + 'gcc', 'libstdc++-devel', 'gcc-c++', 'curl-devel', 'libxml2-devel', + 'libxml2-devel', 'openssl-devel', 'mailcap', 'fuse', 'fuse-devel', + 'fuse-libs' + ) + else + raise "Unsupported platform family provided: #{node.platform_family}" end prereqs = node[:s3fs_fuse][:packages] unless node[:s3fs_fuse][:packages].empty? @@ -45,7 +44,7 @@ end s3fs_version = node[:s3fs_fuse][:version] -source_url = "http://s3fs.googlecode.com/files/s3fs-#{s3fs_version}.tar.gz" +source_url = "https://github.com/s3fs-fuse/s3fs-fuse/archive/v#{s3fs_version}.tar.gz" remote_file "/tmp/s3fs-#{s3fs_version}.tar.gz" do source source_url @@ -55,9 +54,11 @@ bash "compile_and_install_s3fs" do cwd '/tmp' code <<-EOH - tar -xzf s3fs-#{s3fs_version}.tar.gz - cd s3fs-#{s3fs_version} + mkdir ./s3fs-#{s3fs_version} + tar -xzf s3fs-#{s3fs_version}.tar.gz -C ./s3fs-#{s3fs_version} + cd ./s3fs-#{s3fs_version}/* #{'export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib64/pkgconfig' if node.platform_family == 'rhel'} + ./autogen.sh ./configure --prefix=/usr/local make && make install EOH @@ -68,7 +69,7 @@ false end end - if(node[:s3fs_fuse][:bluepill] && File.exists?(File.join(node[:bluepill][:conf_dir], 's3fs.pill'))) + if(node[:s3fs_fuse][:bluepill].kind_of?(Array) && File.exists?(File.join(node[:s3fs_fuse][:bluepill][:conf_dir], 's3fs.pill'))) notifies :stop, 'bluepill_service[s3fs]' notifies :start, 'bluepill_service[s3fs]' end @@ -83,3 +84,7 @@ system('cat /boot/config-`uname -r` | grep -P "^CONFIG_FUSE_FS=y$" > /dev/null') } end + +template node[:s3fs_fuse][:version_file] do + mode 0655 +end diff --git a/templates/default/s3fs_fuse_version b/templates/default/s3fs_fuse_version new file mode 100644 index 0000000..081383d --- /dev/null +++ b/templates/default/s3fs_fuse_version @@ -0,0 +1 @@ +<%= node[:s3fs_fuse][:version] %> \ No newline at end of file