From 2c091c98cc959a8dc56ff6cb39a90798858e04ba Mon Sep 17 00:00:00 2001 From: Tim Joseph Dumol Date: Wed, 20 Apr 2011 00:35:20 +0800 Subject: [PATCH] Added Arch Linux as under vagrant/hosts Added NFS support for Arch Linux under vagrant/hosts by adding vagrant/hosts/arch and a platform test for Arch Linux. --- lib/vagrant/hosts.rb | 1 + lib/vagrant/hosts/arch.rb | 27 +++++++++++++++++++++++++++ lib/vagrant/hosts/base.rb | 1 + lib/vagrant/util/platform.rb | 5 +++++ templates/locales/en.yml | 4 ++++ 5 files changed, 38 insertions(+) create mode 100644 lib/vagrant/hosts/arch.rb diff --git a/lib/vagrant/hosts.rb b/lib/vagrant/hosts.rb index 5ed2ebdd9..852269732 100644 --- a/lib/vagrant/hosts.rb +++ b/lib/vagrant/hosts.rb @@ -3,5 +3,6 @@ module Vagrant autoload :Base, 'vagrant/hosts/base' autoload :BSD, 'vagrant/hosts/bsd' autoload :Linux, 'vagrant/hosts/linux' + autoload :Arch, 'vagrant/hosts/arch' end end diff --git a/lib/vagrant/hosts/arch.rb b/lib/vagrant/hosts/arch.rb new file mode 100644 index 000000000..c53e17936 --- /dev/null +++ b/lib/vagrant/hosts/arch.rb @@ -0,0 +1,27 @@ +module Vagrant + module Hosts + class Arch < Linux + def nfs_export(ip, folders) + output = TemplateRenderer.render('nfs/exports_linux', + :uuid => env.vm.uuid, + :ip => ip, + :folders => folders) + + env.ui.info I18n.t("vagrant.hosts.arch.nfs_export.prepare") + sleep 0.5 + + output.split("\n").each do |line| + # This should only ask for administrative permission once, even + # though its executed in multiple subshells. + system(%Q[sudo su root -c "echo '#{line}' >> /etc/exports"]) + end + + # We run restart here instead of "update" just in case nfsd + # is not starting + system("sudo /etc/rc.d/rpcbind restart") + system("sudo /etc/rc.d/nfs-common restart") + system("sudo /etc/rc.d/nfs-server restart") + end + end + end +end diff --git a/lib/vagrant/hosts/base.rb b/lib/vagrant/hosts/base.rb index 8b216897a..10932ccbf 100644 --- a/lib/vagrant/hosts/base.rb +++ b/lib/vagrant/hosts/base.rb @@ -31,6 +31,7 @@ module Vagrant classes = { :darwin => BSD, :bsd => BSD, + :arch => Arch, :linux => Linux } diff --git a/lib/vagrant/util/platform.rb b/lib/vagrant/util/platform.rb index b86b4b56c..9c96776b3 100644 --- a/lib/vagrant/util/platform.rb +++ b/lib/vagrant/util/platform.rb @@ -28,6 +28,11 @@ module Vagrant false end + def arch? + linux?() and File.exist?('/etc/rc.conf') and + File.exist?('/etc/pacman.conf') and File.exist?('/etc/rc.d/') + end + # Returns boolean noting whether this is a 64-bit CPU. This # is not 100% accurate and there could easily be false negatives. # diff --git a/templates/locales/en.yml b/templates/locales/en.yml index d6ae4403b..51dd522d8 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -451,6 +451,10 @@ en: nfs_export: prepare: "Preparing to edit /etc/exports. Administrator privileges will be required..." + arch: + nfs_export: + prepare: "Preparing to edit /etc/exports. Administrator privileges will be required..." + provisioners: chef: json: "Generating chef JSON and uploading..."