Solved

inotifywait on remote folder with local mount point

Posted on 2016-10-29
7
103 Views
Last Modified: 2016-10-31
I'm running a VirtualBox with Ubuntu, hosted on Windows 10.  I have an NTFS directory mounted as a VB shared folder.  From within the VM, I want to monitor this directory recursively for file changes and run a local shell script when one is detected.  

I'm familiar with inotifywait, but the file changes are being done from the host side, so the VM's file system does fire any events when a change is made.
0
Comment
Question by:Steve Bink
7 Comments
 
LVL 16

Assisted Solution

by:Hanno Schröder
Hanno Schröder earned 100 total points
ID: 41865764
A notification can only happen on the side with the fs (locally).
Therefore, you have two options:
a) Get the notification on the server's side and send some inf/message to yout client (who has the fs mounted)
b) Create a small script that loops through a little check routine (polls for changes)
0
 
LVL 40

Expert Comment

by:noci
ID: 41865835
A different approach might be: Supply the service from the linux box where the windows box does the remote mount..?

Another approach:
https://github.com/thekid/inotify-win

Inotify port for windows.
0
 
LVL 50

Author Comment

by:Steve Bink
ID: 41865923
To clarify the scenario a bit...

I code using PHPStorm on Windows.  My project is in a Windows directory.  My web services and runtime environment is a LAMP stack on my Ubuntu VM.  The Windows-based project directory is exposed to the VM as a VB shared folder, and the docroot for my Apache site is that same shared folder..  When files are changed in the project (e.g., I edit files), I want to fire a shell script on the VM to run some management tasks.  The script must have local access to the VM file system.

It sounds to me like I need a way for an Ubuntu VM to monitor the host filesystem for changes.  inotify-win looks promising, but I'm not sure how to get those messages into the guest.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 40

Assisted Solution

by:noci
noci earned 100 total points
ID: 41866085
Oh ok...
In that case you may want a different setup... using git.
Build your stuff on windows and create the layout as you want to have it on the LAMP environment.
Store that in git...
Then regularly pull the environment to the windows box.
If there are no changes no download will happen. (This is how many continuous sites update their stuff).

OTOH you can always trigger a pull by the windows version of inotify.
0
 
LVL 50

Author Comment

by:Steve Bink
ID: 41866254
As it is right now, when I edit a file on the host, the changes are immediately apparent from the guest.  The problem is that every time I edit a file, I want to run a script to update a deployment package to include the changes, and/or copy them into place in a "pre-deployed" testing environment. The final version of the entire thing (source and deploy package) may also be committed into a git repo and pushed.  All of that happens inside the guest... Windows is used only for editing.

Currently, I edit my files, then manually trigger this process on the VM.  It is that step I want to automate.  I've considered using a poller, but I think that would just end up being a source of stress... even if I polled every five seconds, that delay can interrupt my workflow just as much as pausing to trigger my deployment script.

>>> Supply the service from the linux box where the windows box does the remote mount..?

That sounds like a perfectly sane solution, though it grates against my inclination to have my Windows docs be the canon.  How could I implement that?
0
 
LVL 37

Accepted Solution

by:
ArneLovius earned 300 total points
ID: 41867662
If you run it the other way around and work in a SMB share from the Linux VM, then you could use inotifywait on the Linux side...

Alternatively, work locally and use something* to replicate to directory structure to the Linux VM, where you could use inotifywait

*I would suggest taking a look at syncthing
0
 
LVL 50

Author Comment

by:Steve Bink
ID: 41867695
It was while I was looking at syncthing that I remembered why I set it up this way... I'm trying to keep the space usage on the VM to a minimum.  So, I guess I'm just out of luck here.  

For the record, syncthing would have been a good solution here.  Its only deficiency is the fact that the guest would maintain its own copy.  Minus the space limitations, it would have been ideal.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question