From 5fa6f0dd09e3f70798f2ffdf90031ca53083dc70 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Mon, 22 Sep 2014 23:43:55 -0300 Subject: [PATCH] synced_folder: Emit `vagrant-mounted` upstart event when starting containers Closes GH-302 --- CHANGELOG.md | 5 ++++- lib/vagrant-lxc/synced_folder.rb | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa8e6d7..c6a72e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [1.0.0](https://github.com/fgrehm/vagrant-lxc/compare/v1.0.0.alpha.3...v1.0.0) (Sep 22, 2014) +## [1.0.0](https://github.com/fgrehm/vagrant-lxc/compare/v1.0.0.alpha.3...v1.0.0) (Sep 23, 2014) BACKWARDS INCOMPATIBILITIES: @@ -8,9 +8,12 @@ BACKWARDS INCOMPATIBILITIES: IMPROVEMENTS: + - `vagrant-mounted` upstart event is now emited on containers that support it [[GH-302]] - Add support for specifying the `--strip-parameters` used by the [default template](scripts/lxc-template) when extracting rootfs tarballs [[GH-311]] +[GH-302]: https://github.com/fgrehm/vagrant-lxc/issues/302 + BUG FIXES: - Check for outdated base boxes when starting containers [[GH-314]] diff --git a/lib/vagrant-lxc/synced_folder.rb b/lib/vagrant-lxc/synced_folder.rb index 1130622..e16babf 100644 --- a/lib/vagrant-lxc/synced_folder.rb +++ b/lib/vagrant-lxc/synced_folder.rb @@ -46,6 +46,27 @@ module Vagrant guest_path: data[:guestpath])) end end + + def enable(machine, folders, _opts) + # Emit an upstart event if we can + return unless machine.communicate.test("test -x /sbin/initctl") + + # short guestpaths first, so we don't step on ourselves + folders = folders.sort_by do |id, data| + if data[:guestpath] + data[:guestpath].length + else + # A long enough path to just do this at the end. + 10000 + end + end + + folders.each do |id, data| + guest_path = data[:guestpath] + machine.communicate.sudo( + "/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=#{guest_path}") + end + end end end end