diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fc8c3f73..d20ed7661 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/lib/vagrant/systems.rb b/lib/vagrant/systems.rb index 57a689548..89a2f86ce 100644 --- a/lib/vagrant/systems.rb +++ b/lib/vagrant/systems.rb @@ -8,3 +8,4 @@ require 'vagrant/systems/solaris' require 'vagrant/systems/debian' require 'vagrant/systems/gentoo' require 'vagrant/systems/redhat' +require 'vagrant/systems/ubuntu' diff --git a/lib/vagrant/systems/debian.rb b/lib/vagrant/systems/debian.rb index 1914a28f6..19422a6eb 100644 --- a/lib/vagrant/systems/debian.rb +++ b/lib/vagrant/systems/debian.rb @@ -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 diff --git a/lib/vagrant/systems/linux.rb b/lib/vagrant/systems/linux.rb index 48c7fb79e..fd747576c 100644 --- a/lib/vagrant/systems/linux.rb +++ b/lib/vagrant/systems/linux.rb @@ -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 diff --git a/lib/vagrant/systems/ubuntu.rb b/lib/vagrant/systems/ubuntu.rb new file mode 100644 index 000000000..2aaad4814 --- /dev/null +++ b/lib/vagrant/systems/ubuntu.rb @@ -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 diff --git a/lib/vagrant/vm.rb b/lib/vagrant/vm.rb index 397b29403..239922d7c 100644 --- a/lib/vagrant/vm.rb +++ b/lib/vagrant/vm.rb @@ -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,