Sha256: 658471d5e2bab1def9c1f913374f692b50de19c1a7409fb65766f1ee2f97583b

Contents?: true

Size: 678 Bytes

Versions: 20

Compression:

Stored size: 678 Bytes

Contents

module VagrantPlugins
  module GuestSUSE
    module Cap
      class ChangeHostName
        def self.change_host_name(machine, name)
          comm = machine.communicate

          if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
            basename = name.split(".", 2)[0]
            comm.sudo <<-EOH.gsub(/^ {14}/, '')
              echo '#{basename}' > /etc/HOSTNAME
              hostname '#{basename}'

              # Prepend ourselves to /etc/hosts
              grep -w '#{name}' /etc/hosts || {
                sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts
              }
            EOH
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 16 versions & 3 rubygems

Version Path
vagrant-unbundled-2.2.5.0 plugins/guests/suse/cap/change_host_name.rb
vagrant-unbundled-2.2.4.0 plugins/guests/suse/cap/change_host_name.rb
vagrant-unbundled-2.2.3.0 plugins/guests/suse/cap/change_host_name.rb
vagrant-unbundled-2.2.2.0 plugins/guests/suse/cap/change_host_name.rb
vagrant-unbundled-2.2.0.0 plugins/guests/suse/cap/change_host_name.rb
vagrant-unbundled-2.1.4.0 plugins/guests/suse/cap/change_host_name.rb
vagrant-unbundled-2.1.2.0 plugins/guests/suse/cap/change_host_name.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-04f7215b5e3f/plugins/guests/suse/cap/change_host_name.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-04f7215b5e3f/plugins/guests/suse/cap/change_host_name.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-04f7215b5e3f/plugins/guests/suse/cap/change_host_name.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-04f7215b5e3f/plugins/guests/suse/cap/change_host_name.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-04f7215b5e3f/plugins/guests/suse/cap/change_host_name.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-04f7215b5e3f/plugins/guests/suse/cap/change_host_name.rb
vagrant-unbundled-2.1.1.0 plugins/guests/suse/cap/change_host_name.rb
vagrant-unbundled-2.0.4.0 plugins/guests/suse/cap/change_host_name.rb
vagrant-unbundled-2.0.3.0 plugins/guests/suse/cap/change_host_name.rb
vagrant-aws-detiber-0.7.2.pre.4 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/plugins/guests/suse/cap/change_host_name.rb
vagrant-aws-detiber-0.7.2.pre.3 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/plugins/guests/suse/cap/change_host_name.rb
vagrant-aws-detiber-0.7.2.pre.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/plugins/guests/suse/cap/change_host_name.rb
vagrant-unbundled-2.0.2.0 plugins/guests/suse/cap/change_host_name.rb