From 8189a2f35fb554bcb4a611e97e5839bf78eca8ff Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Fri, 25 Jul 2014 13:33:39 -0700 Subject: [PATCH] [ansible] Tweak SSH key setup script --- scripts/setup_ssh_keys.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/setup_ssh_keys.rb b/scripts/setup_ssh_keys.rb index 8d26af9..dffc6da 100644 --- a/scripts/setup_ssh_keys.rb +++ b/scripts/setup_ssh_keys.rb @@ -13,9 +13,13 @@ end cd File.expand_path('~/.ssh') with_mount "~/Dropbox/sekritz.sparseimage" do |mountpoint| - Dir["#{mountpoint}/ssh keys/*"].each do |file| - cp file, File.basename(file) - puts `chmod go-r #{File.basename(file)}` - puts `ssh-add -K #{File.basename(file)}` + from = Dir["#{mountpoint}/ssh keys/*"] + to = from.map {|file| File.basename(file) } + from.zip(to).each do |from, to| + next if File.exist?(to) + + cp from, to + puts `chmod go-r #{to}` + puts `ssh-add -K #{to}` end end