Merge pull request #2543 from glensc/pld-hostname
guests/pld: fix hostname change on pld
This commit is contained in:
commit
2a0f8e2143
|
@ -0,0 +1,20 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestPld
|
||||||
|
module Cap
|
||||||
|
class ChangeHostName
|
||||||
|
def self.change_host_name(machine, name)
|
||||||
|
machine.communicate.tap do |comm|
|
||||||
|
# Only do this if the hostname is not already set
|
||||||
|
if !comm.test("sudo hostname | grep --line-regexp '#{name}'")
|
||||||
|
comm.sudo("sed -i 's/\\(HOSTNAME=\\).*/\\1#{name}/' /etc/sysconfig/network")
|
||||||
|
comm.sudo("hostname #{name}")
|
||||||
|
comm.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
|
||||||
|
comm.sudo("sed -i 's/\\(DHCP_HOSTNAME=\\).*/\\1\"#{name}\"/' /etc/sysconfig/interfaces/ifcfg-*")
|
||||||
|
comm.sudo("service network restart")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,6 +11,11 @@ module VagrantPlugins
|
||||||
Guest
|
Guest
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guest_capability("pld", "change_host_name") do
|
||||||
|
require_relative "cap/change_host_name"
|
||||||
|
Cap::ChangeHostName
|
||||||
|
end
|
||||||
|
|
||||||
guest_capability("pld", "network_scripts_dir") do
|
guest_capability("pld", "network_scripts_dir") do
|
||||||
require_relative "cap/network_scripts_dir"
|
require_relative "cap/network_scripts_dir"
|
||||||
Cap::NetworkScriptsDir
|
Cap::NetworkScriptsDir
|
||||||
|
|
Loading…
Reference in New Issue