View Single Post
Old 11-20-2011, 07:53 PM   #29
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Quote:
Originally Posted by Mario1up View Post
I noticed that there seems to be no thread that compiles all the hacks into one topic. So, to make things easy to find, I've decided to make this list of all the Kindle hacks I could gather. I will update it as new ones are made.

If I miss any, please feel free to post them here and I will add them. If you think a hack should go into a different category or there should be a new category, please go ahead and say so.
This 'mntusb' script allows connecting multiple kindles simultaneously to a host linux PC, where they will all be usable at the same time.

I expanded on a 'mntusb' script I had posted elsewhere on this forum. Previously, it required command-line parameters to specify which kindle number and which usb number.

This version is all automatic. It finds the kindles and assigns each of them a unique HWaddr MAC address, and an IPv4 address in a unique IP subnet, as defined in their /mnt/us/usbnet/config files.

I use 10.10.x.x/24 subnets because they will not conflict with 192.168.x.x addresses already assigned to common networking devices.

For each kindle number 1 to 9, The script "pings" 10.10.x.2 subnet range 1 to 9 to find newly attached kindles.

This script also lists which IP and MAC addresses are assigned to all of the kindles, so is useful to run just to get information about them.

This script may also be useful to run in the background as a scheduled daemon task.

*** UPDATE 2011 Nov 22 ***

The script source code and attached file have been updated to tell the Gnome Network Manager to stop messing with the usbnet connections. This should stop the problems with spontaneous usbnet disconnects. It will have to be repeated whenever another usb network device is attached. (Thanks ryran)

Source code:
Spoiler:
Code:
#!/bin/sh
### mntusb - find and mount usb kindles at 10.10.x.2
### This script runs on a linux host (not on the kindles).
### Each kindle must be on a different IPv4 subnet (unique 'x' above).
### Kindle subnets are set in the /mnt/us/usbnet/etc/config file. 
echo Mounting usb network kindles...
for U in $(nmcli dev|awk '/usb.*connecting/{print$1}'); do
    nmcli dev disconnect iface $U>/dev/null
done
for U in 0 1 2 3 4 5 6 7 8 9; do
  sudo ifconfig usb$U up 2>/dev/null||continue
  ifconfig|grep -A1 usb$U|grep "inet ">/dev/null&&ifconfig|grep -A1 usb$U&&continue
  for K in 1 2 3 4 5 6 7 8 9; do
    ifconfig|grep ":10.10.$K.1 ">/dev/null&&continue
    sudo ifconfig usb$U down
    sudo ifconfig usb$U hw ether ee:49:00:00:00:0$K
    sudo ifconfig usb$U 10.10.$K.1 netmask 255.255.255.0
    sudo ifconfig usb$U up
    ping -c1 -w1 10.10.$K.2>/dev/null&&(
      ifconfig|grep -A1 usb$U
### Optional: mount kindle file system in host /mnt/.
#     mkdir /mnt/kindle$K 2>/dev/null
#     sudo umount /mnt/kindle$K 2>/dev/null
#     sshfs /mnt/kindle$K root@10.10.$K.2:/
    )&&break
    sudo ifconfig usb$U down
    sudo ifconfig usb$U del 10.10.$K.2 2>/dev/null
    sudo ifconfig usb$U up
  done
done

Sample output from mntusb script testing:
Spoiler:

Sample output from ifconfig after plugging in kindle4, then kindle2, then kindle3:
Code:
usb0      Link encap:Ethernet  HWaddr ee:49:00:00:00:00  
          inet6 addr: fe80::ec49:ff:fe00:0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:28 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:6464 (6.4 KB)

usb1      Link encap:Ethernet  HWaddr ee:49:00:00:00:00  
          inet6 addr: fe80::ec49:ff:fe00:0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:27 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:6122 (6.1 KB)

usb2      Link encap:Ethernet  HWaddr ee:49:00:00:00:00  
          inet6 addr: fe80::ec49:ff:fe00:0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:26 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:5982 (5.9 KB)
As you can see, they all have the same HWaddr, which will prevent all but one of them from working no matter WHAT IPv4 addresses get assigned to them.

Output from ./mntusb:
Code:
Mounting usb network kindles...
[sudo] password for user: 
usb0      Link encap:Ethernet  HWaddr ee:49:00:00:00:04  
          inet addr:10.10.4.1  Bcast:10.10.4.255  Mask:255.255.255.0
usb1      Link encap:Ethernet  HWaddr ee:49:00:00:00:02  
          inet addr:10.10.2.1  Bcast:10.10.2.255  Mask:255.255.255.0
usb2      Link encap:Ethernet  HWaddr ee:49:00:00:00:03  
          inet addr:10.10.3.1  Bcast:10.10.3.255  Mask:255.255.255.0
Output from ./mntusb after unplugging kindle2 and kindle4:
Code:
Mounting usb network kindles...
usb2      Link encap:Ethernet  HWaddr ee:49:00:00:00:03  
          inet addr:10.10.3.1  Bcast:10.10.3.255  Mask:255.255.255.0
Output from ./mntusb after plugging back in kindle2, then kindle4:
Code:
Mounting usb network kindles...
usb0      Link encap:Ethernet  HWaddr ee:49:00:00:00:02  
          inet addr:10.10.2.1  Bcast:10.10.2.255  Mask:255.255.255.0
usb1      Link encap:Ethernet  HWaddr ee:49:00:00:00:04  
          inet addr:10.10.4.1  Bcast:10.10.4.255  Mask:255.255.255.0
usb2      Link encap:Ethernet  HWaddr ee:49:00:00:00:03  
          inet addr:10.10.3.1  Bcast:10.10.3.255  Mask:255.255.255.0
As you can see, linux assigned different usb device numbers after they were reconnected in a different order.

If you uncomment the lines marked as "Optional" in 'mntusb', the script will also mount the kindle file systems in the linux host PC as /mnt/kindle* folders.
Attached Files
File Type: gz mntusb.tar.gz (639 Bytes, 885 views)

Last edited by geekmaster; 01-02-2012 at 09:37 AM.
geekmaster is offline   Reply With Quote