sshfs-mapper: improve map parser for the ruby version.

git-svn-id: https://websvn.glenux.net/svn/Upoc/sshfs-mapper/trunk@1508 eaee96b3-f302-0410-b096-c6cfd47f7835
This commit is contained in:
Glenn Y. Rolland 2010-01-13 23:46:48 +00:00
parent f53924cfbd
commit 63954a3e62
2 changed files with 25 additions and 16 deletions

39
map.rb
View file

@ -7,29 +7,34 @@ module SshfsMapper
@host = nil @host = nil
@port = 22 @port = 22
@user = nil @user = nil
@map = {} @engine = :arcfour
@maps = {}
end end
def parse() def parse()
puts "Parsing map #{@path}" puts "Parsing map #{@path}"
File.open( @path ) do |f| f = File.open( @path )
f.each do |line| f.each do |line|
case line case line
when /^MAP\s*=\s*(\S+)\s*(\S+)\s*$/ then when /^\s*REMOTE_USER\s*=\s*(.*)\s*$/
@map[$1] = $2 @user = $1
when /^REMOTE_HOST\s*=\s*(\S+)\s*$/ then when /^\s*REMOTE_PORT\s*=\s*(.*)\s*$/
@port = $1.to_i
when /^\s*REMOTE_HOST\s*=\s*(.*)\s*$/
@host = $1
when /^\s*REMOTE_CYPHER\s*=\s*(.*)\s*$/
idx = ["arcfour", "aes-256-cbc"].index( $1 )
if not idx.nil? then
@host = $1 @host = $1
when /^REMOTE_PORT\s*=\s*(\S+)\s*$/ then
@port = $1
when /^REMOTE_USER\s*=\s*(\S+)\s*$/ then
@user = $1
when /^\s*$/ then
# skip
else
puts "unexpectd line '#{line}'"
end end
when /^\s*MAP\s*=\s*(.*)\s+(.*)\s*$/
@maps[$1] = $2
else
puts "dropping #{line}"
end end
end end
f.close
#
end end
def is_alive? def is_alive?
@ -41,7 +46,9 @@ module SshfsMapper
end end
def connect() def connect()
puts "Connecting map #{@path}" puts "[#{File.basename @path}] Connecting..."
puts " #{@user}@#{@host}:#{@port}"
puts " maps = #{@maps}"
# do something # do something
# test server connection # test server connection
# mount # mount

View file

@ -40,6 +40,8 @@ do_mount() {
-o reconnect \ -o reconnect \
-o workaround=all \ -o workaround=all \
-o cache_timeout=240 \ -o cache_timeout=240 \
-o ServerAliveInterval 15 \
-o no_readahead \
-o Ciphers=arcfour \ -o Ciphers=arcfour \
-o Port=$remoteport \ -o Port=$remoteport \
$remotedir \ $remotedir \