2012-05-23 22:57:43 +00:00
|
|
|
require "vagrant"
|
|
|
|
|
|
|
|
require Vagrant.source_root.join("plugins/guests/debian/guest")
|
|
|
|
|
2012-04-19 04:23:25 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module GuestUbuntu
|
|
|
|
class Guest < VagrantPlugins::GuestDebian::Guest
|
2012-01-13 06:57:32 +00:00
|
|
|
def mount_shared_folder(name, guestpath, options)
|
|
|
|
# Mount it like normal
|
|
|
|
super
|
|
|
|
|
|
|
|
# Emit an upstart event if upstart is available
|
2012-08-20 19:15:42 +00:00
|
|
|
vm.communicate.sudo("[ -x /sbin/initctl ] && /sbin/initctl emit vagrant-mounted MOUNTPOINT=#{guestpath}")
|
2012-01-13 06:57:32 +00:00
|
|
|
end
|
|
|
|
|
2012-09-13 07:14:40 +00:00
|
|
|
def mount_nfs(ip, folders)
|
|
|
|
# Mount it like normal
|
|
|
|
super
|
|
|
|
|
|
|
|
# Emit an upstart events if upstart is available
|
|
|
|
folders.each do |name, opts|
|
|
|
|
real_guestpath = expanded_guest_path(opts[:guestpath])
|
2013-01-30 18:54:53 +00:00
|
|
|
vm.communicate.sudo("[ -x /sbin/initctl ] && /sbin/initctl emit vagrant-mounted MOUNTPOINT=#{real_guestpath}")
|
2012-09-13 07:14:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-03-01 07:38:30 +00:00
|
|
|
def change_host_name(name)
|
2012-08-20 19:15:42 +00:00
|
|
|
vm.communicate.tap do |comm|
|
2012-10-13 03:06:54 +00:00
|
|
|
if !comm.test("sudo hostname | grep '^#{name}$'")
|
2012-08-20 19:15:42 +00:00
|
|
|
comm.sudo("sed -i 's/.*$/#{name}/' /etc/hostname")
|
|
|
|
comm.sudo("sed -i 's@^\\(127[.]0[.]1[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
|
2012-10-12 16:11:52 +00:00
|
|
|
if comm.test("[ `lsb_release -c -s` = hardy ]")
|
|
|
|
# hostname.sh returns 1, so I grep for the right name in /etc/hostname just to have a 0 exitcode
|
|
|
|
comm.sudo("/etc/init.d/hostname.sh start; grep '#{name}' /etc/hostname")
|
|
|
|
else
|
|
|
|
comm.sudo("service hostname start")
|
|
|
|
end
|
2012-08-20 19:15:42 +00:00
|
|
|
comm.sudo("hostname --fqdn > /etc/mailname")
|
|
|
|
end
|
2011-03-01 07:38:30 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|