Solved

inotifywait on remote folder with local mount point

Posted on 2016-10-29
7
41 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 39

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 39

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 36

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
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 navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now