2009-04-03 16:27:49 +00:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
|
2010-01-24 18:30:15 +00:00
|
|
|
$DEBUG = true
|
|
|
|
$VERBOSE = true
|
|
|
|
|
2011-03-07 23:52:00 +00:00
|
|
|
require 'pp'
|
2014-03-20 21:48:53 +00:00
|
|
|
require 'qasim'
|
2009-05-22 21:01:23 +00:00
|
|
|
|
2011-07-20 22:49:07 +00:00
|
|
|
module Qasim
|
2011-03-10 16:56:54 +00:00
|
|
|
|
2011-07-20 22:49:07 +00:00
|
|
|
class QasimCli
|
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 --"
|
2011-03-15 16:58:13 +00:00
|
|
|
@config = Config.new
|
|
|
|
@config.parse_cmd_line ARGV
|
|
|
|
@config.parse_file
|
|
|
|
|
|
|
|
@all_maps = {}
|
|
|
|
pp @config
|
2009-05-22 21:01:23 +00:00
|
|
|
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
|
|
|
|
|
2011-03-15 16:58:13 +00:00
|
|
|
# asynchronous mount
|
|
|
|
selected_maps = @config.maps.select do |map|
|
2011-03-07 23:52:00 +00:00
|
|
|
pp map
|
2011-03-15 16:58:13 +00:00
|
|
|
map.online?
|
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-15 16:58:13 +00:00
|
|
|
|
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
|
|
|
|
|
2011-07-20 22:49:07 +00:00
|
|
|
app = Qasim::Qasim.new
|
2009-05-22 21:01:23 +00:00
|
|
|
app.run
|
2009-04-03 16:27:49 +00:00
|
|
|
|
2011-03-07 23:25:47 +00:00
|
|
|
|