sync events to Dropbox

Forum for questions and support relating to the 1.25.x releases only.
Locked
zaphyr
Posts: 4
Joined: Thu Apr 11, 2013 9:20 am

sync events to Dropbox

Post by zaphyr »

Hi,

I'm using Zoneminder 1.25.0 with two local USB webcams on Linux Mint 14.1, and initially everything is working fine.
I symlinked the events folder to my Dropbox, and it works partially. I say partially because there are some issues syncing both ways. There's no problem for Zoneminder to create folders in the Dropbox directory, but since the folders are created with www-data as owner, Dropbox is not allowed to make any changes. This means, if I change anything in the ZM directory in Dropbox on a remote computer, the change is not synced to the box running ZoneMinder because it doesn't have proper access to the files. The logged in linux account differs from www-data, which is the default ZoneMinder user.
To fix this, the only way I can think of, is to change the ZM deault user to the same as the Linux user...but is it enough just to change the user in the zm.conf file? Will it break anything regarding SQL, as I understand www-data is also a SQL user?
Thanks in advance for the help!
Tobiii112
Posts: 3
Joined: Sat Dec 08, 2012 7:58 am

Re: sync events to Dropbox

Post by Tobiii112 »

Does Dropbox upload it after you changed the owner of the directories?
You could try to change the owner using a crontab. I don't know if it works, but give it a try ;)
zaphyr
Posts: 4
Joined: Thu Apr 11, 2013 9:20 am

Re: sync events to Dropbox

Post by zaphyr »

Tobiii112 wrote:Does Dropbox upload it after you changed the owner of the directories?
You could try to change the owner using a crontab. I don't know if it works, but give it a try ;)
Yes, if i chown the events directory it syncs fine both ways, but next time ZM creates new event pictures/folders I loose permissions to the new items an have to chown again. Using cron is a workaround yes, and if there is no other option, it'll have to do :)

EDIT: Actually, I'm looking in to something called "Incron" instead of crontab. While crontab triggers commands based on time, incron triggers based on changes in the files/folders. So instead of running cron every 5 minutes 24/7, incron only runs when theres an actual need for it.
zaphyr
Posts: 4
Joined: Thu Apr 11, 2013 9:20 am

Re: sync events to Dropbox

Post by zaphyr »

Ok, so it seems to be working now.

I set up incron using information found here: howtoforge/triggering-commands-on-file-or-directory-changes-with-incron

This is what I did:

Code: Select all

sudo incrontab -e
'sudo' is used because the cronjob is going to invoke the 'chown' command. For normal commands which doesn't require root, the 'sudo' part is not needed. Remember to add root to the incron.allow file

Then I created a incron job with these parameters

Code: Select all

/home/john/Dropbox/ZM/events/ IN_CREATE chown -Rv john:video /home/john/Dropbox/ZM
Of course, you will have to change 'john' to reflect your linux user

Now, according to the documentation in the link I provided earlier, you should be able to see if the incron job works, by looking in the syslog. My syslog did not show any relevant information, but by running some tests, it does indeed seem like the job is running just fine.
zaphyr
Posts: 4
Joined: Thu Apr 11, 2013 9:20 am

Re: sync events to Dropbox

Post by zaphyr »

Update for anyone interested

The solution above did not work, as incron does not watch folders recursively
To solve this I'm using a python script called watcher.py together with a config file watcher.ini, which recursively watches a folder and based on certain events can trigger a command. In my case it triggers a shell script that chowns and chmods the ZM event folder. I use chown and chmod because chown doesn't seem to give the group r+w access, just r, and I need rw access for the video group in order for www-data to be able to create new files and folder after it is chowned.
I hope this is the final fix, and it may be of use to anyone :)
Locked