lib/kuzushi.rb in kuzushi-0.0.15 vs lib/kuzushi.rb in kuzushi-0.0.16
- old
+ new
@@ -109,11 +109,10 @@
shell "gem install #{gem} --no-rdoc --no-ri"
end
end
def process_volumes(v)
- handle_tmpfs v if v.media == "tmpfs"
handle_ebs v if v.media == "ebs"
handle_raid v if v.media == "raid"
set_readahead v if v.readahead
set_scheduler v if v.scheduler
handle_format v if v.format
@@ -147,20 +146,15 @@
o << "mode=#{m.mode}" if m.mode
o << "noatime" if o.empty?
o.join(",")
end
- def handle_tmpfs(m)
- m.format ||= "tmpfs"
- m.device ||= "tmpfs"
- end
-
def handle_mount(m)
task "mount #{m.mount}" do
unless mounted?(m.mount)
shell "mv #{m.mount} #{m.mout}.old" if File.exists?(m.mount)
- shell "mkdir -p #{m.mount} && mount -o #{mount_options(m)} -t #{m.format} #{m.device} #{m.mount}"
+ shell "mkdir -p #{m.mount} && mount -o #{mount_options(m)} -t #{m.format || m.media} #{m.device || m.media} #{m.mount}"
shell "chown -R #{m.user}:#{m.group} #{m.mount}" if m.user or m.group
end
end
end
@@ -181,11 +175,11 @@
def process_files(f)
if f.template
write_file("/templates/#{f.template}", f.file) do |file|
@system = system
t = ERB.new File.read(file), 0, '<>'
- t.result(binding))
+ t.result(binding)
end
else
src = f.source || File.basename(f.file)
write_file("/files/#{src}", f.file) do |file|
File.read(file)
@@ -194,11 +188,11 @@
end
def write_file(src, dest, &blk)
fetch(src) do |file|
FileUtils.mkdir_p(File.dirname(dest))
- File.open(f.file,"w") { |f| f.write(blk.call) }
+ File.open(dest,"w") { |f| f.write(blk.call(file)) }
end
end
def process_users(user)
(user.authorized_keys || []).each do |key|
@@ -219,13 +213,14 @@
shell "echo #{v.scheduler} > /sys/block/#{File.basename(v.device)}/queue/scheduler"
end
end
def handle_format(v)
+ return if v.format == "tmpfs"
task "formatting #{v.device}", :init => true do
label = "-L " + v.label rescue ""
- shell "mkfs.#{v.format} #{label} #{v.device}"
+ shell "mkfs.#{v.format} #{label} #{v.device}" unless v.mount && mounted?(v.mount)
end
add_package "xfsprogs" if v.format == "xfs"
end
def add_package(p)
@@ -305,10 +300,10 @@
end
end
def shell(cmd)
puts "# #{cmd}"
- puts Rush.bash cmd
+ puts Kernel.system cmd ## FIXME - need to handle/report exceptions here
end
def init?
@init ||= false
end