set hostname on archlinux [closes GH-439]

Signed-off-by: Dave Simons <dave@inuits.be>
This commit is contained in:
Dave Simons 2011-07-27 23:24:27 +02:00 committed by Mitchell Hashimoto
parent f707431410
commit 1bf3aa69ed
4 changed files with 20 additions and 1 deletions

View File

@ -10,3 +10,4 @@ require 'vagrant/systems/gentoo'
require 'vagrant/systems/redhat'
require 'vagrant/systems/suse'
require 'vagrant/systems/ubuntu'
require 'vagrant/systems/arch'

View File

@ -0,0 +1,16 @@
module Vagrant
module Systems
class Arch < Linux
def change_host_name(name)
vm.ssh.execute do |ssh|
# Only do this if the hostname is not already set
if !ssh.test?("sudo hostname | grep '#{name}'")
ssh.exec!("sudo sed -i 's/\\(HOSTNAME=\\).*/\\1#{name}/' /etc/rc.conf")
ssh.exec!("sudo hostname #{name}")
ssh.exec!("sudo sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} @' /etc/hosts")
end
end
end
end
end
end

View File

@ -14,6 +14,7 @@ module Vagrant
return :gentoo if ssh.test?("cat /etc/gentoo-release")
return :redhat if ssh.test?("cat /etc/redhat-release")
return :suse if ssh.test?("cat /etc/SuSE-release")
return :arch if ssh.test?("cat /etc/arch-release")
end
# Can't detect the distro, assume vanilla linux

View File

@ -66,7 +66,8 @@ module Vagrant
:redhat => Systems::Redhat,
:suse => Systems::Suse,
:linux => Systems::Linux,
:solaris => Systems::Solaris
:solaris => Systems::Solaris,
:arch => Systems::Arch
}
raise Errors::VMSystemError, :_key => :unknown_type, :system => system.to_s if !mapping.has_key?(system)