|
|
@ -2,9 +2,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
require 'optparse'
|
|
|
|
require 'optparse'
|
|
|
|
|
|
|
|
|
|
|
|
# Default to a five minute timeout
|
|
|
|
# Default to a one hour timeout
|
|
|
|
timeout = 5
|
|
|
|
timeout = 1
|
|
|
|
unit = ?M
|
|
|
|
unit = ?H
|
|
|
|
|
|
|
|
|
|
|
|
OptionParser.new do |opts|
|
|
|
|
OptionParser.new do |opts|
|
|
|
|
opts.banner = "Usage: #{__FILE__} [options]"
|
|
|
|
opts.banner = "Usage: #{__FILE__} [options]"
|
|
|
@ -20,10 +20,11 @@ def with_mount(image)
|
|
|
|
mountpoint = out.split(/\s+/).last
|
|
|
|
mountpoint = out.split(/\s+/).last
|
|
|
|
yield mountpoint
|
|
|
|
yield mountpoint
|
|
|
|
ensure
|
|
|
|
ensure
|
|
|
|
puts `hdiutil unmount "#{mountpoint}"`
|
|
|
|
puts `hdiutil detach "#{mountpoint}"`
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
keyz = File.expand_path("../keyz.sparsebundle", __FILE__)
|
|
|
|
keyz = File.expand_path("../keyz.sparsebundle", __FILE__)
|
|
|
|
with_mount(keyz) do |mountpoint|
|
|
|
|
with_mount(keyz) do |mountpoint|
|
|
|
|
`ssh-add -t #{timeout}#{unit} "#{File.join(mountpoint, "id_rsa")}"`
|
|
|
|
`ssh-add -t #{timeout}#{unit} "#{File.join(mountpoint, "id_rsa")}"`
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# `hdiutil eject "#{File.dirname(__FILE__)}"`
|
|
|
|