From 5fab5ea8b51d39864475d4c9227c91790388ada0 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Thu, 21 Jul 2011 15:50:57 +0000 Subject: [PATCH] sshfs-mapper qasim-gui: Connect on click. git-svn-id: https://websvn.glenux.net/svn/Upoc/sshfs-mapper/trunk@1707 eaee96b3-f302-0410-b096-c6cfd47f7835 --- bin/qasim-gui.rb | 1 + qasim/map.rb | 33 +++++++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/bin/qasim-gui.rb b/bin/qasim-gui.rb index d7feebe..4cc20ab 100755 --- a/bin/qasim-gui.rb +++ b/bin/qasim-gui.rb @@ -79,6 +79,7 @@ module Qasim itemx.setCheckable true; itemx.connect(SIGNAL(:triggered)) do puts "%s => %s" % [name, itemx.checked ] + map.connect end menu.addAction itemx; end diff --git a/qasim/map.rb b/qasim/map.rb index 6a3904e..b77aa3f 100644 --- a/qasim/map.rb +++ b/qasim/map.rb @@ -12,14 +12,13 @@ module Qasim :user, :map - class MapParseError < RuntimeError - end + class MapParseError < RuntimeError ; end + class ConnectError < RuntimeError ; end CYPHER_ARCFOUR = :arcfour CYPHER_AES256CBC = "aes-256-cbc".to_sym CYPHERS = [ CYPHER_ARCFOUR, CYPHER_AES256CBC ] - def initialize map_path @path = map_path @host = nil @@ -99,10 +98,36 @@ module Qasim def connect puts "[#{File.basename @path}] Connecting..." puts " #{@user}@#{@host}:#{@port}" - puts " maps = %s" % @maps.map{ |k,v| "%s => %s" % [ k, v ] }.join(', ') + #puts " maps = %s" % @maps.map{ |k,v| "%s => %s" % [ k, v ] }.join(', ') # do something # test server connection # mount + # + # FIXME: test connexion with Net::SSH + timeout or ask password + @maps.each do |name, remotepath| + pp map + cmd = [ "sshfs" , + "-o allow_root" , + "-o idmap=user" , + "-o uid=%s" % Process.uid, + "-o gid=%s" % Process.gid, + "-o reconnect", + "-o workaround=all", + "-o cache_timeout=240", + "-o ServerAliveInterval 15", + "-o no_readahead", + "-o Ciphers=arcfour", + "-o Port=%s" % @port, + "%s@%s:%s:%s" % [@user,@host,@port,remotepath], + "$localdir" ].join(' ') + rdebug "command: %s" % cmd +=begin + system cmd + if $?.exitstatus != 0 then + raise ConnectError, self + end +=end + end end def disconnect