Hello,
When you start or reboot your router when a printer connected to its usb port is switched off, there is no /dev/lp0 device. If you start p910nd in that case, every 10 seconds the following message is printed in the syslog:
Mar 20 08:46:17 router lpr.err p9100d[10111]: /dev/lp0: No such file or directory
Mar 20 08:46:17 router lpr.err p9100d[10111]: /dev/lp0: No such file or directory, will try opening later
I've created a little script that starts p910nd when a printer is plugged in. It uses hotplug.d. I'm not really sure how to check for a printer, but on my router (netgear wndr3700) the following works. Also, I found that p910nd seems to have a bug that the .pid file is not removed when the daemon is stopped. Requirements: usb-support (kmod-usb-core, kmod-usb-Xhci, kmod-usb2), usb-printing support (kmod-usb-printer) and p910nd. kmod-ledtrig-usbdev will turn on the usb LED automatically if the printer is switched on. See http://wiki.openwrt.org/doc/howto/p910nd.server for more info.
This is my script:
/etc/hotplug.d/usb/50-p910nd
#!/bin/sh
case "$ACTION" in
add)
# Check if lp device is plugged in and p910nd is not already started
if [ ! -f /var/run/p9100d.pid -a -d /sys/devices/platform/ar71xx-ehci/usb?/*/*/*/lp0 ]; then
logger "USB Printer device plugged in, starting p910nd"
/etc/init.d/p910nd start
fi
;;
remove)
# Check if lp device is unplugged and if p910nd is still running
if [ ! -d /sys/devices/platform/ar71xx-ehci/usb?/*/*/*/lp0 -a -f /var/run/p9100d.pid ]; then
logger "USB Printer device unplugged, stopping p910nd"
/etc/init.d/p910nd stop
# p910nd does not seem to remove .pid file when stopped, removing it manually
rm /var/run/p9100d.pid
fi
;;
esac
Improvements are welcome. Right now for example, it checks only for lp0, not lpX or other ports than 9100 (9101, 9102 etc). And the device detection could probably be better. Hope you like it.