Sha256: eee7db0a2895514686e5a3ee40a10f718b42a64d91f915309df9d62e8fd66c9d

Contents?: true

Size: 662 Bytes

Versions: 6

Compression:

Stored size: 662 Bytes

Contents

module VagrantPlugins
  module GuestDebian
    module Cap
      class ChangeHostName
        def self.change_host_name(machine, name)
          machine.communicate.tap do |comm|
            if !comm.test("hostname --fqdn | grep '^#{name}$' || hostname --short | grep '^#{name}$'")
              comm.sudo("sed -r -i 's/^(127[.]0[.]1[.]1[[:space:]]+).*$/\\1#{name} #{name.split('.')[0]}/' /etc/hosts")
              comm.sudo("sed -i 's/.*$/#{name.split('.')[0]}/' /etc/hostname")
              comm.sudo("hostname -F /etc/hostname")
              comm.sudo("hostname --fqdn > /etc/mailname")
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/plugins/guests/debian/cap/change_host_name.rb
tnargav-1.2.3 plugins/guests/debian/cap/change_host_name.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/plugins/guests/debian/cap/change_host_name.rb
vagrant-shell-0.2.6 vendor/bundle/gems/tnargav-1.2.2/plugins/guests/debian/cap/change_host_name.rb
vagrant-shell-0.2.5 vendor/bundle/gems/tnargav-1.2.2/plugins/guests/debian/cap/change_host_name.rb
tnargav-1.2.2 plugins/guests/debian/cap/change_host_name.rb