View Single Post
Old 02-07-2011, 07:33 AM   #1
dent
Junior Member
dent began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Jan 2011
Device: kindle 3
automatically sync remote directory to kindle on wlan0 up

hi all,

I asked this on the ##kindle irc channel but didn't get any feedback so i'll try here

What I'm trying to do:
When I switch the kindle on at home, i want it to rsync (over ssh) the contents of a remote folder to the kindle (fwiw, the remote folder holds daily news which calibre downloads for me every morning).

My approach has been to add the following to my /etc/network/interfaces
Code:
iface wlan0 inet dhcp
	# note post-up doesn't execute anything!
	up /mnt/us/local/bin/wlan0-up.sh
The wlan0-up.sh script checks the essid of the current network and if it's the home one, runs rsync over ssh.

I know the script is correct because it works fine when if I ssh into the kindle and run:
/mnt/us/local/bin/wlan0-up.sh

My 2 problems (I care a lot more about 2 than 1):
  • Getting the ESSID: The following 2 commands return an empty string when run automatically via ifup:
    Code:
    ssid=$(iwconfig wlan0 | head -n 1 | awk {'print $4'} |cut -d: -f2 |tr -d \")
    Code:
    ssid=$(wpa_cli status | grep ^ssid=|cut -d= -f2)
    Both of them return the correct essid when run manually from the command line. The following command works for me, both automatically via ifup and manually on the command line but it's not ideal:
    Code:
    grep -q 'ssid=MYESSID' /var/log/wpa_supplicant.wlan0.log
  • SSH'ing: The following simple ssh command does not connect, it simply returns immediately when run automatically via ifup:
    Code:
    ssh -i /path/to/valid/id_dsa  remuser@remhost touch /tmp/test_file
    The same command works fine from the command line. The wlan0-up.sh script also makes sure it restores known_hosts and the id_dsa key before attempting to ssh anywhere so it's not that.
I've tried all sorts of things including sleeping for a while before running iwconfig, running the commands in a loop and sleeping after each failed one for up to 3 minutes and issuing
Code:
dbus-send --system /default com.lab126.wifid.cmConnected
before calling iwconfig.
This is now really winding me up (!) as it shouldn't be this hard. anyone have any thoughts on it or otherwise managed to get the kindle to automatically sync from a remote folder? I currently have to ssh into it and run the script manually.

Thanks!
d

Last edited by dent; 02-07-2011 at 07:35 AM. Reason: clarified a "doesn't work" statement
dent is offline   Reply With Quote