Auto Copy Files When USB Mounted
|
24th Sep, 2014, 03:31 PM
Post: #1
|
|||
|
|||
Auto Copy Files When USB Mounted
Hi guys,
Just got my first Pi for XBMC media center and wanted to see if its possible to auto copy content on a USB Key to a main HD connected to the Pi when the USB key is auto mounted. The idea is that when I build one for family i can provide new content on the USB key and when they connect the USB it will copy the content to the main HD. Even better if i can prompt a library update after the copy in XBMC. I had a quick search around and couldn't find anything pre written. I thought for sure i'm not the only one with tech challenged family that update media centers in the same way. Not even sure what programming language to use. The Pi is running Xbian. Easy to change this if it makes the process achievable Thanks, Mike |
|||
26th Sep, 2014, 02:00 PM
Post: #2
|
|||
|
|||
RE: Auto Copy Files When USB Mounted
Are you talking system updates or simple media files?
Please read rules and do a search before you post! | FAQs | How to post log file? | Can't find an answer? Contact us. |
|||
26th Sep, 2014, 03:00 PM
Post: #3
|
|||
|
|||
RE: Auto Copy Files When USB Mounted
(26th Sep, 2014 02:00 PM)f1vefour Wrote: Are you talking system updates or simple media files? Just media files. Just want to make it as easy as giving family a USB key to connect and it will copy the new content and update XBMC library. One of the guys on the XBMC forum posted a possible solution I just need to test it. http://forum.xbmc.org/showthread.php?tid=205060&pid=1800362#pid1800362 Do you happen to know how i can install Rsync on the Xbian distro? Part of the solution above require Rsync. Thanks for the response Mike |
|||
26th Sep, 2014, 03:05 PM
Post: #4
|
|||
|
|||
RE: Auto Copy Files When USB Mounted
Sure can, it's what I was going to suggest.
sudo apt-get install rsync Please read rules and do a search before you post! | FAQs | How to post log file? | Can't find an answer? Contact us. |
|||
26th Sep, 2014, 03:17 PM
Post: #5
|
|||
|
|||
RE: Auto Copy Files When USB Mounted | |||
26th Sep, 2014, 04:08 PM
Post: #6
|
|||
|
|||
RE: Auto Copy Files When USB Mounted
Good luck.
Please read rules and do a search before you post! | FAQs | How to post log file? | Can't find an answer? Contact us. |
|||
28th Sep, 2014, 07:14 PM
Post: #7
|
|||
|
|||
RE: Auto Copy Files When USB Mounted
I can't seem to get the xbmc-send to work
xbmc-send --action="UpdateLibrary(video)" Has anyone here used the xbmc-send command with xbian? Thanks, Mike |
|||
28th Sep, 2014, 09:13 PM
Post: #8
|
|||
|
|||
RE: Auto Copy Files When USB Mounted
You can use curl also, but yes I have used it before.
Please read rules and do a search before you post! | FAQs | How to post log file? | Can't find an answer? Contact us. |
|||
1st Oct, 2014, 09:56 PM
Post: #9
|
|||
|
|||
RE: Auto Copy Files When USB Mounted
Anyone know of timeouts on udev rules?
I have the rule working and the copy starts but stops at about 77-80mb. So I was thinking the udev rule runs the script and then times out. udev rule:ACTION=="add", SUBSYSTEM=="block", KERNEL=="sdb1", RUN+="/storage/script/usbcopy.sh" Script: #!/bin/sh /storage/.xbmc/addons/network.backup.rsync/bin/rsync -a -v --ignore-existing /media/USB/NewMovies/* /media/mainhd/ /usr/bin/xbmc-send --action="UpdateLibrary(video)" /usr/bin/xbmc-send --action="Notification(All Done, You may safely remove the drive)" From WinSCP I can see the file start and progress and then stop at about the 77mb-80mb. Any ideas thanks, Mike |
|||
2nd Oct, 2014, 02:32 PM
Post: #10
|
|||
|
|||
RE: Auto Copy Files When USB Mounted
Just to mention that running the script manually completes the copy. I just fails to complete when executed from the udev rule.
Since the size of the file is different each time i was thinking udev may have a time out. Thanks, Mike |
|||
8th Oct, 2014, 02:14 PM
Post: #11
|
|||
|
|||
RE: Auto Copy Files When USB Mounted
@mjbrown
timeout on udev rules makes perfect sense. otherwise udevtrigger could block booting of system. to check if this is problem, make your usbcopy.sh just wrapper to launch another - real copy script as spawned process. so in usbcopy.sh called from udev rull do just Code: /run/my/real/copy.sh & this way copy process will start as another process and usbcopy.sh rule will return to udev immediately. another approach and maybe more suitable would be to re-use xbians usbmount implementation (auto usb storage mounter). it itself is called by a udev rule, spawned, and mounts your drive. it is already designed to provide "hooks" for user to easy inject the mount and umount events. all you need is to copy your scrtipt into /etc/usbmount/mount.d . all scripts here are started after disk is mounted. you don't need any conf files changes / updates. it even provides some internal info to the scripts, like UM_MOUNTPOINT is actual dir where the disk is mounted, and others ... UM_DEVICE - filename of the device node UM_MOUNTPOINT - mointpoint UM_FILESYSTEM - filesystem type UM_MOUNTOPTIONS - mount options that have been passed to the mount command UM_VENDOR - vendor of the device (empty if unknown) UM_MODEL - model name of the device (empty if unknown) some basic doc is at /usr/share/doc/usbmount/README.gz . but again, just put the script into relevant hook folder and you are done. Please read rules and do a search before you post! . FAQs . How to post log file? . Looking for answers? Please start here |
|||
10th Oct, 2014, 07:31 PM
(This post was last modified: 10th Oct, 2014 07:33 PM by f1vefour.)
Post: #12
|
|||
|
|||
RE: Auto Copy Files When USB Mounted
I mentioned you could update the library with curl but I never gave an example.
Code: curl -H "Content-Type: application/json" -u user:pword -d "{\"jsonrpc\":\"2.0\",\"method\":\"VideoLibrary.Scan\",\"id\":\"scan\"}" http://127.0.0.1:8686/jsonrpc Please read rules and do a search before you post! | FAQs | How to post log file? | Can't find an answer? Contact us. |
|||
« Next Oldest | Next Newest »
|
Possibly Related Threads... | |||||
Thread: | Author | Replies | Views: | Last Post | |
[PROBLEM] Auto-update to RC3 -> playing video files not working anymore | syco | 15 | 41,165 |
17th Sep, 2014 10:40 AM Last Post: moocow |