Merge pull request #5290 from channui/solaris11-plugin
guests/solaris11: Copy linux support for insert_public_key and remove_public_key to solari...
This commit is contained in:
commit
55d54b5832
|
@ -0,0 +1,21 @@
|
||||||
|
require "vagrant/util/shell_quote"
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestSolaris11
|
||||||
|
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("mkdir -p ~/.ssh")
|
||||||
|
comm.execute("chmod 0700 ~/.ssh")
|
||||||
|
comm.execute("printf '#{contents}\\n' >> ~/.ssh/authorized_keys")
|
||||||
|
comm.execute("chmod 0600 ~/.ssh/authorized_keys")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,21 @@
|
||||||
|
require "vagrant/util/shell_quote"
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestSolaris11
|
||||||
|
module Cap
|
||||||
|
class RemovePublicKey
|
||||||
|
def self.remove_public_key(machine, contents)
|
||||||
|
contents = contents.chomp
|
||||||
|
contents = Vagrant::Util::ShellQuote.escape(contents, "'")
|
||||||
|
|
||||||
|
machine.communicate.tap do |comm|
|
||||||
|
if comm.test("test -f ~/.ssh/authorized_keys")
|
||||||
|
comm.execute(
|
||||||
|
"sed -i '/^.*#{contents}.*$/d' ~/.ssh/authorized_keys")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -49,6 +49,16 @@ module VagrantPlugins
|
||||||
require_relative "cap/rsync"
|
require_relative "cap/rsync"
|
||||||
Cap::RSync
|
Cap::RSync
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guest_capability("solaris11", "insert_public_key") do
|
||||||
|
require_relative "cap/insert_public_key"
|
||||||
|
Cap::InsertPublicKey
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability("solaris11", "remove_public_key") do
|
||||||
|
require_relative "cap/remove_public_key"
|
||||||
|
Cap::RemovePublicKey
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue