Skip to content

Instantly share code, notes, and snippets.

@julik
Created October 7, 2012 13:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julik/3848380 to your computer and use it in GitHub Desktop.
Save julik/3848380 to your computer and use it in GitHub Desktop.
Manually mount HFS shares on OSX
#!/usr/bin/env ruby
require 'fileutils'
MOUNTZ = %w(
some-server.company.local:/mnt/raiddisk/commercial /mnt/commercial
)
SERVERS = Hash[*MOUNTZ]
MAGIC_OPTS = %w( soft resvport intr rsize=8192 wsize=8192 timeo=900 retrans=3 proto=tcp )
def unmount
SERVERS.each_value do | mountpoint |
`sudo umount #{mountpoint}`
# Make sure the mountpoint is removed for the next launch
FileUtils.rmdir(mountpoint) if File.exist?(mountpoint)
end
end
def mount
unmount
SERVERS.each_pair do | host, mountpoint |
FileUtils.mkdir_p(mountpoint)
# Make sure its mega-writable
File.chmod(0777, mountpoint)
`sudo mount -t nfs -o #{MAGIC_OPTS.join(',')} #{host} #{mountpoint}`
end
end
if ARGV.to_s.include?("unmount")
unmount
else
unmount
mount
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment