You are not logged in.
I am stumped as to what exactly is going on here.
What I am trying to do is have my garmin watch automatically rsync to a folder on my dropbox (mounted on my filesystem), to be accessible to tapiriik.
I have made a rule, that I have verified matches the USB device I would like to sync:
#/etc/udev/rules.d/61-tapiriik.rules
ACTION=="add", KERNEL=="sd*", ATTRS{idVendor}=="0424", ATTRS{idProduct}=="2513", RUN+="/home/wash/bin/garmin_upload.sh"
the script that runs:
#/home/wash/bin/garmin_upload.sh
#!/bin/bash
rsync -v /media/GARMIN/Garmin/Activity/* /home/wash/Dropbox/Apps/tapiriik/ &> /home/wash/tester
I redirect the output to that file and tail -f /home/wash/tester to view what happens:
rsync: change_dir "/media/GARMIN/Garmin/Activity" failed: No such file or directory (2)
sent 18 bytes received 12 bytes 60.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1165) [sender=3.1.1]
I have USB devices automount using udisks2. I (wash), not root, am the owner of /media/GARMIN. by adding ls -al /media to garmin_upload.sh I found that Udev is unable to see /media/GARMIN. I also added id so I could verify the script runs as root:
#/home/wash/bin/garmin_upload.sh
#!/bin/bash
id &> /home/wash/tester
ls -al /media &> /home/wash/tester
rsync -v /media/GARMIN/Garmin/Activity/* /home/wash/Dropbox/Apps/tapiriik &> /home/wash/tester
tail -f /home/wash/tester
uid=0(root) gid=0(root) groups=0(root)
tail: tester: file truncated
total 12
drwxr-xr-x 3 root root 4096 Nov 11 19:43 .
drwxr-xr-x 18 root root 4096 Nov 4 08:29 ..
tail: tester: file truncated
rsync: change_dir "/media/GARMIN/Garmin/Activity" failed: No such file or directory (2)
sent 18 bytes received 12 bytes 60.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1165) [sender=3.1.1]
why is this folder not visible to the script/udev? If I run the script as root using su, it works fine. I've also tried inserting very long sleeps (10s) to make sure the script isn't ahead of the mounting.
Last edited by pdizzle (2015-11-12 05:23:23)
Offline
Offline
Thanks for the fast response. Very informative. I have left the script as-is but update the Udev rule to read:
ACTION=="add", KERNEL=="sd*", ATTRS{idVendor}=="0424", ATTRS{idProduct}=="2513", ENV{SYSTEMD_WANTS}="upgarmin.service"
the systemd service:
[Unit]
Description=Sync Garmin Device with Dropbox
[Service]
Type=oneshot
ExecStart=/home/wash/bin/garmin_upload.sh
[Install]
WantedBy=multi-user.target
But this does not seem to execute. If i start the service manually with systemctl start upgarmin.service it does work, though. I have enabled the systemd service. Why would this be?
Offline
I updated my service file to directly follow the syntax as you had laid out and now it works:
[Unit]
Description=Sync Garmin Device with Dropbox
Requires=media-GARMIN.mount
After=media-GARMIN.mount
[Service]
Type=oneshot
ExecStart=/home/wash/bin/garmin_upload
[Install]
WantedBy=media-GARMIN.mount
thanks again for the help
Offline
No problem. Please remember to mark your thread as [Solved] by editing your first post and prepending it to the title.
Offline