From 18f36f05367f78820632870bff09bf80685d115b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Droz?= Date: Mon, 11 May 2015 13:38:58 +0200 Subject: lastpass importer: more types supported and better checking --- contrib/importers/lastpass2pass.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'contrib') diff --git a/contrib/importers/lastpass2pass.rb b/contrib/importers/lastpass2pass.rb index 41a2a29..654101b 100755 --- a/contrib/importers/lastpass2pass.rb +++ b/contrib/importers/lastpass2pass.rb @@ -76,7 +76,7 @@ entry = "" begin file = File.open(filename) file.each do |line| - if line =~ /^http/ + if line =~ /^(http|ftp|ssh)/ entries.push(entry) entry = "" end @@ -110,8 +110,12 @@ puts "Records parsed: #{records.length}" successful = 0 errors = [] records.each do |r| + if File.exist?("#{r.name}.gpg") and FORCE == false + puts "skipped #{r.name}: already exists" + next + end print "Creating record #{r.name}..." - IO.popen("pass insert -m#{"f" if FORCE} '#{r.name}' > /dev/null", 'w') do |io| + IO.popen("pass insert -m '#{r.name}' > /dev/null", 'w') do |io| io.puts r end if $? == 0 @@ -124,7 +128,7 @@ records.each do |r| end puts "#{successful} records successfully imported!" -if errors +if errors.length > 0 puts "There were #{errors.length} errors:" errors.each { |e| print e.name + (e == errors.last ? ".\n" : ", ")} puts "These probably occurred because an identically-named record already existed, or because there were multiple entries with the same name in the csv file." -- cgit v1.2.3