sshfs-mapper map: Replace environment variables in map descriptions.
git-svn-id: https://websvn.glenux.net/svn/Upoc/sshfs-mapper/trunk@1664 eaee96b3-f302-0410-b096-c6cfd47f7835
This commit is contained in:
parent
37cb6633f3
commit
9a480130ab
1 changed files with 12 additions and 3 deletions
|
@ -28,7 +28,7 @@ module SshfsMapper
|
|||
@user = nil
|
||||
@cypher = :arcfour
|
||||
@maps = {}
|
||||
@debug = false
|
||||
@debug = true
|
||||
|
||||
self.load @path
|
||||
end
|
||||
|
@ -38,10 +38,18 @@ module SshfsMapper
|
|||
rdebug "Parsing map #{@path}"
|
||||
f = File.open @path
|
||||
linect = 0
|
||||
local_env = ENV.clone
|
||||
f.each do |line|
|
||||
line = line.strip
|
||||
linect += 1
|
||||
|
||||
while line =~ /\$(.*)/ do
|
||||
pattern = $1
|
||||
puts "FOUND PATTERN %s => %s" % [$1, local_env[$1]]
|
||||
line.gsub!(/\$#{pattern}/,local_env[$1])
|
||||
line.gsub!(/\$\{#{pattern}\}/,local_env[$1])
|
||||
end
|
||||
|
||||
case line
|
||||
when /^\s*REMOTE_USER\s*=\s*(.*)\s*$/ then
|
||||
@user = $1
|
||||
|
@ -71,7 +79,7 @@ module SshfsMapper
|
|||
def write path=nil
|
||||
@path=path unless path.nil?
|
||||
|
||||
File.open @path, "w" do |f|
|
||||
File.open(@path, "w") do |f|
|
||||
f.puts "REMOTE_USER=%s" % @user
|
||||
f.puts "REMOTE_PORT=%s" % @port
|
||||
f.puts "REMOTE_HOST=%s" % @host
|
||||
|
@ -79,7 +87,8 @@ module SshfsMapper
|
|||
end
|
||||
end
|
||||
|
||||
def alive?
|
||||
def online?
|
||||
rdebug "testing online? %s " % self.inspect
|
||||
#FIXME: test liveness
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue