Anyway, first few hurdles:
- Found a way to route to DSL modem, same exact script as DD-WRT (how convenient!)
- Found a way to add a non-root user, altered it to allow public key only and saved to nvram! (didn't know how to do it in dd-wrt, had to manually run the user setup script after each reboot). The only issue was permissions, which is easily fixed/hacked with init script
- Found a way to enable multiple printers (more on that in a moment)
- Found a way to send firmware to a printer that needs it (TODO as soon as I get a new USB2.0 hub)
- Found a way to set up sane to share a scanner! This is what pushed me to choose Tomato over DD-WRT on this router, actually. I'm sure there's a way to do the same thing there, but convenient google result is more convenient :)
- the way to share a printer on the next port (9101) is simply run "p910nd -b -f /dev/usb/lp1 1", where "-f /dev/usb/lp1" points it to the lp# device symlink, "1" means I want to use port 9101 (default is 9100 and the only remaining one is 9102), and in this case p910nd executable will rename itself to p9101d
- Loading Printer's Firmware in Hotplug Script page tells me there's an easy way to trap add/remove action on these guys, even tells me how to find the product ID. But after printing all vars, it's apparent there's no mention of the /dev/*lp# device.
DEVPATH='/devices/pci0000:00/0000:00:04.1/usb1/1-2/1-2:1.1'
root@rooter:/tmp/home/root# ls -ld /sys/devices/pci0000:00/0000:00:04.1/usb1/1-2/1-2\:1.1/usb\:lp1 lrwxrwxrwx 1 root root 0 Dec 31 1969 /sys/devices/pci0000:00/0000:00:04.1/usb1/1-2/1-2:1.1/usb:lp1 -> ../../../../../../class/usb/lp1This is easily parseable by a shell script (hotplug). Said script can immediately create an extra symlink, specific to the printer model -- that one is guaranteed to be the right one! Then, all I need to do is share it -- and there's already a way to do all these things. So, without further stalling for time, here's the hacky script:
if [ $INTERFACE = "7/1/2" ]; then
f=/sys/${DEVPATH}/usb:*; [ -e $f ] && d=`ls -d $f |sed 's/.*://'`
if [ $PRODUCT = "3f0/4117/100" ]; then
l=/dev/usb/HP1018
if [ $ACTION = "add" ] && [ "n$d" != "n" ]; then ln -sf /dev/${d} $l; p910nd -b -f $l 2
#TODO: send firmware to the printer
elif [ $ACTION = "remove" ]; then rm -f $l; killall p9102d 2>/dev/null
fi
elif [ $PRODUCT = "4b8/839/100" ]; then
l=/dev/usb/EpsonCX8400
if [ $ACTION = "add" ] && [ "n$d" != "n" ]; then ln -sf /dev/${d} $l; p910nd -b -f $l 1
elif [ $ACTION = "remove" ]; then rm -f $l; killall p9101d 2>/dev/null
fi
fi
fi
Not only does it create everything - it cleans up, too! And it can do the firmware trick as well (need usb hub for the thumbdrive - I'll probably need it for optware/sane, so might as well use it for the printer firmware, too, instead of mucking about with built-in flash)