lib/testlab/user/lifecycle.rb in testlab-0.6.3 vs lib/testlab/user/lifecycle.rb in testlab-0.6.4
- old
+ new
@@ -34,16 +34,17 @@
user_home_dir = File.join(self.container.lxc.fs_root, ((self.id == "root") ? %(/root) : %(/home/#{self.id})))
user_authkeys = File.join(user_home_dir, ".ssh", "authorized_keys")
user_authkeys2 = File.join(user_home_dir, ".ssh", "authorized_keys2")
authkeys = {
- node_authkeys => user_authkeys,
- node_authkeys => user_authkeys2
+ user_authkeys => node_authkeys,
+ user_authkeys2 => node_authkeys
}
- authkeys.each do |source, destination|
+ authkeys.each do |destination, source|
+ @ui.logger.info { "SOURCE: #{source} >>> #{destination}" }
self.container.node.ssh.exec(%(sudo mkdir -pv #{File.dirname(destination)}))
- self.container.node.ssh.exec(%(sudo cp -v #{source} #{destination}))
+ self.container.node.ssh.exec(%(sudo grep "$(cat #{source})" #{destination} || sudo cat #{source} | sudo tee -a #{destination}))
self.container.node.ssh.exec(%(sudo chmod -v 644 #{destination}))
end
# ensure the container user home directory is owned by them
home_dir = self.container.lxc.attach(%(-- /bin/bash -c 'grep #{self.id} /etc/passwd | cut -d ":" -f6')).strip