From 184f6dccb2d550a16eb895ce4339080473b3bfa2 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 18 Sep 2012 22:26:51 -0700 Subject: [PATCH] Forward port GH-1142 --- plugins/hosts/arch/host.rb | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/plugins/hosts/arch/host.rb b/plugins/hosts/arch/host.rb index d2ff0652b..fe56f31f1 100644 --- a/plugins/hosts/arch/host.rb +++ b/plugins/hosts/arch/host.rb @@ -23,17 +23,36 @@ module VagrantPlugins @ui.info I18n.t("vagrant.hosts.arch.nfs_export.prepare") sleep 0.5 + nfs_cleanup(id) + 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") + if systemd? + # Call start to be nice. This will be a no-op if things are + # already running. Then use exportfs to pick up the changes we + # just made. + system("sudo systemctl start nfsd.service rpc-idmapd.service rpc-mountd.service rpcbind.service") + system("sudo exportfs -r") + else + # The restarting of services when we might not need to can be + # considered evil, but this will be obviated by systemd soon + # enough anyway. + 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 + + protected + + # This tests to see if systemd is used on the system. This is used + # in newer versions of Arch, and requires a change in behavior. + def systemd? + Kernel.system("which systemctl &>/dev/null") end end end