Sha256: 07b6694fa721fd3b342c415bd53a9824b5e76758e588fc89fb0511013fdd5d20

Contents?: true

Size: 624 Bytes

Versions: 5

Compression:

Stored size: 624 Bytes

Contents

module VagrantPlugins
  module GuestSuse
    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 '#{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")
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 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/suse/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/suse/cap/change_host_name.rb
vagrant-shell-0.2.6 vendor/bundle/gems/tnargav-1.2.2/plugins/guests/suse/cap/change_host_name.rb
vagrant-shell-0.2.5 vendor/bundle/gems/tnargav-1.2.2/plugins/guests/suse/cap/change_host_name.rb
tnargav-1.2.2 plugins/guests/suse/cap/change_host_name.rb