From 82f620ed133cd37df967b5a1212d78bf6d3bb2c2 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Wed, 18 Nov 2015 16:18:29 -0800 Subject: [PATCH] Fix upstart detection and event emit --- plugins/guests/linux/cap/mount_nfs.rb | 9 +++++---- plugins/guests/linux/cap/mount_smb_shared_folder.rb | 9 +++++---- .../guests/linux/cap/mount_virtualbox_shared_folder.rb | 9 +++++---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/plugins/guests/linux/cap/mount_nfs.rb b/plugins/guests/linux/cap/mount_nfs.rb index ecc3ea9ee..26dfb625d 100644 --- a/plugins/guests/linux/cap/mount_nfs.rb +++ b/plugins/guests/linux/cap/mount_nfs.rb @@ -33,10 +33,11 @@ module VagrantPlugins end # Emit an upstart event if we can - if machine.communicate.test("test -x /sbin/initctl && test 'upstart' = $(basename $(sudo readlink /proc/1/exe))") - machine.communicate.sudo( - "/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=#{expanded_guest_path}") - end + machine.communicate.sudo <<-SCRIPT +if command -v /sbin/init &>/dev/null && /sbin/init --version | grep upstart &>/dev/null; then + /sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT='#{expanded_guest_path}' +fi +SCRIPT end end end diff --git a/plugins/guests/linux/cap/mount_smb_shared_folder.rb b/plugins/guests/linux/cap/mount_smb_shared_folder.rb index 136ccfb8a..af96104e5 100644 --- a/plugins/guests/linux/cap/mount_smb_shared_folder.rb +++ b/plugins/guests/linux/cap/mount_smb_shared_folder.rb @@ -86,10 +86,11 @@ module VagrantPlugins end # Emit an upstart event if we can - if machine.communicate.test("test -x /sbin/initctl && test 'upstart' = $(basename $(sudo readlink /proc/1/exe))") - machine.communicate.sudo( - "/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=#{expanded_guest_path}") - end + machine.communicate.sudo <<-SCRIPT +if command -v /sbin/init &>/dev/null && /sbin/init --version | grep upstart &>/dev/null; then + /sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT='#{expanded_guest_path}' +fi +SCRIPT end end end diff --git a/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb b/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb index 56c864b6b..57fdc207f 100644 --- a/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb +++ b/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb @@ -80,10 +80,11 @@ module VagrantPlugins end # Emit an upstart event if we can - if machine.communicate.test("test -x /sbin/initctl && test 'upstart' = $(basename $(sudo readlink /proc/1/exe))") - machine.communicate.sudo( - "/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=#{expanded_guest_path}") - end + machine.communicate.sudo <<-SCRIPT +if command -v /sbin/init &>/dev/null && /sbin/init --version | grep upstart &>/dev/null; then + /sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT='#{expanded_guest_path}' +fi +SCRIPT end def self.unmount_virtualbox_shared_folder(machine, guestpath, options)