This commit adds/changes the following for SmartOS guests: - modifies the "Halt" capability to use /usr/sbin/poweroff in preference to /usr/sbin/shutdown with parameters, and modifies the associated test. - adds an "InsertPublicKey" capability and tests. - adds a "RemovePublicKey" capability and tests. With this commit applied, the vast majority of typical Vagrant workflow is available to SmartOS global zone guests (provided NFS mounts are used rather than VMWare shared folders).
29 lines
889 B
Ruby
29 lines
889 B
Ruby
require "vagrant/util/shell_quote"
|
|
|
|
module VagrantPlugins
|
|
module GuestSmartos
|
|
module Cap
|
|
class InsertPublicKey
|
|
def self.insert_public_key(machine, contents)
|
|
contents = contents.chomp
|
|
contents = Vagrant::Util::ShellQuote.escape(contents, "'")
|
|
|
|
machine.communicate.tap do |comm|
|
|
comm.execute <<-EOH.sub(/^ */, '')
|
|
if [ -d /usbkey ] && [ "$(zonename)" == "global" ] ; then
|
|
printf '#{contents}\\n' >> /usbkey/config.inc/authorized_keys
|
|
cp /usbkey/config.inc/authorized_keys ~/.ssh/authorized_keys
|
|
else
|
|
mkdir -p ~/.ssh
|
|
chmod 0700 ~/.ssh
|
|
printf '#{contents}\\n' >> ~/.ssh/authorized_keys
|
|
chmod 0600 ~/.ssh/authorized_keys
|
|
fi
|
|
EOH
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|