Use the new communication interface for Ubuntu guest

This commit is contained in:
Mitchell Hashimoto 2012-08-20 12:15:42 -07:00
parent b328e95045
commit 1efee6edcb
1 changed files with 8 additions and 6 deletions

View File

@ -10,15 +10,17 @@ module VagrantPlugins
super super
# Emit an upstart event if upstart is available # Emit an upstart event if upstart is available
vm.channel.sudo("[ -x /sbin/initctl ] && /sbin/initctl emit vagrant-mounted MOUNTPOINT=#{guestpath}") vm.communicate.sudo("[ -x /sbin/initctl ] && /sbin/initctl emit vagrant-mounted MOUNTPOINT=#{guestpath}")
end end
def change_host_name(name) def change_host_name(name)
if !vm.channel.test("sudo hostname | grep '#{name}'") vm.communicate.tap do |comm|
vm.channel.sudo("sed -i 's/.*$/#{name}/' /etc/hostname") if !comm.test("sudo hostname | grep '#{name}'")
vm.channel.sudo("sed -i 's@^\\(127[.]0[.]1[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts") comm.sudo("sed -i 's/.*$/#{name}/' /etc/hostname")
vm.channel.sudo("service hostname start") comm.sudo("sed -i 's@^\\(127[.]0[.]1[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
vm.channel.sudo("hostname --fqdn > /etc/mailname") comm.sudo("service hostname start")
comm.sudo("hostname --fqdn > /etc/mailname")
end
end end
end end
end end