Created
August 12, 2015 23:12
-
-
Save shadeslayer/5d1cfcdf4bcddf3ae11d to your computer and use it in GitHub Desktop.
Mount things inside of other things
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'tmpdir' | |
class Mount | |
def self.mount(path) | |
@mntdir = Dir.mktmpdir | |
fail 'Mounting boot partition failed!' unless system('sudo', | |
'mount', | |
path, | |
@mntdir) | |
puts "Mounted #{path} on #{@mntdir}" | |
yield @mntdir | |
ensure | |
puts "Unmounting #{path}" | |
system('sudo', | |
'umount', | |
@mntdir) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment