diff options
author | Raphaël Droz <raphael.droz@gmail.com> | 2015-05-11 13:38:58 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2015-05-11 13:38:58 +0200 |
commit | 18f36f05367f78820632870bff09bf80685d115b (patch) | |
tree | 8ee3f6dcd6394f45b6d02e91c5ebf1a886526cbf | |
parent | 4690a3021cf74b2093d296f48f205b6706f82f2a (diff) | |
download | pass-18f36f05367f78820632870bff09bf80685d115b.tar.gz pass-18f36f05367f78820632870bff09bf80685d115b.tar.bz2 pass-18f36f05367f78820632870bff09bf80685d115b.zip |
lastpass importer: more types supported and better checking
Diffstat (limited to '')
-rwxr-xr-x | contrib/importers/lastpass2pass.rb | 10 |
1 files changed, 7 insertions, 3 deletions
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." |