lib/kuzushi.rb in kuzushi-0.0.11 vs lib/kuzushi.rb in kuzushi-0.0.12

- old
+ new

@@ -136,22 +136,46 @@ end end add_package "mdadm" end + def mount_options(m) + o = [] + o << m.options if m.options + o << "size=#{m.size}M" if m.size and s.media == "tmpfs" + o << "mode=#{m.mode}" if m.mode + o << "noatime" if o.empty? + o + end + + def handle_mount_tmpfs(m) + task "mount #{m.mount}" do + shell "mkdir -p #{m.mount} && mount -o #{mount_options(m)} -t tmpfs tmpfs #{m.mount}" unless mounted?(m.mount) + end + end + + def handle_mount_device(m) + task "mount #{m.mount}" do + shell "mkdir -p #{m.mount} && mount -o #{mount_options(m)} #{m.device} #{m.mount}" unless mounted?(m.mount) + end + end + def handle_mount(m) - task "mount #{m.device}" do - shell "mkdir -p #{m.mount} && mount -o #{m.options || "noatime"} #{m.device} #{m.mount}" unless mounted?(m.device) + case m.media + when "tmpfs" then handle_mount_tmpfs(m) + else handle_mount_device(m) end end def system_arch system.kernel["machine"] end - def mounted?(dev) - !!system.filesystem[File.basename(dev)]["mount"] rescue false + def mounted?(mount) + ## cant use ohai here b/c it mashes drives together with none or tmpfs devices + mount = mount.chop if mount =~ /\/$/ + !!(File.read("/proc/mounts") =~ / #{mount} /) end def package_arch `dpkg --print-architecture`.chomp end @@ -236,9 +260,10 @@ end def fetch(file, &block) names = @config_names.clone begin + ## its important that we try each name for the script - allows for polymorphic scripts tmpfile RestClient.get("#{@base_url}/#{names.first}#{file}"), file do |tmp| block.call(tmp) end rescue RestClient::ResourceNotFound names.shift