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

Add multiple printers with hotplug Tutorial

Discussion in 'Tomato Firmware' started by hanbaoxu, Jul 17, 2014.

  1. hanbaoxu

    hanbaoxu Network Newbie Member

    Found this article, very useful for people like me who connect more than one printers to the router.

    thanks to all4os.com, this saved me a lot of time.

    Link is here: Add multiple printers on Tomato firmware router in a hotplug script with p910nd

    The key part of this: "Hotplug script" is as shown below, modify and copy it to your router:

    #!/bin/sh

    # log printers Interface, VID, and PID information
    echo Product:${PRODUCT} Interface: ${INTERFACE}>> /var/log/hotplug

    # process printers only
    # usb port
    # parallel to usb port
    if [ "$INTERFACE" = "7/1/1" ] || [ "$INTERFACE" = "7/1/2" ]
    then

    # set -x
    DEV="none"

    # Printer_1

    if [ "$PRODUCT" = "4f9/33/100" ]
    then
    VID=”04f9“
    PID="0033"
    DEV="Printer_1"
    port="0"
    fi

    # Printer_2

    if [ "$PRODUCT" = "1645/6/100" ]
    then
    VID="1645"
    PID="0006"
    DEV="Printer_2"
    port="1"
    fi

    if [ "$DEV" != "none" ]
    then
    if [ -n "$port" ]; then
    for pid in `ps | grep -i p910${port}d | grep -v grep | cut -c1-5` ; do
    kill -9 $pid
    done
    if [ "$ACTION" = "add" ]
    then
    # search for last printer assignment in syslog (/var/log/syslog.log or logread)

    LP=`dmesg | grep -i "usblp.: USB Bidirectional printer dev .* if .* alt .* proto .* vid 0x$VID pid 0x$PID" | grep -io "lp[0-9]" | tail -n 1`

    if [ "$LP" != "" ]
    then
    echo $LP >/var/run/$DEV.lp
    ln -s /dev/usb/$LP /dev/$DEV
    p910nd -b -f /dev/$DEV $port
    fi

    fi

    if [ "$ACTION" = "remove" ]
    then
    # LP = `cat /var/run/$DEV.lp`
    rm /var/run/$DEV.lp
    rm /dev/$DEV

    fi
    fi
    fi
    fi
     
    Last edited: Jul 17, 2014

Share This Page