2009-04-03 16:27:49 +00:00
|
|
|
#!/usr/bin/ruby
|
2009-09-19 23:51:18 +00:00
|
|
|
# vim: set ts=2 sw=2 :
|
2009-04-03 16:27:49 +00:00
|
|
|
|
2010-01-24 18:30:15 +00:00
|
|
|
$DEBUG = true
|
|
|
|
$VERBOSE = true
|
|
|
|
|
2011-03-07 23:52:00 +00:00
|
|
|
require 'pp'
|
2011-03-07 23:25:47 +00:00
|
|
|
require 'sshfs-mapper/config'
|
|
|
|
require 'sshfs-mapper/map'
|
2009-05-22 21:01:23 +00:00
|
|
|
|
|
|
|
module SshfsMapper
|
2011-03-10 16:56:54 +00:00
|
|
|
|
2009-05-22 21:01:23 +00:00
|
|
|
class SshfsMapper
|
2011-03-10 16:56:54 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
2011-03-07 23:25:47 +00:00
|
|
|
def initialize
|
2011-03-10 16:56:54 +00:00
|
|
|
@all_maps = nil
|
2009-12-14 23:56:06 +00:00
|
|
|
@active_maps = nil
|
2011-03-10 16:56:54 +00:00
|
|
|
|
2009-05-22 21:01:23 +00:00
|
|
|
puts "-- sshfs-mapper --"
|
|
|
|
conf = Config.new
|
2011-03-07 23:25:47 +00:00
|
|
|
conf.parse_cmd_line ARGV
|
2011-03-10 16:56:54 +00:00
|
|
|
@all_maps = conf.parse_file
|
2009-05-22 21:01:23 +00:00
|
|
|
puts conf
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2011-03-10 16:56:54 +00:00
|
|
|
# create default map for each selected map
|
|
|
|
# or default.map if none selected
|
|
|
|
def run_init
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_mount
|
|
|
|
|
|
|
|
selected_maps = if @config.all_maps @all_maps
|
|
|
|
|
|
|
|
@all_maps.each do |map|
|
2011-03-07 23:52:00 +00:00
|
|
|
pp map
|
2011-03-10 16:56:54 +00:00
|
|
|
# if map.available? then
|
|
|
|
# map.connect!
|
|
|
|
# end
|
2009-05-22 21:01:23 +00:00
|
|
|
end
|
2011-03-10 16:56:54 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def run_umount
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
def run
|
|
|
|
case @config.action
|
|
|
|
when Config::ACTION_INIT
|
|
|
|
run_init
|
|
|
|
when Config::ACTION_MOUNT
|
|
|
|
run_mount
|
|
|
|
when Config::ACTION_UMOUNT
|
|
|
|
run_umount
|
|
|
|
else
|
|
|
|
raise RuntimeError, "Unknown action"
|
|
|
|
end
|
|
|
|
|
2009-05-22 21:01:23 +00:00
|
|
|
puts "--run"
|
|
|
|
end
|
2009-04-03 16:27:49 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-05-22 21:01:23 +00:00
|
|
|
app = SshfsMapper::SshfsMapper.new
|
|
|
|
app.run
|
2009-04-03 16:27:49 +00:00
|
|
|
|
2011-03-07 23:25:47 +00:00
|
|
|
|