Sha256: a22bc4159d258e3101f26d70779b64f1d9b922c2ce35d382a903a445d9819203
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
module VagrantPlugins module GuestUbuntu module Cap class ChangeHostName < VagrantPlugins::GuestDebian::Cap::ChangeHostName def self.change_host_name(machine, name) super end def update_etc_hostname return super unless systemd? sudo("hostnamectl set-hostname '#{short_hostname}'") end def refresh_hostname_service if hardy? # hostname.sh returns 1, so use `true` to get a 0 exitcode sudo("/etc/init.d/hostname.sh start; true") elsif systemd? # Service runs via hostnamectl else sudo("service hostname start") end end def hardy? os_version("hardy") end def renew_dhcp sudo("ifdown -a; ifup -a; ifup -a --allow=hotplug") end private def init_package machine.communicate.execute('cat /proc/1/comm') do |type, data| return data.chomp if type == :stdout end end def os_version(name) machine.communicate.test("[ `lsb_release -c -s` = #{name} ]") end def systemd? init_package == 'systemd' end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vagrant-unbundled-1.8.1.2 | plugins/guests/ubuntu/cap/change_host_name.rb |
vagrant-unbundled-1.8.1.1 | plugins/guests/ubuntu/cap/change_host_name.rb |