Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

inotifywait on remote folder with local mount point

Posted on 2016-10-29
7
Medium Priority
?
443 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 P.S.
Hanno P.S. earned 400 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 51

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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 40

Assisted Solution

by:noci
noci earned 400 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 51

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 1200 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 51

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month11 days, 21 hours left to enroll

916 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