Setting hostname on Debian (not Ubuntu) should now work [closes GH-307]
This commit is contained in:
parent
8792ed8b49
commit
2cfa79ac6d
|
@ -3,6 +3,7 @@
|
|||
- Fix issue with unknown terminal type output for sudo commands.
|
||||
- Forwarded port protocol can now be set as UDP. [GH-311]
|
||||
- Chef server file cache path and file backup path can be configured. [GH-310]
|
||||
- Setting hostname should work on Debian now. [GH-307]
|
||||
|
||||
## 0.7.2 (February 8, 2011)
|
||||
|
||||
|
|
|
@ -8,3 +8,4 @@ require 'vagrant/systems/solaris'
|
|||
require 'vagrant/systems/debian'
|
||||
require 'vagrant/systems/gentoo'
|
||||
require 'vagrant/systems/redhat'
|
||||
require 'vagrant/systems/ubuntu'
|
||||
|
|
|
@ -25,9 +25,9 @@ module Vagrant
|
|||
def change_host_name(name)
|
||||
vm.ssh.execute do |ssh|
|
||||
if !ssh.test?("sudo hostname | grep '#{name}'")
|
||||
ssh.exec!("sudo sed -i 's/.*$/#{name}/' /etc/hostname")
|
||||
ssh.exec!("sudo sed -i 's@^\\(127[.]0[.]1[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
|
||||
ssh.exec!("sudo service hostname start")
|
||||
ssh.exec!("sudo sed -i 's/.*$/#{name}/' /etc/hostname")
|
||||
ssh.exec!("sudo hostname -F /etc/hostname")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,11 @@ module Vagrant
|
|||
class Linux < Base
|
||||
def distro_dispatch
|
||||
vm.ssh.execute do |ssh|
|
||||
return :debian if ssh.test?("cat /etc/debian_version")
|
||||
if ssh.test?("cat /etc/debian_version")
|
||||
return :debian if ssh.test?("cat /proc/version | grep 'Debian'")
|
||||
return :ubuntu if ssh.test?("cat /proc/version | grep 'Ubuntu'")
|
||||
end
|
||||
|
||||
return :gentoo if ssh.test?("cat /etc/gentoo-release")
|
||||
return :redhat if ssh.test?("cat /etc/redhat-release")
|
||||
end
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
require 'vagrant/systems/debian'
|
||||
|
||||
module Vagrant
|
||||
module Systems
|
||||
class Ubuntu < Debian
|
||||
def change_host_name(name)
|
||||
vm.ssh.execute do |ssh|
|
||||
if !ssh.test?("sudo hostname | grep '#{name}'")
|
||||
ssh.exec!("sudo sed -i 's/.*$/#{name}/' /etc/hostname")
|
||||
ssh.exec!("sudo sed -i 's@^\\(127[.]0[.]1[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
|
||||
ssh.exec!("sudo service hostname start")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -59,6 +59,7 @@ module Vagrant
|
|||
# Hard-coded internal systems
|
||||
mapping = {
|
||||
:debian => Systems::Debian,
|
||||
:ubuntu => Systems::Ubuntu,
|
||||
:freebsd => Systems::FreeBSD,
|
||||
:gentoo => Systems::Gentoo,
|
||||
:redhat => Systems::Redhat,
|
||||
|
|
Loading…
Reference in New Issue