Code:
#!/usr/bin/python
import os
import sys
import getopt
host = '10.37.129.2'
mount_points = [('/Users/dave/Music', '/home/dave/Music'),
('/Users/dave/Documents', '/home/dave/Documents'),
('/Users/dave/Pictures', '/home/dave/Pictures')]
def main(argv=None):
if argv is None:
argv = sys.argv
try:
opts, args = getopt.getopt(argv[1:], 'u', ['unmount'])
except getopt.error, msg:
print msg
print 'for help use --help'
sys.exit(2)
mount_op = mount
for option, a in opts:
if option in ('-u', '--unmount'):
mount_op = unmount
mount_op()
return 0
def mount():
argv = ['/usr/bin/sshfs', None, None]
for mount in mount_points:
argv[1] = '%s:%s' % (host, mount[0])
argv[2] = mount[1]
cmd = ' '.join(argv)
print cmd
os.system(cmd)
def unmount():
argv = ['/usr/bin/fusermount', '-u', None]
for mount in mount_points:
argv[2] = mount[1]
cmd = ' '.join(argv)
print cmd
os.system(cmd)
if __name__ == '__main__':
sys.exit(main())
I save this as ~/bin/mount_sshfs and change its permissions to be executable. Whenever I login to Ubuntu, my OS X folder /Users/dave/Music is available in Ubuntu as /home/dave/Music.