1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to install and run Python script on Tomato USB

Discussion in 'Tomato Firmware' started by Jas, Mar 1, 2013.

  1. Jas

    Jas Networkin' Nut Member

  2. quihong

    quihong Serious Server Member

    You'll need entware (or optware).

    To get you started:

    Code:
    Plug in your USB flash drive (will be completely wiped).
    SSH (Putty) into your router.
     
    #Partition your usb flash drive
    umount /dev/sda1
    fdisk /dev/sda
     
    # Type in the following commands:
    # p      # list current partitions
    # o      # to delete all partitions
    # n      # new partition
    # p      # primary partition
    # 1 (one) # first partition
    # <enter> # default start block
    # <enter> # default end block #use the whole flash drive
    # w      # write new partition to disk
     
     
    #umount /dev/sda1 incase it was automounted
    umount /dev/sda1
     
     
    #format newly created partition
    #label disk as 'optware' case sensitive
    mke2fs -j -L optware /dev/sda1
     
    #mount the new disk partition
    mount /dev/sda1 /opt
     
    #Install entware
    cd /opt
    wget http://wl500g-repo.googlecode.com/svn/ipkg/entware_install.sh
    sh ./entware_install.sh
     
    #install python
    opkg install python
     
    
     
  3. Jas

    Jas Networkin' Nut Member

    Thank you quihong :) I'll try to do that tonight and will let you know how it went !!
     
  4. Jas

    Jas Networkin' Nut Member

    Hey quihong.. Sorry it took me so long to respond. Anyway so I'm done with the steps you have mentioned and installed python successfully on RTN-16. Could you please provide me with the next steps? Thanks.
     
  5. quihong

    quihong Serious Server Member

    You know it's been over a year right? Your original link doesn't even work anymore.
     
  6. koitsu

    koitsu Network Guru Member

    Recommended changes:

    1. Use mkfs.ext3 instead of mkfs.ext2
    2. Do not use -j flag in mkfs.ext3; journalling just causes more read/write I/O on a USB drive, and you want to keep the I/O down to a minimum if possible
    3. Change filesystem label (-L flag) "optware" to "entware" to be consistent; I tend to just use a generic "usbflash" as the label
    4. Don't mount the literal drive as /opt; instead just use a bind mount, and let TomatoUSB do the right thing automatically by mounting /dev/sda1 as /tmp/mnt/{label-you-chose-during-mkfs}, followed by mount -o bindable /tmp/mnt/{label-you-chose-during-mkfs} /opt
    5. Installation for Entware has changed, as well as the URL. The procedure now, taken from their own site:

    wget -O - http://entware.wl500g.info/binaries/entware/installer/entware_install.sh | sh

    Footnotes:

    * mount -o bindable is the same thing as mount -o bind or mount --bind. mount -o bindable just happens to match exactly the syntax shown in the mount usage syntax.
    * This is a matter of preference, but I tend to use an mount.autorun script (placed in /tmp/mnt/{label-you-chose-during-mkfs}) that PROPERLY deals with the auto-creation of /opt. What properly means: if you were to simply add the mount -o bindable to an auto-exec part in the GUI, every time you'd click Save in the GUI you'd end up with multiple bindable mounts (Linux is stupid and will let you make bindable mounts of the same mountpoint over and over, i.e. df -k will show several /opt mounts, and this causes massive confusion). The script I use does the following right up front:

    Code:
    #!/bin/sh
    if /bin/grep -q /opt /proc/mounts
    then
            /bin/umount /opt
    
            if [ $? -ne 0 ]; then
                    echo "umount failed, script not continuing"
                    exit 1
            fi
    fi
    
    /bin/mount -o bindable /tmp/mnt/usbflash /opt
    
    What this does is cause /bin/umount /opt only to be run if /opt shows up in /proc/mounts. This ensures that you can only have "one /opt binable mount" at one time. Hope this makes sense.
     
  7. Jas

    Jas Networkin' Nut Member

    Yes it has been.. The files from that Pyhton Script are now here: https://db.tt/DZaR6a58 . Any help would be appreciated.
    According to koistu, should I install entware again ?
     
  8. koitsu

    koitsu Network Guru Member

    If it's working for you, there's no reason to uninstall. However, you may want to run opkg update ; opkg upgrade a few times (2-3 times -- not kidding around here) because all the URLs for package updates/etc. have changed and it has to upgrade itself in the process too.
     

Share This Page