• SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Out of which user script should I call rsync?

marassa

New Around Here
Hi there,

I've got an RT-N66U router running latest Merlin firmware, installed an internal SD card, installed optware onto it, installed rsync via ipkg.

The goal is to rsync a local USB drive to match a remote Windows server running DeltaCopy, on every power on of the router.

For this to work, 3 conditions must be met:
1. WAN available (for the source to be reachable)
2. Destination USB drive mounted
3. rsync itself available

I wrote a post-mount script which works perfectly when executed manually but when run by the system on boot, all three rsync calls (I sync three different modules sequentially) return 127 as evidenced by "logger $?" commands directly following the rsync calls.

As far as I understand it, the rsync command itself seems to be not available at the time the script runs.

The question is where from am I supposed to call rsync for all three conditions to be met?

rsync (as a part of optware) resides on the SD which (I believe) doesn't trigger a post-mount script after its mount.

Can it even be so that the SD is not mounted yet when the USB drive is mounted?

I would really appreciate any help.

Best regards,
Andrei
 
Hi there,

I've got an RT-N66U router running latest Merlin firmware, installed an internal SD card, installed optware onto it, installed rsync via ipkg.

The goal is to rsync a local USB drive to match a remote Windows server running DeltaCopy, on every power on of the router.

For this to work, 3 conditions must be met:
1. WAN available (for the source to be reachable)
2. Destination USB drive mounted
3. rsync itself available

I wrote a post-mount script which works perfectly when executed manually but when run by the system on boot, all three rsync calls (I sync three different modules sequentially) return 127 as evidenced by "logger $?" commands directly following the rsync calls.

As far as I understand it, the rsync command itself seems to be not available at the time the script runs.

The question is where from am I supposed to call rsync for all three conditions to be met?

rsync (as a part of optware) resides on the SD which (I believe) doesn't trigger a post-mount script after its mount.

Can it even be so that the SD is not mounted yet when the USB drive is mounted?

I would really appreciate any help.

Best regards,
Andrei


I personally use init-start with a sleep 150

Code:
#!/bin/sh

HARDWARE_MODEL=$(nvram get productid)
MYROUTER=$(nvram get computer_name)
BUILDNO=$(nvram get buildno)

/usr/bin/logger -t "($(basename $0))" $$ "Martineau $MYROUTER BOOT in progress... [$@]" 

# NOTE: Can't use Flash drive /tmp/mnt/RT-AC56U/ 'cos it hasn't been mounted yet :-(
# Can't use Flash drive /tmp/mnt/RT-N66U/ 'cos it hasn't been mounted yet :-(
echo `date` > /tmp/BOOTINPROGRESS

# If we ensure that the mount point exists at this stage of the boot, it can eliminate the Hotplug boot error?
#   hotplug[427]: USB /dev/sdxn (ext4) failed to mount at the first try! 
#mkdir -p /tmp/mnt/$MYROUTER

# Should be sufficient to cover physical BOOT process?
sleep 150


...include one-off boot dependent script calls here....

Regards,
 
Thanks Martineau, that's one way for sure.
I also just had an idea of moving optware along with rsync to the very drive I am syncing - this way I'll hopefully have rsync available by the time the post-mount script for that disk fires.
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!

Members online

Top